-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbookPhotoShoot.js
More file actions
34 lines (31 loc) · 1.19 KB
/
bookPhotoShoot.js
File metadata and controls
34 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {getFormAddressFields} from "./general";
import {deleteCookie} from "./clientUtils";
async function submitPhotoShootForm() {
localStorage.setItem('photoShootBooked', true);
const addressFields = getFormAddressFields();
let amount = document.getElementById('amount').value;
let pn = formatPhoneNumber(phoneNumber.value);
// Write to Firestore
await db.collection('users').doc(authUser.current.uid).update({
...addressFields,
phoneNumber: pn
})
.then(() => {
console.log(`Address and phone of ${authUser.current.uid} is now updated`);
confirmationScreen.style.display = 'block';
header.style.display = 'none';
formDiv.style.display = 'none';
deleteCookie('photo_invite');
})
.catch((error) => {
errorHandler.report(error);
console.error("Error updating document: ", error);
});
}
photoShootInviteCode.value = checkCookie('photo_invite');
photoShootForm.addEventListener('submit', submitPhotoShootForm);
phoneNumber.addEventListener('input', function () {
const pn = formatPhoneNumber(phoneNumber.value);
const error = pn.length >= 12 && pn.includes('+') ? '' : 'Ogiltigt mobilnummer';
phoneNumber.setCustomValidity(error);
});