Skip to content

Commit

Permalink
Merge pull request #117 from it-at-m/feature-zms-3133-exclusive-location
Browse files Browse the repository at this point in the history
Feature zms 3133 exclusive location
  • Loading branch information
manjencic authored Nov 21, 2024
2 parents 005b0aa + fba7d17 commit 5bac3c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 18 additions & 4 deletions frontend/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ export default {
return new Promise((resolve) => {
store.dispatch('API/fetchServicesAndProviders', { serviceId: preselectedService, locationId: preselectedProvider })
.then(data => {
store.commit('setProviders', data.offices)
let providers = data.offices
const exclusiveProviders = data.offices.filter(office => {
return office.id === preselectedProvider && ! office.showAlternativeLocations
})

if (exclusiveProviders.length) {
providers = exclusiveProviders
}
store.commit('setProviders', providers)

let requests = data.services.map(service => {
service.providers = []
Expand All @@ -47,9 +55,15 @@ export default {
data.relations.forEach(relation => {
if (relation.serviceId === service.id) {
service.minSlots[relation.officeId] = relation.slots
const foundProvider = data.offices.filter(office => {
const foundProviders = providers.filter(office => {
return office.id === relation.officeId
})[0]
})

if (foundProviders.length == 0) {
return
}

const foundProvider = foundProviders[0]

foundProvider.index = index
index++
Expand Down Expand Up @@ -133,12 +147,12 @@ export default {
})
},
setAppointmentFromResponse (store, appointmentData) {
store.commit('selectProviderWithId', appointmentData.officeId)
store.commit('selectServiceWithId', {
id: appointmentData.serviceId,
count: appointmentData.serviceCount,
subServiceCounts: appointmentData.subRequestCounts
})
store.commit('selectProviderWithId', appointmentData.officeId)

const customer = {
name: appointmentData.familyName,
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export default {
service.subServiceCounts = subServiceCountsById
}

if (state.preselectedProvider && ! state.preselectedProvider.showAlternativeLocations) {
service.providers = [state.preselectedProvider]
}

this.commit('data/setService', { service: service, provider: state.preselectedProvider })
}
})
Expand Down

0 comments on commit 5bac3c6

Please sign in to comment.