(action, formData, currency, timezoneId)
| 5 | import Loading from '/components/Loading.ts'; |
| 6 | export const actionWords = new Map([['change-email', 'change email'], ['verify-change-email', 'change email'], ['change-password', 'change password'], ['change-dav-password', 'change WebDav password'], ['delete-account', 'delete account'], ['change-currency', 'change currency'], ['change-timezone', 'change timezone']]); |
| 7 | function formFields(action, formData, currency, timezoneId) { |
| 8 | const fields = [{ |
| 9 | name: 'action', |
| 10 | label: '', |
| 11 | type: 'hidden', |
| 12 | value: action, |
| 13 | overrideValue: action, |
| 14 | required: true, |
| 15 | readOnly: true |
| 16 | }]; |
| 17 | if (action === 'change-email') { |
| 18 | fields.push({ |
| 19 | name: 'email', |
| 20 | label: 'Email', |
| 21 | type: 'email', |
| 22 | placeholder: 'jane.doe@example.com', |
| 23 | value: getFormDataField(formData, 'email'), |
| 24 | required: true |
| 25 | }); |
| 26 | } else if (action === 'verify-change-email') { |
| 27 | fields.push({ |
| 28 | name: 'email', |
| 29 | label: 'Email', |
| 30 | type: 'email', |
| 31 | placeholder: 'jane.doe@example.com', |
| 32 | value: getFormDataField(formData, 'email'), |
| 33 | required: true |
| 34 | }, { |
| 35 | name: 'verification-code', |
| 36 | label: 'Verification Code', |
| 37 | description: `The verification code to validate your new email.`, |
| 38 | type: 'text', |
| 39 | placeholder: '000000', |
| 40 | required: true |
| 41 | }); |
| 42 | } else if (action === 'change-password') { |
| 43 | fields.push({ |
| 44 | name: 'current-password', |
| 45 | label: 'Current Password', |
| 46 | type: 'password', |
| 47 | placeholder: 'super-SECRET-passphrase', |
| 48 | required: true |
| 49 | }, { |
| 50 | name: 'new-password', |
| 51 | label: 'New Password', |
| 52 | type: 'password', |
| 53 | placeholder: 'super-SECRET-passphrase', |
| 54 | required: true |
| 55 | }); |
| 56 | } else if (action === 'change-dav-password') { |
| 57 | fields.push({ |
| 58 | name: 'new-dav-password', |
| 59 | label: 'New WebDav Password', |
| 60 | type: 'password', |
| 61 | placeholder: 'super-SECRET-passphrase', |
| 62 | required: true, |
| 63 | description: 'Alternative password used for WebDav access and/or HTTP Basic Auth.' |
| 64 | }); |
no test coverage detected