Skip to content

Commit

Permalink
Merge branch 'dev' into feature/ZMS-1441_telefonnummer_feld_config
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAFink authored Oct 11, 2023
2 parents 44e5c7a + a3e27d8 commit d5f851b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 17 deletions.
68 changes: 59 additions & 9 deletions frontend/__tests__/store/modules/formData/mutations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('Form data mutations', () => {
expect(state.service).toBeNull()
})

it('setService sets service in store', async () => {
it('setService sets service with subservices in store', async () => {
const state = {
service: {
id: 1,
Expand All @@ -154,30 +154,30 @@ describe('Form data mutations', () => {
count: 2,
combinable: [
1,
2,
3
2
],
subServiceCounts: {
2: 1
2: 1,
3: 1
}
})

expect(state.appointmentCounts).toStrictEqual({
1: 2,
2: 1,
3: 0
3: 1
})
expect(state.appointmentCount).toBe(2)
expect(state.service).toStrictEqual({
id: 1,
name: 'Service 1',
count: 2,
combinable: [
2,
3
2
],
subServiceCounts: {
2: 1
2: 1,
3: 1
},
subServices: [
{
Expand All @@ -186,12 +186,62 @@ describe('Form data mutations', () => {
},
{
id: 3,
count: 0
count: 1
}
]
})
})

it('setService sets service withouth subservices in store', async () => {
const state = {
service: {
id: 1,
name: 'Service',
maxQuantity: 3,
combinable: [
2,
3
]
},
appointment: {
authKey: 'aaa',
processId: 'bbb'
},
appointmentCounts: {
1: 3
},
appointmentCount: 3
}

mutations.setService(state, {
id: 1,
name: 'Service 1',
count: 2,
combinable: [
1,
2,
3
],
subServiceCounts: {}
})

expect(state.appointmentCounts).toStrictEqual({
1: 2
})
expect(state.appointmentCount).toBe(2)
expect(state.service).toStrictEqual({
id: 1,
name: 'Service 1',
count: 2,
combinable: [
2,
3
],
subServiceCounts: {},
subServices: []
})
})

it('setAppointment sets appointment in store', async () => {
state.appointment = {
authKey: 'aaa',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/CustomerInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<v-btn id="customer-submit-button" class="button-next" elevation="2" depressed color="primary"
@click="saveCustomer()">
<span class="desktop">{{ $t('nextToReservation') }}</span>
<span class="mobile">{{ $t('finishReservation') }}</span>
<span class="mobile">{{ $t('next') }}</span>
</v-btn>
</div>
</template>
Expand Down
22 changes: 15 additions & 7 deletions frontend/src/store/modules/formData/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,22 @@ export default {
}

if (! service.subServices) {
service.subServices = combinable.map((subServiceId) => {
return {
id: subServiceId,
count: service.subServiceCounts && service.subServiceCounts[subServiceId]
? service.subServiceCounts[subServiceId]
: 0
if (service.subServiceCounts) {
service.subServices = []
for (const [subServiceId, subServiceCount] of Object.entries(service.subServiceCounts)) {
service.subServices.push({
id: parseInt(subServiceId),
count: subServiceCount
})
}
})
} else {
service.subServices = combinable.map((subServiceId) => {
return {
id: subServiceId,
count: 0
}
})
}
}

service.subServices.forEach((service) => {
Expand Down

0 comments on commit d5f851b

Please sign in to comment.