Skip to content

Commit

Permalink
Adding vacation balance condition
Browse files Browse the repository at this point in the history
  • Loading branch information
maayarosama committed Jan 28, 2024
1 parent c0eb4ab commit 58f3c3d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 0 additions & 2 deletions client/src/components/cards/vacationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ export default {
'update-vacation': (item: any) => item,
'delete-vacation': () => true,
'status-vacation': (item: string) => item,
},
setup(props, ctx) {
Expand Down
28 changes: 24 additions & 4 deletions client/src/views/ProfileView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<v-row class="ma-5">
<v-col cols="12" sm="12" md="3" class="pa-2 border rounded ma-2 align-self-start">
<div class="pa-5">
<profileImage :user="user.state.value"/>
<profileImage :user="user.state.value" />
<div class=" text-center">
<h5 clas=" text-h5 font-weight-bold ">
{{ user.state.value?.full_name }}
Expand All @@ -15,7 +15,7 @@
<v-col cols="12" sm="12" md="8" class="pa-2 border rounded position-relative ma-2">
<div>
<personalInformation :user="user.state.value" />
<vacationBalance :balance="balance.state.value" />
<vacationBalance :balance="balance.state.value" v-if="showBalance" />
</div>
</v-col>
</v-row>
Expand All @@ -27,11 +27,11 @@ import { computed, defineComponent, ref } from 'vue'
import vacationBalance from '@/components/vacationBalance.vue'
import personalInformation from '@/components/personalInformation.vue'
import { $api } from '@/clients'
import { onMounted } from 'vue'
import type { Api } from '@/types'
import { useRoute } from 'vue-router';
import { useAsyncState } from '@vueuse/core';
import profileImage from "@/components/profileImage.vue";
import { useState } from '@/store'
export default defineComponent({
components: {
vacationBalance,
Expand All @@ -41,6 +41,7 @@ export default defineComponent({
setup() {
const $route = useRoute();
const state = useState()
const user = useAsyncState($route.query.id ? $api.users.getuser(Number($route.query.id)) : $api.myprofile.getUser(), [], {
onSuccess(data) {
balance.execute(undefined, data.id)
Expand All @@ -55,10 +56,29 @@ export default defineComponent({
{ immediate: false }
)
const showBalance = computed(() => {
if (state.user.value) {
if (user.state.value.id === state.user.value.value.id) {
return true;
}
else if (state.user.value.value.user_type === 'Admin') {
if (user.state.value.reporting_to) {
if (user.state.value.reporting_to.includes(state.user.value.value.id)
&& user.state.value.location.name === state.user.value.value.location.name) {
return true;
}
}
return false
}
}
return false
});
return {
user,
state,
balance,
showBalance,
vacationBalance,
personalInformation,
profileImage,
Expand Down

0 comments on commit 58f3c3d

Please sign in to comment.