Replace mysql2 with prisma
also I updated packages, and properly typed api input a lot of time was spent, I don't remeber what really I did x3 but everything was related to replacing mysql2 with prisma
This commit is contained in:
parent
be1e3909b6
commit
eebf25198d
39 changed files with 1081 additions and 1292 deletions
|
@ -6,24 +6,28 @@ import { ref, type Ref } from "vue";
|
|||
import { VBtn, VForm } from "vuetify/components";
|
||||
import PagedList from "~/components/pagedList.vue";
|
||||
import Snowflake from "~/utils/snowflake";
|
||||
import { client as clientType, order, orderSummary } from "~/utils/types/database";
|
||||
import OrderView from "~/components/orderView.vue";
|
||||
import EntryEditor, { type fieldDefinition } from "~/components/entryEditor.vue";
|
||||
|
||||
const route = useRoute();
|
||||
const id = route.params.id;
|
||||
|
||||
const clientRequest = await useFetch(`/api/clients/${id}`);
|
||||
const clientRequest = await useFetch(`/api/clients/${id}` as "/api/clients/:id");
|
||||
if (clientRequest.error.value) throw createError(clientRequest.error.value?.data ?? "");
|
||||
const client = clientRequest.data as Ref<clientType>;
|
||||
type Client = NonNullable<typeof clientRequest.data.value>;
|
||||
const client = clientRequest.data as Ref<Client>;
|
||||
|
||||
const clientOrdersRequest = await useFetch(`/api/clients/${id}/orders`);
|
||||
const clientOrdersRequest = await useFetch(`/api/clients/${id}/orders` as "/api/clients/:id/orders");
|
||||
if (clientOrdersRequest.error.value) throw createError(clientOrdersRequest.error.value?.data ?? "");
|
||||
const clientOrders = clientOrdersRequest.data as Ref<Array<orderSummary>>;
|
||||
type OrderSummary = NonNullable<typeof clientOrdersRequest.data.value>;
|
||||
const clientOrders = clientOrdersRequest.data as Ref<OrderSummary>;
|
||||
|
||||
type Order = Awaited<ReturnType<typeof useFetch<void, any, "/api/orders/:id", "get">>>["data"]["value"];
|
||||
|
||||
// cache
|
||||
const orders = ref<Map<string, {
|
||||
loading: boolean,
|
||||
value?: order
|
||||
value?: Order
|
||||
}>>(new Map());
|
||||
|
||||
for (const i of clientOrders.value)
|
||||
|
@ -36,7 +40,7 @@ async function loadOrder(id: string) {
|
|||
// @ts-expect-error
|
||||
entry.value = await $fetch(`/api/orders/${id}` as "/api/order/:id", {
|
||||
method: "GET",
|
||||
});
|
||||
}) as Order;
|
||||
entry.loading = false;
|
||||
}
|
||||
|
||||
|
@ -184,24 +188,24 @@ function getCreationDate() {
|
|||
>
|
||||
<template #title="i">
|
||||
<VRow>
|
||||
<VCol>{{ new Date(Number(new Snowflake(BigInt(((i.record) as orderSummary).id)).timestamp)).toLocaleDateString() }}</VCol>
|
||||
<VCol>{{ ((i.record) as orderSummary).value }} PLN</VCol>
|
||||
<VCol>{{ new Date(Number(new Snowflake(BigInt((i.record.id))).timestamp)).toLocaleDateString() }}</VCol>
|
||||
<VCol>{{ i.record.value }} PLN</VCol>
|
||||
<VCol>
|
||||
{{ ((i.record) as orderSummary).imported_products_count }}
|
||||
{{ i.record.imported_products_count }}
|
||||
products,
|
||||
{{ ((i.record) as orderSummary).work_count }}
|
||||
{{ i.record.work_count }}
|
||||
works
|
||||
</VCol>
|
||||
</VRow>
|
||||
</template>
|
||||
<template #text="i">
|
||||
<VProgressLinear
|
||||
:height="orders.get((i.record as orderSummary).id)?.loading ?? true ? undefined : 0"
|
||||
:height="orders.get(i.record.id)?.loading ?? true ? undefined : 0"
|
||||
absolute
|
||||
:progress="orders.get((i.record as orderSummary).id)?.loading ?? true"
|
||||
:indeterminate="orders.get((i.record as orderSummary).id)?.loading ?? true"
|
||||
:progress="orders.get(i.record.id)?.loading ?? true"
|
||||
:indeterminate="orders.get(i.record.id)?.loading ?? true"
|
||||
/>
|
||||
<OrderView :order="(orders.get((i.record as orderSummary).id)?.value as order | undefined)" />
|
||||
<OrderView :order="orders.get(i.record.id)?.value" />
|
||||
</template>
|
||||
</PagedList>
|
||||
</VCol>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue