{"version":3,"file":"app-1146dd7e.83952295dd6a51410d9c.bundle.js","mappings":";;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAGA;AAIA;AAFA;AAKA;AAEA;AAAA;AACA;AAVA;AAYA;;;;;;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAVA;AAYA;AACA;AACA;;;;AAGA;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAPA;;;;AASA;;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;;;;AAEA;AAMA;;;AAEA;;;;;AAEA;AAEA;;;;;;AAUA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAhBA;;;;AAmBA;;AAAA;AACA;;;AAEA;;;;;AAEA;AAEA;AAEA;AAGA;AAIA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAZA;;;;AAeA;;AAAA;AACA;;;AAEA;;;;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AACA;;AA/MA;AADA;;AACA;AAgNA;AAAA;AAhNA;;;;;;;;;;;;;;;;;;;ACFA;AACA;AAGA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAGA;AACA;AACA;AAGA;;;;AACA;AAAA;;;;AACA;AACA;;;;AACA;AAAA;;;;AACA;AAKA;;;;AACA;AAAA;;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A;;;;;AACA;;AAAA;AACA;;;;;AACA;AACA;;;;;AACA;;AAAA;AACA;;;;;AACA;AACA;;;;AACA;;AAAA;;;;;AACA;AAEA;;;;AACA;;AAAA;;;;;AACA;AAEA;;;;;AAEA;;AADA;AAEA;;;;;AACA;AAEA;;;;AACA;;AAAA;;;;;AACA;AACA;;;;AACA;;AAAA;;;;;AACA;AAEA;;;;;AACA;;AAAA;AACA;;;;;AACA;AAEA;;;;;AACA;;AAAA;AACA;;;;;AACA;AACA;;;;;AACA;;AAAA;AACA;;;;;AACA;AACA;;;;AACA;;AAAA;AACA;;;;;AACA;AAEA;;;;;AAEA;;AADA;AAEA;;;;;AACA;AACA;;;;;AACA;;AAAA;AACA;;;;;AACA;AAEA;;;;;AACA;;AAAA;AAGA;;;;;AACA;AAEA;;;;;AACA;;AAAA;AACA;;;;;AACA;AAxIA;AADA;AAKA;AAJA;AAyIA;AAAA;AAzIA;;;;;;;;;;;;;;;ACMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":["webpack://ro-dental/./src/services/authentication-service.ts","webpack://ro-dental/./src/services/data-service.ts","webpack://ro-dental/./src/services/state-actions.ts","webpack://ro-dental/./src/services/state-manager.ts","webpack://ro-dental/./src/services/state.ts"],"sourcesContent":["import { autoinject } from \"aurelia-framework\";\nimport { config } from \"../config\";\nimport moment from \"moment\";\n\n@autoinject()\nexport class AuthenticationService {\n session: ITokenObject;\n isAdministrator: boolean = false;\n\n constructor() {\n // this._stateManager = stateManager;\n\n const sessionToken = localStorage[config.tokenName] || null;\n\n if (sessionToken != null) this.session = JSON.parse(sessionToken);\n }\n\n async loginAsync(email: string, password: string) {\n let fetchUrl = `/login`;\n\n const returnedData = await fetch(fetchUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: JSON.stringify({\n email: email,\n password: password,\n }),\n });\n\n if (returnedData.status == 403) {\n return \"Inactive Subscription\";\n }\n\n try {\n const session = await returnedData.json();\n\n if (session == \"Email Not Confirmed\") {\n return \"Please Confirm Your Email Address\";\n }\n if (session == \"Account Not Found\") {\n return \"Unknown User\";\n }\n if (session == \"Name taken\") {\n return \"Name Taken\";\n }\n\n localStorage[config.tokenName] = JSON.stringify(session);\n this.session = session;\n\n const userData = await fetch(\"Users\", {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${session.token}`,\n },\n });\n try {\n const user = await userData.json();\n if (user.isAdmin) {\n this.isAdministrator = true;\n } else {\n this.isAdministrator = false;\n }\n } catch {\n return \"No User\";\n }\n\n //this._aurelia.setRoot(\"app\");\n //set the value of userAuthenticated in app.ts to true\n\n return \"Login Successful\";\n } catch (exception) {\n return this.session;\n }\n }\n\n async registerAsync(\n firstName: string,\n lastName: string,\n email: string,\n phone: string,\n password: string,\n passwordRepeat: string,\n wantsNewsletter: boolean,\n birthday: Date\n ) {\n let fetchUrl = `/register`;\n\n const returnedData = await fetch(fetchUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: JSON.stringify({\n firstName: firstName,\n lastName: lastName,\n email: email,\n phone: phone,\n password: password,\n passwordRepeat: passwordRepeat,\n wantsNewsletter: wantsNewsletter,\n birthday: birthday,\n }),\n });\n\n try {\n const data = await returnedData.json();\n return data;\n } catch (exception) {\n return this.session;\n }\n }\n\n logout() {\n // Clear from localStorage\n localStorage[config.tokenName] = null;\n\n // .. and from the session object\n this.session = null;\n\n // .. and set root to login.\n // this._aurelia.setRoot(\"login-register\");\n }\n\n sendConfirmationEmail(email: string) {\n let fetchUrl = `/verification`;\n\n fetch(fetchUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: JSON.stringify({\n email: email,\n }),\n });\n }\n\n sendPasswordResetEmail(email: string) {\n let fetchUrl = `/resetpassword`;\n\n fetch(fetchUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: JSON.stringify({\n email: email,\n }),\n });\n }\n\n async resetPassword(\n password: string,\n confirmPasssword: string,\n token: string,\n email: string\n ) {\n let fetchUrl = `/resetpassword`;\n\n const returnedData = await fetch(fetchUrl, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: JSON.stringify({\n password: password,\n passwordRepeat: confirmPasssword,\n token: token,\n email: email,\n }),\n });\n\n try {\n const data = await returnedData.json();\n return data;\n } catch (exception) {\n return this.session;\n }\n }\n\n isAuthenticated() {\n return this.session !== null;\n }\n\n static isLoggedIn(): boolean {\n let sessionToken = localStorage[config.tokenName];\n\n if (sessionToken == null || sessionToken.indexOf(\"token\") == -1)\n return false;\n\n let tokenObject = JSON.parse(sessionToken);\n\n return AuthenticationService.confirmOrInvalidate(tokenObject);\n }\n static confirmOrInvalidate(tokenObject: ITokenObject): boolean {\n if (tokenObject == null) return false;\n\n if (moment(tokenObject.expiration).diff(moment()) < 0) {\n localStorage[config.tokenName] = null;\n return false;\n }\n\n return true;\n }\n}\n\nexport interface ITokenObject {\n token: string;\n expiration: string;\n}\n","import { Patient } from \"./../pages/patient\";\nimport { BuySubscriptionDialog } from \"modals/buy-subscription\";\nimport { Appointments } from \"./../pages/appointments\";\nimport { autoinject } from \"aurelia-framework\";\nimport { AuthenticationService } from \"./authentication-service\";\nimport { IAppointment, IAppointmentRequest, ISubscription } from \"./interfaces\";\n\nenum controller {\n AppointmentTypes = \"AppointmentTypes\",\n AppointmentRequests = \"AppointmentRequests\",\n PatientAppointmentRequests = \"PatientAppointmentRequests\",\n Users = \"users\",\n CreditCards = \"creditcards\",\n Appointments = \"appointments\",\n TodaysAppointments = \"TodaysAppointments\",\n PatientAppointments = \"PatientAppointments\",\n SubscriptionTypes = \"SubscriptionTypes\",\n Subscriptions = \"Subscriptions\",\n PatientSubscriptions = \"PatientSubscriptions\",\n Patients = \"Patients\",\n ActiveSubscriptions = \"ActiveSubscriptions\",\n Services = \"Services\",\n Birthdays = \"Birthdays\",\n Transactions = \"Transactions\",\n}\n\n@autoinject()\nexport class DataService {\n _authenticationService: AuthenticationService;\n\n constructor(authenticationService: AuthenticationService) {\n this._authenticationService = authenticationService;\n }\n\n //#region User Data Service Methods\n async getUserFromServerAsync() {\n return await this.getSingleDataFromServerAsync(controller.Users, null);\n }\n async updateUserAsync(user: any) {\n return await this.updateSingleDataAsync(controller.Users, user);\n }\n //#endregion\n\n //#region Appointment Type Data Service Methods\n\n async getAppointmentTypesAsync() {\n return await this.getListDataFromServerAsync(\n controller.AppointmentTypes,\n null\n );\n }\n\n async postAppointmentRequestAsync(appointmentRequest: IAppointmentRequest) {\n return await this.postSingleDataAsync(\n controller.AppointmentRequests,\n appointmentRequest\n );\n }\n\n async deleteAppointmentRequestAsync(appointmentRequest: IAppointmentRequest) {\n return await this.deleteSingleDataFromServerAsync(\n controller.AppointmentRequests,\n appointmentRequest\n );\n }\n\n async getAppointmentRequestsAsync() {\n return await this.getListDataFromServerAsync(\n controller.AppointmentRequests,\n null\n );\n }\n\n async getPatientAppointmentRequestsAsync() {\n return await this.getListDataFromServerAsync(\n controller.PatientAppointmentRequests,\n null\n );\n }\n\n async getAppointmentsAsync() {\n return await this.getListDataFromServerAsync(controller.Appointments, null);\n }\n async getTodaysAppointmentsAsync() {\n return await this.getListDataFromServerAsync(\n controller.TodaysAppointments,\n null\n );\n }\n async getAllAppointmentsAsync() {\n return await this.getListDataFromServerAsync(\n controller.PatientAppointments,\n null\n );\n }\n async updateAppointmentAsync(appointment: IAppointment) {\n return await this.updateSingleDataAsync(\n controller.Appointments,\n appointment\n );\n }\n\n async postAppointmentAsync(appointment: IAppointment) {\n return await this.postSingleDataAsync(controller.Appointments, appointment);\n }\n\n async getSavedCreditCardsAsync() {\n return await this.getListDataFromServerAsync(controller.CreditCards, null);\n }\n async updateSavedCreditCardAsync(creditCard: any) {\n return await this.updateSingleDataAsync(controller.CreditCards, creditCard);\n }\n async removeSavedCreditCardAsync(creditCard: any) {\n return await this.deleteSingleDataFromServerAsync(\n controller.CreditCards,\n creditCard\n );\n }\n\n async getSubscriptionTypesAsync() {\n return await this.getListDataFromServerAsync(\n controller.SubscriptionTypes,\n null\n );\n }\n\n async postSubscriptionAsync(patientSubscription: any) {\n return await this.postSingleDataAsync(\n controller.PatientSubscriptions,\n patientSubscription\n );\n }\n\n async getSubscriptionAsync() {\n return await this.getSingleDataFromServerAsync(\n controller.Subscriptions,\n null\n );\n }\n\n async getPatientAsync(patientId) {\n return await this.getSingleDataFromServerAsync(\n controller.Patients,\n patientId\n );\n }\n async getPatientsAsync(searchTerm: string) {\n return await this.getListDataFromServerAsync(controller.Patients, {\n searchTerm: searchTerm,\n });\n }\n async updatePatientAsync(patient: Patient) {\n return await this.updateSingleDataAsync(controller.Patients, patient);\n }\n async getActiveSubscriptionsAsync() {\n return await this.getListDataFromServerAsync(\n controller.ActiveSubscriptions,\n null\n );\n }\n\n async getServicesAsync() {\n return await this.getListDataFromServerAsync(controller.Services, null);\n }\n\n async getClientBirthdaysAsync(num: number) {\n return await this.getListDataFromServerAsync(controller.Birthdays, {\n days: num,\n });\n }\n\n async postSubscriptionServicesAsync(subscriptionServices: any[]) {\n return await this.postSingleDataAsync(\n controller.Services,\n subscriptionServices\n );\n }\n\n async getTransactionsAsync() {\n return await this.getListDataFromServerAsync(controller.Transactions, null);\n }\n\n async getListDataFromServerAsync(\n controller: controller,\n requestParameters: any\n ) {\n let fetchUrl = `/${controller}`;\n\n if (requestParameters != null)\n fetchUrl = `${fetchUrl}${this.constructQueryString(requestParameters)}`;\n\n const returnedData = await fetch(fetchUrl, {\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${this._authenticationService.session.token}`,\n },\n });\n\n const jsonUnpackedData = await returnedData.json();\n\n return jsonUnpackedData;\n }\n\n async getSingleDataFromServerAsync(controller: controller, dataId: any) {\n let fetchUrl = \"\";\n\n if (dataId != null) fetchUrl = `/${controller}/${dataId}`;\n else fetchUrl = `/${controller}`;\n\n const returnedData = await fetch(fetchUrl, {\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${this._authenticationService.session.token}`,\n },\n });\n\n const jsonUnpackedData = await returnedData.json();\n\n return jsonUnpackedData;\n }\n\n async getPdfDataFromServerAsync(requestParameters: {\n propertyId: number;\n clientId: number;\n }) {\n let fetchUrl = `/pdf`;\n\n if (requestParameters != null)\n fetchUrl = `${fetchUrl}${this.constructQueryString(requestParameters)}`;\n\n const returnedData = await fetch(fetchUrl, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/pdf\",\n },\n });\n }\n\n async postSingleDataAsync(controller: controller, entity: any) {\n let fetchUrl = `/${controller}`;\n\n const returnedData = await fetch(fetchUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${this._authenticationService.session.token}`,\n },\n body: JSON.stringify(entity),\n });\n\n const jsonUnpackedData = await returnedData.json();\n return jsonUnpackedData;\n }\n\n async updateSingleDataAsync(controller: controller, entity: any) {\n let fetchUrl = `/${controller}`;\n\n const returnedData = await fetch(fetchUrl, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${this._authenticationService.session.token}`,\n },\n body: JSON.stringify(entity),\n });\n\n const jsonUnpackedData = await returnedData.json();\n return jsonUnpackedData;\n }\n\n async deleteSingleDataFromServerAsync(controller: controller, entity: any) {\n let fetchUrl = `/${controller}`;\n\n const returnedData = await fetch(fetchUrl, {\n method: \"DELETE\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${this._authenticationService.session.token}`,\n },\n body: JSON.stringify(entity),\n });\n }\n\n async getTemplateDataFromServerAsync(controller: controller) {\n let fetchUrl = `/${controller}`;\n\n const returnedData = await fetch(fetchUrl, {\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n Authorization: `Bearer ${this._authenticationService.session.token}`,\n },\n });\n\n const jsonUnpackedData = await returnedData.json();\n\n return jsonUnpackedData;\n }\n\n private constructQueryString(parameters) {\n var queryString = \"\";\n\n for (var prop in parameters) {\n if (parameters.hasOwnProperty(prop) && parameters[prop] != null) {\n queryString +=\n queryString == \"\"\n ? `?${prop}=${parameters[prop]}`\n : `&${prop}=${parameters[prop]}`;\n }\n }\n\n return queryString;\n }\n}\n","import { State } from \"./state\";\n\nexport const updateUser = (state: State, user: any) => {\n const newState = Object.assign({}, state);\n\n newState.user = user;\n\n return newState;\n};\n\nexport const updateAppointmentTypes = (state: State, appointmentTypes: any) => {\n const newState = Object.assign({}, state);\n\n newState.appointmentTypes = appointmentTypes;\n\n return newState;\n};\n\nexport const updateAppointmentRequests = (\n state: State,\n appointmentRequests: any\n) => {\n const newState = Object.assign({}, state);\n\n newState.appointmentRequests = appointmentRequests;\n\n return newState;\n};\n\nexport const updatePatientAppointmentRequests = (\n state: State,\n appointmentRequests: any\n) => {\n const newState = Object.assign({}, state);\n\n newState.patientAppointmentRequests = appointmentRequests;\n\n return newState;\n};\n\nexport const updateAppointments = (state: State, appointments: any) => {\n const newState = Object.assign({}, state);\n\n newState.appointments = appointments;\n\n return newState;\n};\n\nexport const updateTodaysAppointments = (state: State, appointments: any) => {\n const newState = Object.assign({}, state);\n\n newState.todaysAppointments = appointments;\n\n return newState;\n};\n\nexport const updateAllAppointments = (state: State, appointments: any) => {\n const newState = Object.assign({}, state);\n\n newState.allAppointments = appointments;\n\n return newState;\n};\n\nexport const updateCreditCards = (state: State, savedCreditCards: any) => {\n const newState = Object.assign({}, state);\n\n newState.savedCreditCards = savedCreditCards;\n\n return newState;\n};\n\nexport const updateSubscriptionTypes = (\n state: State,\n subscriptionTypes: any\n) => {\n const newState = Object.assign({}, state);\n\n newState.subscriptionTypes = subscriptionTypes;\n\n return newState;\n};\nexport const updateSubscription = (state: State, subscription: any) => {\n const newState = Object.assign({}, state);\n\n newState.subscription = subscription;\n\n return newState;\n};\n\nexport const updatePatient = (state: State, patient: any) => {\n const newState = Object.assign({}, state);\n\n newState.patient = patient;\n\n return newState;\n};\n\nexport const updatePatients = (state: State, patients: any) => {\n const newState = Object.assign({}, state);\n\n newState.patients = patients;\n\n return newState;\n};\n\nexport const updateActiveSubscriptions = (\n state: State,\n activeSubscriptions: any\n) => {\n const newState = Object.assign({}, state);\n\n newState.activeSubscriptions = activeSubscriptions;\n\n return newState;\n};\n\nexport const updateServices = (state: State, services: any) => {\n const newState = Object.assign({}, state);\n\n newState.services = services;\n\n return newState;\n};\n\nexport const updateClientBirthdays = (state: State, clientBirthdays: any) => {\n const newState = Object.assign({}, state);\n\n newState.clientBirthdays = clientBirthdays;\n\n return newState;\n};\n\nexport const updateTransactions = (state: State, transactions: any) => {\n const newState = Object.assign({}, state);\n\n newState.transactions = transactions;\n\n return newState;\n};\n\nexport const setIsAdmin = (state: State, isAdmin: boolean) => {\n const newState = Object.assign({}, state);\n\n newState.isAdmin = isAdmin;\n\n return newState;\n};\n","import { Store } from \"aurelia-store\";\nimport { State } from \"./state\";\nimport { autoinject } from \"aurelia-framework\";\nimport { DataService } from \"./data-service\";\nimport {\n setIsAdmin,\n updateActiveSubscriptions,\n updateAllAppointments,\n updateAppointmentRequests,\n updateAppointmentTypes,\n updateAppointments,\n updateClientBirthdays,\n updateCreditCards,\n updatePatient,\n updatePatientAppointmentRequests,\n updatePatients,\n updateServices,\n updateSubscription,\n updateSubscriptionTypes,\n updateTodaysAppointments,\n updateTransactions,\n updateUser,\n} from \"./state-actions\";\nimport { IAppointment, IAppointmentRequest, ISubscription } from \"./interfaces\";\n\n@autoinject()\nexport class StateManager {\n _store: Store;\n _dataService: DataService;\n\n constructor(dataService: DataService, store: Store) {\n this._dataService = dataService;\n this._store = store;\n }\n\n async setIsAdmin(bool: boolean) {\n this._store.dispatch(setIsAdmin, bool);\n }\n\n async getUserAsync() {\n const user = await this._dataService.getUserFromServerAsync();\n this._store.dispatch(updateUser, user);\n this._store.dispatch(setIsAdmin, user.isAdmin);\n return user;\n }\n async setUserNullAsync() {\n this._store.dispatch(updateUser, null);\n }\n\n async updateUserAsync(userToUpdate) {\n const user = await this._dataService.updateUserAsync(userToUpdate);\n this._store.dispatch(updateUser, user);\n }\n\n async getAppointmentTypesAsync() {\n const appointmentTypes = await this._dataService.getAppointmentTypesAsync();\n this._store.dispatch(updateAppointmentTypes, appointmentTypes);\n }\n\n async getAppointmentRequests() {\n const appointmentRequests =\n await this._dataService.getAppointmentRequestsAsync();\n this._store.dispatch(updateAppointmentRequests, appointmentRequests);\n }\n\n async deleteAppointmentRequest(appointmentRequest: IAppointmentRequest) {\n await this._dataService.deleteAppointmentRequestAsync(appointmentRequest);\n }\n\n async postAppointmentRequest(appointmentRequest: IAppointmentRequest) {\n await this._dataService.postAppointmentRequestAsync(appointmentRequest);\n }\n\n async getSavedCreditCardsAsync() {\n const creditCards = await this._dataService.getSavedCreditCardsAsync();\n this._store.dispatch(updateCreditCards, creditCards);\n }\n async updateSavedCreditCardAsync(creditCard) {\n await this._dataService.updateSavedCreditCardAsync(creditCard);\n }\n async removeSavedCreditCardAsync(creditCard) {\n await this._dataService.removeSavedCreditCardAsync(creditCard);\n }\n\n async getPatientAppointmentRequests() {\n const appointmentRequests =\n await this._dataService.getPatientAppointmentRequestsAsync();\n this._store.dispatch(updatePatientAppointmentRequests, appointmentRequests);\n }\n\n async getAppointments() {\n const appointments = await this._dataService.getAppointmentsAsync();\n this._store.dispatch(updateAppointments, appointments);\n }\n\n async getTodaysAppointments() {\n const appointments = await this._dataService.getTodaysAppointmentsAsync();\n this._store.dispatch(updateTodaysAppointments, appointments);\n }\n async getAllAppointmentsAsync() {\n const appointments = await this._dataService.getAllAppointmentsAsync();\n this._store.dispatch(updateAllAppointments, appointments);\n }\n async updateAppointmentAsync(appointment: IAppointment) {\n await this._dataService.updateAppointmentAsync(appointment);\n }\n\n async postAppointmentAsync(appointment: IAppointment) {\n await this._dataService.postAppointmentAsync(appointment);\n }\n\n async getSubscriptionTypesAsync() {\n const subscriptionTypes =\n await this._dataService.getSubscriptionTypesAsync();\n this._store.dispatch(updateSubscriptionTypes, subscriptionTypes);\n }\n\n async postSubscriptionAsync(patientSubscription: any) {\n await this._dataService.postSubscriptionAsync(patientSubscription);\n }\n async postSubscriptionServicesAsync(subscriptionServices: any[]) {\n await this._dataService.postSubscriptionServicesAsync(subscriptionServices);\n }\n\n async getSubscriptionAsync() {\n const subscription = await this._dataService.getSubscriptionAsync();\n this._store.dispatch(updateSubscription, subscription);\n }\n\n async getPatientAsync(patientId) {\n const patient = await this._dataService.getPatientAsync(patientId);\n this._store.dispatch(updatePatient, patient);\n }\n async getPatientsAsync(searchTerm) {\n const patients = await this._dataService.getPatientsAsync(searchTerm);\n this._store.dispatch(updatePatients, patients);\n }\n async updatePatientAsync(patient) {\n await this._dataService.updatePatientAsync(patient);\n this._store.dispatch(updatePatient, patient);\n }\n\n async getActiveSubscriptionsAsync() {\n const activeSubscriptions =\n await this._dataService.getActiveSubscriptionsAsync();\n this._store.dispatch(updateActiveSubscriptions, activeSubscriptions);\n }\n async getServicesAsync() {\n const services = await this._dataService.getServicesAsync();\n this._store.dispatch(updateServices, services);\n }\n\n async getClientBirthdaysAsync(num: number) {\n const clientBirthdays = await this._dataService.getClientBirthdaysAsync(\n num\n );\n this._store.dispatch(updateClientBirthdays, clientBirthdays);\n }\n\n async getTransactionsAsync() {\n const transactions = await this._dataService.getTransactionsAsync();\n this._store.dispatch(updateTransactions, transactions);\n }\n}\n","import { PatientAppointments } from \"../pages/all-appointments\";\nimport { ISubscription } from \"aurelia-router\";\nimport {\n IAppointment,\n IAppointmentRequest,\n IAppointmentType,\n ICreditCard,\n IService,\n ITransaction,\n IUser,\n} from \"./interfaces\";\n\nexport interface State {\n user: IUser;\n appointmentTypes: IAppointmentType[];\n appointmentRequests: IAppointmentRequest[];\n patientAppointmentRequests: IAppointmentRequest[];\n savedCreditCards: any[];\n appointments: IAppointment[];\n subscriptionTypes: any[];\n subscription: ISubscription;\n patient: IUser;\n patients: IUser[];\n activeSubscriptions: ISubscription[];\n todaysAppointments: IAppointment[];\n allAppointments: IAppointment[];\n services: IService[];\n clientBirthdays: IUser[];\n transactions: ITransaction[];\n isAdmin: boolean;\n}\n\nexport const initialState: State = {\n user: null,\n appointmentTypes: [],\n appointmentRequests: [],\n savedCreditCards: [],\n patientAppointmentRequests: [],\n appointments: [],\n subscriptionTypes: [],\n subscription: null,\n patient: null,\n patients: [],\n activeSubscriptions: [],\n todaysAppointments: [],\n allAppointments: [],\n services: [],\n clientBirthdays: [],\n isAdmin: null,\n transactions: [],\n};\n"],"names":[],"sourceRoot":""}