diff --git a/frontend/__tests__/store/modules/formData/mutations.spec.js b/frontend/__tests__/store/modules/formData/mutations.spec.js index 9130ef5..d274b3a 100644 --- a/frontend/__tests__/store/modules/formData/mutations.spec.js +++ b/frontend/__tests__/store/modules/formData/mutations.spec.js @@ -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, @@ -154,18 +154,18 @@ 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({ @@ -173,11 +173,11 @@ describe('Form data mutations', () => { name: 'Service 1', count: 2, combinable: [ - 2, - 3 + 2 ], subServiceCounts: { - 2: 1 + 2: 1, + 3: 1 }, subServices: [ { @@ -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', diff --git a/frontend/src/components/CustomerInfo.vue b/frontend/src/components/CustomerInfo.vue index 663863e..a36a40d 100644 --- a/frontend/src/components/CustomerInfo.vue +++ b/frontend/src/components/CustomerInfo.vue @@ -30,7 +30,7 @@ {{ $t('nextToReservation') }} - {{ $t('finishReservation') }} + {{ $t('next') }} diff --git a/frontend/src/store/modules/formData/mutations.js b/frontend/src/store/modules/formData/mutations.js index 386bf36..7a16914 100644 --- a/frontend/src/store/modules/formData/mutations.js +++ b/frontend/src/store/modules/formData/mutations.js @@ -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) => {