Skip to content

Commit

Permalink
fixing state user error
Browse files Browse the repository at this point in the history
  • Loading branch information
maayarosama committed Jan 28, 2024
1 parent 7f1ab92 commit c94fc45
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions client/src/components/cards/vacationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,33 +163,37 @@ export default {
},
])
const couldUpdate = computed(() => {
if (props.vacation.status == 'pending') {
if (props.vacation.isUpdated && state.user.value.value.id == props.vacation.applying_user) {
return true;
if (state.user.value) {
if (props.vacation.status == 'pending') {
if (props.vacation.isUpdated && state.user.value.value.id == props.vacation.applying_user) {
return true;
}
if (!props.vacation.isUpdated && state.user.value.value.id == props.vacation.applying_user.id) {
return true;
}
return false
}
if (!props.vacation.isUpdated && state.user.value.value.id == props.vacation.applying_user.id) {
return true;
}
return false
}
return false
});
const couldApprove = computed(() => {
if (state.user.value.value.user_type === 'Admin'
|| state.user.value.value.user_type === 'Supervisor'
) {
if (props.vacation.user.id == state.user.value.value.id) {
return true;
if (state.user.value) {
if (state.user.value.value.user_type === 'Admin'
|| state.user.value.value.user_type === 'Supervisor'
) {
if (props.vacation.user.id == state.user.value.value.id) {
return true;
}
if (props.vacation.user.reporting_to.includes(state.user.value.value.id)
&& props.vacation.user.location.name === state.user.value.value.location.name) {
return true;
}
return false
}
if (props.vacation.user.reporting_to.includes(state.user.value.value.id)
&& props.vacation.user.location.name === state.user.value.value.location.name) {
return true;
}
return false
}
return false
});
Expand Down

0 comments on commit c94fc45

Please sign in to comment.