From 10dad92a5b0fcbe70dcc922e32d12b706c46646d Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Sat, 28 Jun 2025 14:52:30 +0200 Subject: [PATCH] Update types --- ui/src/components/RowActionMenu.tsx | 2 +- ui/src/components/devis/ViewDevisModal.tsx | 2 +- ui/src/hooks/devis.ts | 2 +- ui/src/pages/devis.tsx | 2 +- ui/src/providers/ChatProvider.tsx | 3 +- ui/src/types/database.types.ts | 36 +++++++--- ui/src/types/db.ts | 80 ---------------------- ui/src/utils/helpers.ts | 2 +- 8 files changed, 33 insertions(+), 96 deletions(-) delete mode 100644 ui/src/types/db.ts diff --git a/ui/src/components/RowActionMenu.tsx b/ui/src/components/RowActionMenu.tsx index 071b631..07aafe6 100644 --- a/ui/src/components/RowActionMenu.tsx +++ b/ui/src/components/RowActionMenu.tsx @@ -1,7 +1,7 @@ import React from "react"; import { DeleteDevisModalButton } from "@ui/components/devis/DeleteDevisModal"; import { ViewDevisModalButton } from "@ui/components/devis/ViewDevisModal"; -import { Database } from "@ui/types/db"; +import { Database } from "@ui/types/database.types"; import { Button } from "@ui/ui-library/button"; import { Download } from "lucide-react"; diff --git a/ui/src/components/devis/ViewDevisModal.tsx b/ui/src/components/devis/ViewDevisModal.tsx index f7b49e0..73f6a96 100644 --- a/ui/src/components/devis/ViewDevisModal.tsx +++ b/ui/src/components/devis/ViewDevisModal.tsx @@ -1,4 +1,4 @@ -import { Database } from "@ui/types/db"; +import { Database } from "@ui/types/database.types"; import { Button } from "@ui/ui-library/button"; import { DialogBody, DialogFooter } from "@ui/ui-library/dialog"; diff --git a/ui/src/hooks/devis.ts b/ui/src/hooks/devis.ts index 632229c..908d247 100644 --- a/ui/src/hooks/devis.ts +++ b/ui/src/hooks/devis.ts @@ -1,5 +1,5 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { Database } from "@ui/types/db"; +import { Database } from "@ui/types/database.types"; import { supabase } from "./auth"; import { useSession } from "@ui/contexts/SessionContext"; diff --git a/ui/src/pages/devis.tsx b/ui/src/pages/devis.tsx index ba8e0e5..e3af693 100644 --- a/ui/src/pages/devis.tsx +++ b/ui/src/pages/devis.tsx @@ -13,7 +13,7 @@ import { useUpdateDevis, } from "@ui/hooks/devis"; import { useState } from "react"; -import { Database } from "@ui/types/db"; +import { Database } from "@ui/types/database.types"; import { CalendarDate, DateValue } from "@internationalized/date"; import { RowActionMenu } from "@ui/components/RowActionMenu"; import { CustomLoadingOverlay } from "@ui/components/CustomLoadingOverlay"; diff --git a/ui/src/providers/ChatProvider.tsx b/ui/src/providers/ChatProvider.tsx index c97e894..c9ed980 100644 --- a/ui/src/providers/ChatProvider.tsx +++ b/ui/src/providers/ChatProvider.tsx @@ -15,8 +15,7 @@ export default function ChatProvider({ tokenOrProvider: user.streamToken, userData: { id: user.id, - // @ts-expect-error - name is not defined in the user type - name: user.name || "", + name: user.name ?? "", }, }); diff --git a/ui/src/types/database.types.ts b/ui/src/types/database.types.ts index d88e4f3..11d1144 100644 --- a/ui/src/types/database.types.ts +++ b/ui/src/types/database.types.ts @@ -63,30 +63,48 @@ export type Database = { } Relationships: [] } + feedbacks: { + Row: { + created_at: string | null + fd_type: string + id: number + message: string + user_id: string + } + Insert: { + created_at?: string | null + fd_type: string + id?: number + message: string + user_id: string + } + Update: { + created_at?: string | null + fd_type?: string + id?: number + message?: string + user_id?: string + } + Relationships: [] + } profiles: { Row: { avatar_url: string | null email: string | null - full_name: string | null id: string - updated_at: string | null - website: string | null + name: string | null } Insert: { avatar_url?: string | null email?: string | null - full_name?: string | null id: string - updated_at?: string | null - website?: string | null + name?: string | null } Update: { avatar_url?: string | null email?: string | null - full_name?: string | null id?: string - updated_at?: string | null - website?: string | null + name?: string | null } Relationships: [] } diff --git a/ui/src/types/db.ts b/ui/src/types/db.ts deleted file mode 100644 index 3c754c5..0000000 --- a/ui/src/types/db.ts +++ /dev/null @@ -1,80 +0,0 @@ -export type Json = - | string - | number - | boolean - | null - | { [key: string]: Json | undefined } - | Json[]; - -export type Database = { - public: { - Tables: { - devis: { - Row: { - client_email: string; - created_at: string; - date: string; - due_date: string; - id: string; - items: Json; - notes: string | null; - number: string; - status: Database["public"]["Enums"]["devis_status"]; - subtotal: number; - tax: number; - terms: string | null; - total: number; - updated_at: string; - user_id: string; - }; - Insert: { - client_email: string; - created_at?: string; - date: string; - due_date: string; - id?: string; - items?: Json; - notes?: string | null; - number: string; - status?: Database["public"]["Enums"]["devis_status"]; - subtotal: number; - tax: number; - terms?: string | null; - total: number; - updated_at?: string; - user_id: string; - }; - Update: { - client_email?: string; - created_at?: string; - date?: string; - due_date?: string; - id?: string; - items?: Json; - notes?: string | null; - number?: string; - status?: Database["public"]["Enums"]["devis_status"]; - subtotal?: number; - tax?: number; - terms?: string | null; - total?: number; - updated_at?: string; - user_id?: string; - }; - Relationships: []; - }; - }; - Views: { - [_ in never]: never; - }; - Functions: { - [_ in never]: never; - }; - Enums: { - devis_status: "draft" | "sent" | "accepted" | "rejected" | "expired"; - }; - CompositeTypes: { - [_ in never]: never; - }; - }; -}; diff --git a/ui/src/utils/helpers.ts b/ui/src/utils/helpers.ts index c487fee..030d501 100644 --- a/ui/src/utils/helpers.ts +++ b/ui/src/utils/helpers.ts @@ -1,4 +1,4 @@ -import { Database } from "@ui/types/db"; +import { Database } from "@ui/types/database.types"; import jsPDF from "jspdf"; export const calculateTax = (amount: number, taxRate: number) => {