Skip to content

Commit 8e72d32

Browse files
committed
fix: view contract permissions
1 parent 5ce5d6f commit 8e72d32

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

frontend/src/components/companies/CompanyBillingInfo.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080

8181
<script setup lang="ts">
8282
import { ref, computed } from "vue";
83-
import { useAuthStore } from "@/stores/auth";
8483
import { useCompanyBillingMutation } from "@/mutations/companies";
8584
import type { Company, CompanyBillingInfo } from "@/dto/companies";
8685
import Card from "../ui/card/Card.vue";
@@ -92,6 +91,7 @@ import Button from "../ui/button/Button.vue";
9291
import BillingForm from "./BillingForm.vue";
9392
import EmptyStateCard from "../ui/EmptyStateCard.vue";
9493
import ContractDownload from "./ContractDownload.vue";
94+
import { usePermissions } from "@/composables/usePermissions";
9595
9696
interface Props {
9797
company?: Company;
@@ -122,14 +122,8 @@ const hasBillingInfo = computed(() => {
122122
const billingMutation = useCompanyBillingMutation();
123123
const { mutate: updateBilling, isLoading: isUpdating } = billingMutation;
124124
125-
const authStore = useAuthStore();
126-
const canSeeContract = computed(
127-
() =>
128-
authStore.isAuthenticated &&
129-
authStore.decoded &&
130-
((authStore.decoded as { role?: string }).role === "COORDINATOR" ||
131-
(authStore.decoded as { role?: string }).role === "ADMIN"),
132-
);
125+
const permissions = usePermissions();
126+
const canSeeContract = computed(() => permissions.isCoordinatorOrAdmin);
133127
134128
const startEditing = () => {
135129
isEditing.value = true;

frontend/src/components/tasks/TaskContract.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</div>
3737

3838
<ContractDownload
39-
v-if="entityType === 'company'"
39+
v-if="entityType === 'company' && canSeeContract"
4040
:company-id="props.entityId"
4141
/>
4242
</div>
@@ -56,6 +56,7 @@ import type {
5656
CompanyTasks,
5757
CompanyTaskContract,
5858
} from "@/dto/tasks";
59+
import { usePermissions } from "@/composables/usePermissions";
5960
6061
const props = defineProps<{
6162
entityId: string;
@@ -74,6 +75,9 @@ const hasSigned = ref(props.companyTasks?.contract?.signed ?? false);
7475
const hasReceiptSent = ref(props.companyTasks?.contract?.receiptSent ?? false);
7576
const hasPaid = ref(props.companyTasks?.contract?.paid ?? false);
7677
78+
const permissions = usePermissions();
79+
const canSeeContract = computed(() => permissions.isCoordinatorOrAdmin);
80+
7781
watch(
7882
[hasCreatedContract, hasSentContract, hasSigned, hasReceiptSent, hasPaid],
7983
() => {

0 commit comments

Comments
 (0)