|
33 | 33 | const dispatch = createEventDispatcher() |
34 | 34 |
|
35 | 35 | function saveAuthenticatedUser(body) { |
36 | | -
|
37 | 36 | $user.naturapeuteID = body.id |
38 | 37 |
|
39 | 38 | $user.author.email = body.email |
|
43 | 42 | $user.therapist.phone = body.phone |
44 | 43 |
|
45 | 44 | const office = body.offices[0] |
| 45 | +
|
46 | 46 | if (office) { |
47 | 47 | $user.author.street = office.street |
48 | 48 | $user.author.city = office.city |
|
73 | 73 | if(body.invoice_data.services) $user.preferredServices = body.invoice_data.services.map(e => ({ ...e })) |
74 | 74 | $patients = body.patients.map(e => ({ ...e })) |
75 | 75 |
|
76 | | - saveUser( |
77 | | - $user.naturapeuteID, |
78 | | - $user.author, |
79 | | - $user.therapist, |
80 | | - $user.servicePrice, |
81 | | - $user.preferredServices, |
82 | | - $patients |
83 | | - ) |
| 76 | + if ($user.naturapeuteID) { |
| 77 | + saveUser( |
| 78 | + $user.naturapeuteID, |
| 79 | + $user.author, |
| 80 | + $user.therapist, |
| 81 | + $user.servicePrice, |
| 82 | + $user.preferredServices, |
| 83 | + $patients |
| 84 | + ) |
| 85 | + } |
84 | 86 | } |
85 | 87 |
|
86 | 88 | function onAuthenticate() { |
|
102 | 104 |
|
103 | 105 | dispatch('failed') |
104 | 106 | } |
| 107 | +
|
| 108 | + function onDemoMode() { |
| 109 | + saveAuthenticatedUser({ |
| 110 | + email: 'john.doe@email.com', |
| 111 | + phone: '0313172521', |
| 112 | + firstname: 'John', |
| 113 | + lastname: 'Doe', |
| 114 | + offices: [], |
| 115 | + invoice_data: { |
| 116 | + author: { |
| 117 | + name: 'Cabinet de John', |
| 118 | + street: 'Rue de Bourgogne 19', |
| 119 | + zipcode: '1203', |
| 120 | + city: 'Genf', |
| 121 | + iban: '6689144926855958782', |
| 122 | + rcc: 'A123456' |
| 123 | + }, |
| 124 | + therapist: { |
| 125 | + street: 'Rue de Bourgogne 19', |
| 126 | + zipcode: '1203', |
| 127 | + city: 'Genf', |
| 128 | + rcc: 'A123456' |
| 129 | + }, |
| 130 | + hourly_price: 100, |
| 131 | + services: [ |
| 132 | + { code: 1200, color: '#f46d6d' }, |
| 133 | + { code: 1140, color: '#75b79e' }, |
| 134 | + { code: 1089, color: '#f8a978' }, |
| 135 | + { code: 1005, color: '#424874' } |
| 136 | + ] |
| 137 | + }, |
| 138 | + patients: [ |
| 139 | + { |
| 140 | + id: 1234567890, |
| 141 | + firstname: 'Joe', |
| 142 | + lastname: 'Doakes', |
| 143 | + birthdate: 45270000000, |
| 144 | + gender: 'man', |
| 145 | + email: 'joe.doakes@email.com', |
| 146 | + street: 'Avenue de Rheinau 8', |
| 147 | + zipcode: '1304', |
| 148 | + city: 'Werdenberg', |
| 149 | + canton: 'AG' |
| 150 | + } |
| 151 | + ] |
| 152 | + }) |
| 153 | + user.initUpdated() |
| 154 | + onAuthenticationDone() |
| 155 | + } |
105 | 156 | </script> |
106 | 157 |
|
107 | 158 | <form class="aposto-form" on:submit|preventDefault={onAuthenticate}> |
|
118 | 169 | Rejoindre Naturapeute |
119 | 170 | </span> |
120 | 171 | </a> |
121 | | - <Button title="Essayer en démo" on:click={onAuthenticationDone} disabled={$loading}> |
| 172 | + <Button title="Essayer en démo" on:click={onDemoMode} disabled={$loading}> |
122 | 173 | Essayer en démo |
123 | 174 | </Button> |
124 | 175 | <p class="demo-hint"> |
|
0 commit comments