diff --git a/api/src/database.types.ts b/api/src/database.types.ts index 8398ee5..8d1f8cc 100644 --- a/api/src/database.types.ts +++ b/api/src/database.types.ts @@ -151,6 +151,13 @@ export type Database = { referencedRelation: "user_tablos" referencedColumns: ["id"] }, + { + foreignKeyName: "fk_tablo_access_user_id_from_profiles" + columns: ["user_id"] + isOneToOne: false + referencedRelation: "profiles" + referencedColumns: ["id"] + }, ] } tablo_invites: { @@ -244,7 +251,15 @@ export type Database = { status: string | null user_id: string | null } - Relationships: [] + Relationships: [ + { + foreignKeyName: "fk_tablo_access_user_id_from_profiles" + columns: ["user_id"] + isOneToOne: false + referencedRelation: "profiles" + referencedColumns: ["id"] + }, + ] } } Functions: { diff --git a/ui/src/App.tsx b/ui/src/App.tsx index cc1c1c4..9fd87e4 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -17,6 +17,7 @@ import { PlanningPage } from "./pages/planning"; import { ChantiersPage } from "./pages/chantiers"; import { ChatPage } from "./pages/chat"; import { FeedbackPage } from "./pages/feedback"; +import { SupportPage } from "./pages/support"; import { AllCommunityModule, ModuleRegistry } from "ag-grid-community"; import ChatProvider from "./providers/ChatProvider"; import { UserStoreProvider } from "./providers/UserStoreProvider"; @@ -106,6 +107,14 @@ export const App = () => { } /> + + + + } + /> diff --git a/ui/src/hooks/support.ts b/ui/src/hooks/support.ts new file mode 100644 index 0000000..0b6acda --- /dev/null +++ b/ui/src/hooks/support.ts @@ -0,0 +1,41 @@ +import { useMutation } from "@tanstack/react-query"; +import { supabase } from "./auth"; +import { useUser } from "@ui/providers/UserStoreProvider"; + +export interface SupportTicketData { + issue_type: + | "bug" + | "performance" + | "security" + | "feature_request" + | "account" + | "other"; + severity: "low" | "medium" | "high" | "critical"; + title: string; + description: string; +} + +// Create new support ticket +export const useCreateSupportTicket = () => { + const user = useUser(); + const { mutate, isSuccess, isPending } = useMutation({ + mutationFn: async ({ + issue_type, + severity, + title, + description, + }: SupportTicketData) => { + const { error } = await supabase.from("support_tickets").insert({ + issue_type, + severity, + title, + description, + user_id: user?.id ?? "", + }); + if (error) throw error; + }, + onSuccess: () => {}, + }); + + return { createSupportTicket: mutate, isSuccess, isPending }; +}; diff --git a/ui/src/pages/support.tsx b/ui/src/pages/support.tsx new file mode 100644 index 0000000..be85c93 --- /dev/null +++ b/ui/src/pages/support.tsx @@ -0,0 +1,207 @@ +import React, { useState } from "react"; +import { Button } from "@ui/ui-library/button"; +import { Form } from "@ui/ui-library/form"; +import { TextField, Label, TextArea, Description } from "@ui/ui-library/field"; +import { Text } from "@ui/ui-library/text"; +import { Separator } from "react-aria-components"; +import { SendIcon, ArrowLeftIcon } from "lucide-react"; +import { twMerge } from "tailwind-merge"; +import { useNavigate } from "react-router-dom"; +import { useCreateSupportTicket, SupportTicketData } from "@ui/hooks/support"; + +export function SupportPage() { + const navigate = useNavigate(); + const [formData, setFormData] = useState({ + issue_type: "bug", + severity: "medium", + title: "", + description: "", + }); + + const { createSupportTicket, isSuccess, isPending } = + useCreateSupportTicket(); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + createSupportTicket(formData); + }; + + const handleInputChange = (field: keyof SupportTicketData, value: string) => { + setFormData((prev) => ({ ...prev, [field]: value })); + }; + + return ( +
+ {/* Header */} +
+
+ +
+ Support technique + + Signalez un problème ou demandez de l'aide + +
+
+
+ + + + {isSuccess ? ( +
+
+ +
+ + Votre ticket de support a été créé ! + + + Votre demande a été envoyée avec succès. Notre équipe de support + vous répondra dans les plus brefs délais. + + +
+ ) : ( +
+
+ {/* Issue Type */} + + + + + + {/* Severity */} + + + + + + {/* Title Field */} + + + handleInputChange("title", e.target.value)} + placeholder="Titre du problème" + className={twMerge( + "w-full rounded-md border border-gray-300 dark:border-gray-600", + "px-3 py-2 bg-white dark:bg-gray-700", + "text-gray-900 dark:text-gray-100", + "placeholder-gray-400 dark:placeholder-gray-500", + "focus:border-blue-500 focus:ring-1 focus:ring-blue-500", + "outline-none" + )} + required + /> + + + {/* Description Field */} + + +