Skip to content

Commit 9764c04

Browse files
committed
Add demo user
1 parent 4a01479 commit 9764c04

File tree

2 files changed

+64
-14
lines changed

2 files changed

+64
-14
lines changed

src/components/AuthenticationForm/AuthenticationForm.svelte

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
const dispatch = createEventDispatcher()
3434
3535
function saveAuthenticatedUser(body) {
36-
3736
$user.naturapeuteID = body.id
3837
3938
$user.author.email = body.email
@@ -43,6 +42,7 @@
4342
$user.therapist.phone = body.phone
4443
4544
const office = body.offices[0]
45+
4646
if (office) {
4747
$user.author.street = office.street
4848
$user.author.city = office.city
@@ -73,14 +73,16 @@
7373
if(body.invoice_data.services) $user.preferredServices = body.invoice_data.services.map(e => ({ ...e }))
7474
$patients = body.patients.map(e => ({ ...e }))
7575
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+
}
8486
}
8587
8688
function onAuthenticate() {
@@ -102,6 +104,55 @@
102104
103105
dispatch('failed')
104106
}
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+
}
105156
</script>
106157

107158
<form class="aposto-form" on:submit|preventDefault={onAuthenticate}>
@@ -118,7 +169,7 @@
118169
Rejoindre Naturapeute
119170
</span>
120171
</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}>
122173
Essayer en démo
123174
</Button>
124175
<p class="demo-hint">

src/js/utils.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,12 @@ export function isPatientValid(patient) {
8080
}
8181

8282
function isEmailValid(email) {
83-
return email.match(/[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*/)
83+
return email && email.match(/[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*/)
8484
}
8585

8686
export function isIBANValid(iban) {
87-
const matches = iban.match(/^CH(\d{2})(\d{5})([A-Z0-9]{12})$/)
88-
return Boolean(matches)
89-
87+
const matches = iban.match(/^CH(\d{2})(\d{5})([A-Z0-9]{12})$/)
88+
return Boolean(matches)
9089
}
9190

9291
function isRCCValid(RCC) {

0 commit comments

Comments
 (0)