global rework patient info

This commit is contained in:
dderbentsov
2023-11-02 01:19:05 +03:00
parent 35e8740f04
commit 92b7bd6d01
21 changed files with 562 additions and 109 deletions

View File

@@ -0,0 +1,74 @@
import { fetchWrapper } from "@/shared/fetchWrapper";
const state = () => ({
firstName: "",
lastName: "",
patronymic: "",
birthDate: "",
gender: "",
marks: [],
addresses: [
{
category: "fact",
full_address: "г.Рязань, ул. Новикова-Прибоя, д.43/1, кв.2",
},
{
category: "registration",
full_address: "г.Санкт-Себастьянг, ул. Шоссе Энтузиастов, д.243, кв.4",
},
],
contacts: [
{ category: "email", value: "dol@yandex.ru" },
{ category: "phone", value: "+79586541252" },
],
});
const getters = {
PERSON(state) {
return {
firstName: state.firstName,
lastName: state.lastName,
patronymic: state.patronymic,
birthDate: state.birthDate,
gender: state.gender,
marks: ["hard", "rich", "allergic", "infected", "ban"],
};
},
ADDRESSES(state) {
return state.addresses;
},
CONTACTS(state) {
return state.contacts;
},
};
const actions = {
GET_PERSON({ commit }, id) {
fetchWrapper
.get(`persons/${id}`)
.then((res) => {
commit("SET_PERSON", res);
})
.catch((e) => alert(e));
},
UPDATE_PERSON(context, { obj, id }) {
fetchWrapper.patch(`persons/${id}`, obj);
},
};
const mutations = {
SET_PERSON(state, payload) {
state.firstName = payload.first_name;
state.lastName = payload.last_name;
state.patronymic = payload.patronymic;
state.birthDate = payload.birth_date;
state.gender = payload.gender;
},
};
export default {
state,
getters,
actions,
mutations,
};