Skip to content

Commit

Permalink
refactor(dashboard/invoice): fix type-check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeNamedRobin committed Aug 14, 2024
1 parent 7b10d4c commit c6d5e04
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/FindUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const filterUsers = (e: any) => {
}
};
const defaultUser = ref([]);
const defaultUser: Ref<Array<BaseUserResponse & { fullName: string }>> = ref([]);
onBeforeMount(() => {
if (props.modelValue) {
Expand Down
8 changes: 5 additions & 3 deletions apps/dashboard/src/components/InputSpan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
v-model="internalValue as number"
:disabled="disabled"/>
<InputSwitch v-if="type === 'switch'"
v-model="internalValue"
v-model="internalValue as boolean"
:disabled="disabled"/>
</span>
<div class="flex justify-content-end">
Expand All @@ -56,7 +56,7 @@ const props = defineProps({
required: true
},
value: {
type: [String, Number],
type: [String, Number, Boolean],
},
attributes: {
type: Object as PropType<any>,
Expand Down Expand Up @@ -92,14 +92,16 @@ const emit = defineEmits(['update:value']);
const stringInputs = ['text', 'textarea'];
const numberInputs = ['currency', 'number'];
const booleanInputs = ['switch'];
const initialValue = () => {
if (stringInputs.includes(props.type)) return '';
if (numberInputs.includes(props.type)) return 0;
if (booleanInputs.includes(props.type)) return false;
return '';
};
const internalValue: Ref<string | number | undefined> = ref(initialValue());
const internalValue: Ref<string | number | undefined | boolean> = ref(initialValue());
onMounted(() => {
internalValue.value = props.value ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,12 @@
</Column>
<Column :header="$t('c_invoiceInfo.Actions')" style="width: 10%">
<template #body="slotProps" >
<div class="flex flex-row ">
<Button
type="button"
icon="pi pi-file-edit"
class="p-button-rounded p-button-text p-button-plain"
@click="() => handleCreateInvoice(slotProps.data.user)"
/>
<Button
type="button"
icon="pi pi-external-link"
class="p-button-rounded p-button-text p-button-plain"
@click="() => console.log(slotProps.data.user.id)"
/>
</div>
</template>
</Column>

Expand Down Expand Up @@ -91,10 +83,16 @@ const getAllUsers = async (skip: number) => {
}
};
// Typing is absolutely fucked in the api but it works
const getInvoiceableBalances = async (skip: number) => {
//@ts-ignore-next-line
const response = await apiService.balance.getAllBalance(undefined, undefined, -1, undefined, undefined, undefined, ["INVOICE"], undefined, undefined, false, Number.MAX_SAFE_INTEGER, skip);
//@ts-ignore-next-line
balances.value.push(...response.data.records);
//@ts-ignore-next-line
if (response.data._pagination.count > response.data.records.length) {
//@ts-ignore-next-line
await getInvoiceableBalances(skip + response.data.records.length);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<span class="text-gray-700">{{ `Creating invoice for ${form.model.for.value.value.firstName} ${form.model.for.value.value.lastName} as ` }}</span>
<span class="text-gray-700">{{
`Creating invoice for ${form.model.for.value.value.firstName} ${form.model.for.value.value.lastName} as `
}}</span>
<UserLink :user="form.model.by.value.value"/>
<div class="flex flex-column justify-content-between gap-2">
<InputSpan :label="$t('c_invoiceInfo.Description')"
Expand Down Expand Up @@ -68,16 +70,16 @@
<script setup lang="ts">
import { useI18n } from "vue-i18n";
import type { PropType } from "vue";
import {type Form, setSubmit} from "@/utils/formUtils";
import { type Form, setSubmit } from "@/utils/formUtils";
import * as yup from "yup";
import { createInvoiceSchema } from "@/utils/validation-schema";
import UserLink from "@/components/UserLink.vue";
import InputSpan from "@/components/InputSpan.vue";
import {useInvoiceStore} from "@/stores/invoice.store";
import type {CreateInvoiceRequest, InvoiceResponse} from "@sudosos/sudosos-client";
import {handleError} from "@/utils/errorUtils";
import {useToast} from "primevue/usetoast";
import {useRouter} from "vue-router";
import { useInvoiceStore } from "@/stores/invoice.store";
import type { CreateInvoiceRequest, InvoiceResponse } from "@sudosos/sudosos-client";
import { handleError } from "@/utils/errorUtils";
import { useToast } from "primevue/usetoast";
import { useRouter } from "vue-router";
const props = defineProps({
form: {
Expand Down

0 comments on commit c6d5e04

Please sign in to comment.