Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // API Reference: https://www.wix.com/velo/reference/api-overview/introduction
- // “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world
- import wixUsers from 'wix-users';
- import {getUser} from 'backend/usersInfo';
- import wixData from 'wix-data';
- function createApplication(id) {
- getUser(id)
- .then((user) => {
- let toInsert = {
- "name": $w('#input8').value,
- "patientID": user['slug'],
- "dateOfSubmissionOfTheForm": $w('#datePicker7').value,
- "birtday": $w('#datePicker4').value,
- "address": $w('#input9').value,
- "email": $w('#input10').value,
- "phone": $w('#input11').value,
- "type": $w('#checkboxGroup4').value,
- "sex": $w('#radioGroup4').value,
- "vaccinated": $w('#radioGroup5').value,
- "vaccineManufacter": $w('#radioGroup6').value,
- "1stVaccineShot": $w('#datePicker5').value,
- "2ndVaccineShot": $w('#datePicker6').value,
- "recentlyTraveled": $w('#radioGroup7').value,
- "previousCovidPositive": $w('#radioGroup8').value,
- "symptomsLast14Days": $w('#checkboxGroup1').value,
- "speakingLanguage": $w('#input12').value,
- "race": $w('#radioGroup9').value,
- "ethnicity": $w('#radioGroup10').value,
- "insuranceName": $w('#input13').value,
- "insuranceId": $w('#input14').value,
- "document": $w('#input15').value,
- "agree": $w('#checkbox1').value,
- };
- wixData.insert("Covid_Collection", toInsert)
- .then((results) => {
- console.log('success');
- let item = results;
- $w('#text34').show();
- $w('#image5').hide();
- })
- .catch((err) => {
- let errorMsg = err;
- console.log(errorMsg);
- $w('#text35').text = errorMsg;
- $w('#text35').show();
- $w('#image5').hide();
- });
- })
- .catch((err) => {
- let errorMsg = err;
- console.log(errorMsg);
- $w('#text35').text = errorMsg;
- $w('#text35').show();
- $w('#image5').hide();
- });
- }
- $w.onReady(function () {
- $w('#button3').onClick(function() {
- // if($w('#input8').value.length != 0 && $w('#input10').value.length != 0 && $w('#datePicker4').value){
- if ($w('#input8').value.length != 0 && $w('#input10').value.length != 0 && $w('#checkboxGroup4').value.length != 0 && $w('#input9').value.length != 0 && $w('#input11').value.length != 0 && $w('#radioGroup4').value.length != 0) {
- $w('#image5').show();
- $w('#button3').disable();
- $w('#text34').hide();
- $w('#text35').hide();
- $w('#text139').hide();
- createApplication(wixUsers.currentUser.id);
- $w('#image5').hide();
- $w('#button3').enable();
- // if (!wixUsers.currentUser.loggedIn) {
- // let name = $w('#input8').value;
- // let email = $w('#input10').value;
- // let birthday = $w('#datePicker4').value;
- // wixUsers.register(email, birthday.toLocaleDateString('en-US'))
- // .then((result) => {
- // let user = result.user;
- // $w('#text139').text = "The account was created.\nLogin:"+email+"\nPassword:"+birthday.toLocaleDateString('en-US');
- // $w('#text139').show();
- // createApplication(user['id']);
- // $w('#button3').enable();
- // })
- // .catch((err) => {
- // let errorMsg = err;
- // console.log('register error');
- // console.log(errorMsg);
- // $w('#text35').text = errorMsg.substr(0, errorMsg.indexOf(']') + 1) + " already exists";
- // // $w('#text35').text = errorMsg.substr(0, 10) + "already exists";
- // $w('#text35').show();
- // $w('#image5').hide();
- // $w('#button3').enable();
- // });
- // }
- // else{
- // createApplication(wixUsers.currentUser.id);
- // $w('#image5').hide();
- // $w('#button3').enable();
- // }
- }
- else{
- $w('#text35').text = "Fill in the required fields";
- $w('#text35').show();
- $w('#image5').hide();
- $w('#button3').enable();
- }
- });
- });
- wixUsers.onLogin( () => {
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement