fixing route

This commit is contained in:
Warunee Tamkoo 2024-08-13 09:45:59 +07:00
parent 1333e53c63
commit d0ac01b92e
5 changed files with 32 additions and 22 deletions

View file

@ -22,7 +22,7 @@ const retireDate = ref<Date>();
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
const isEmployee = defineModel("isEmployee", { type: String });
const empType = ref<string>("");
const empType = ref<string>("officer");
/** props*/
const props = defineProps({
id: {
@ -95,7 +95,12 @@ function calculateAge(birthDate: Date | null) {
async function fetchInformation(id: string) {
showLoader();
await http
.get(config.API.orgProfileById(id, empType.value))
.get(
config.API.orgProfileById(
id,
`${empType.value == "employee" ? `-${empType.value}` : ""}`
)
)
.then((res) => {
const data = res.data.result;
imformation.prefix = data.prefix ? data.prefix : "-";
@ -128,7 +133,12 @@ async function fetchInformation(id: string) {
async function fetchProfileGov(id: string) {
showLoader();
await http
.get(config.API.profileNewGovernmentById(id, empType.value))
.get(
config.API.profileNewGovernmentById(
id,
`${empType.value == "employee" ? `-${empType.value}` : ""}`
)
)
.then((res) => {
const data = res.data.result;
goverment.oc = data.org !== "" ? data.org : "-";
@ -155,7 +165,7 @@ async function fetchProfileGov(id: string) {
}
function redirecToRegistry() {
router.push(`/registry-officer${empType.value}/${props.id}`);
router.push(`/registry-${empType.value}/${props.id}`);
modal.value = false;
}
@ -168,8 +178,8 @@ watch(
empType.value =
route.name === "appoint-employee-detail" ||
isEmployee.value == "EMPLOYEE"
? "-employee"
: "";
? "employee"
: "officer";
fetchInformation(props.id);
fetchProfileGov(props.id);