Фикс отображения данных при обновлении страницы

This commit is contained in:
megavrilinvv
2023-08-15 17:14:13 +03:00
parent 48f43a0770
commit d0ff2da700
4 changed files with 31 additions and 26 deletions

View File

@@ -257,15 +257,18 @@ const getters = {
getContactsData(state) {
let phones =
state.medicalCard?.person?.contacts
?.filter((el) => el.kind === "PHONE")
?.map((el) => ({ ...el })) || [];
?.filter((el) => el.category === "PHONE")
?.map((el) => {
el.value = el.value.slice(1);
return { ...el };
}) || [];
let emails =
state.medicalCard?.person?.contacts
?.filter((el) => el.kind === "EMAIL")
?.filter((el) => el.category === "EMAIL")
?.map((el) => ({ ...el })) || [];
let networks =
state.medicalCard?.person?.contacts
?.filter((el) => el.kind !== "PHONE" && el.kind !== "EMAIL")
?.filter((el) => el.category !== "PHONE" && el.category !== "EMAIL")
?.map((el) => ({ ...el })) || [];
return {
phones,
@@ -454,24 +457,23 @@ const actions = {
});
return this.getMedicalCardData(id);
},
getMedicalCardData({ state, commit }, id) {
if (state?.personId === id) return;
fetchWrapper.get(`medical_cards/person/${id}`).then((data) => {
if (!data) {
return this.createMedicalCard(id);
}
state.personId = id;
commit("setMedicalCard", data);
commit("setBasicData");
commit("setContactsData");
commit("setDocumentsData");
commit("setAllergiesData");
commit("setConfidantData");
commit("setHealthStateData");
commit("setEventsPersonData", data?.person?.id);
});
getMedicalCardData({ commit }) {
fetchWrapper
.get(`medical_cards/person/${localStorage.getItem("medicalId")}`)
.then((data) => {
if (!data) {
return this.createMedicalCard(localStorage.getItem("medicalId"));
}
commit("setMedicalCard", data);
commit("setBasicData");
commit("setContactsData");
commit("setDocumentsData");
commit("setAllergiesData");
commit("setConfidantData");
commit("setHealthStateData");
commit("setEventsPersonData", data?.person?.id);
});
},
getPersonsFiltredList() {
return fetchWrapper
.get(