From 2a7492262146ce9d2b21bf8f328c5a80fe4834b8 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Fri, 21 Feb 2025 11:29:36 +0700 Subject: [PATCH] feat: add an opsional component for handling the create new group form --- src/components/ui/DataTable.tsx | 23 +++++- src/pages/groups/ManageGroups.tsx | 129 +++++++++++++++++++++++++++++- 2 files changed, 149 insertions(+), 3 deletions(-) diff --git a/src/components/ui/DataTable.tsx b/src/components/ui/DataTable.tsx index e18d65f..73ca407 100644 --- a/src/components/ui/DataTable.tsx +++ b/src/components/ui/DataTable.tsx @@ -19,13 +19,26 @@ import { } from '@/components/ui/table'; import { useState } from 'react'; import { Input } from './input'; +import { Button } from './button'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger +} from './dialog'; interface DataTableProps { columns: ColumnDef[]; data: TData[]; } -export function DataTable({ columns, data }: DataTableProps) { +export function DataTable({ + columns, + data, + createGroup +}: DataTableProps & { createGroup?: () => void }) { const [columnFilters, setColumnFilters] = useState([]); const table = useReactTable({ data, @@ -40,13 +53,19 @@ export function DataTable({ columns, data }: DataTableProps -
+
table.getColumn('name')?.setFilterValue(event.target.value)} className="max-w-sm" /> + + {createGroup && ( + + )}
diff --git a/src/pages/groups/ManageGroups.tsx b/src/pages/groups/ManageGroups.tsx index bdbdb34..8da31ba 100644 --- a/src/pages/groups/ManageGroups.tsx +++ b/src/pages/groups/ManageGroups.tsx @@ -1,5 +1,23 @@ import { DataTable } from '@/components/ui/DataTable'; import { columns, Group } from './Column'; +import { Button } from '@/components/ui/button'; +import { Link } from 'react-router-dom'; +import { + Dialog, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger +} from '@/components/ui/dialog'; +import { DialogContent } from '@mui/material'; +import { useState } from 'react'; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue +} from '@/components/ui/select'; const dataGroup: Group[] = [ { @@ -23,11 +41,120 @@ const dataGroup: Group[] = [ ]; const ManageGroups = () => { + const [isDialogOpen, setIsDialogOpen] = useState(false); + const [formData, setFormData] = useState({ + groupName: '', + description: '', + pin_length: '', + max_pin_attempts: '', + default_notification: '' + }); + + const openDialog = () => setIsDialogOpen(true); + const closeDialog = () => setIsDialogOpen(false); + + const handleChange = (e: React.ChangeEvent) => { + setFormData({ + ...formData, + [e.target.name]: e.target.value + }); + }; + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + console.log('Submitted Data', formData); + closeDialog(); + }; + return (

Groups

- + + + + +
+ Create New Group + Fill out the form to create a new group +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + {/* */} +
+ + +
+
+
);