build-address added tested
This commit is contained in:
250
frontend/pages/build-address/add/form.tsx
Normal file
250
frontend/pages/build-address/add/form.tsx
Normal file
@@ -0,0 +1,250 @@
|
||||
"use client"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { Form, FormField, FormItem, FormLabel, FormControl, FormMessage } from "@/components/ui/form"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { DateTimePicker } from "@/components/ui/date-time-picker"
|
||||
import { buildAddressAddSchema, BuildAddressAdd } from "./schema"
|
||||
import { useAddBuildAddressMutation } from "./queries"
|
||||
|
||||
const BuildAddressForm = ({ refetchTable }: { refetchTable: () => void }) => {
|
||||
|
||||
const form = useForm<BuildAddressAdd>({
|
||||
resolver: zodResolver(buildAddressAddSchema),
|
||||
defaultValues: {
|
||||
buildNumber: "",
|
||||
doorNumber: "",
|
||||
floorNumber: "",
|
||||
commentAddress: "",
|
||||
letterAddress: "",
|
||||
shortLetterAddress: "",
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
street: "",
|
||||
expiryStarts: "",
|
||||
expiryEnds: "",
|
||||
},
|
||||
});
|
||||
|
||||
const { handleSubmit } = form;
|
||||
|
||||
const mutation = useAddBuildAddressMutation();
|
||||
|
||||
function onSubmit(values: BuildAddressAdd) { mutation.mutate({ data: values }); setTimeout(() => refetchTable(), 400) };
|
||||
|
||||
return (
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="space-y-6 p-4"
|
||||
>
|
||||
{/* ROW 1 */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="buildNumber"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Build Number</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="12A" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="doorNumber"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Door Number</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="3" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
{/* ROW 2 */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="floorNumber"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Floor Number</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="1" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="street"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Street ID</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="671f0d..." {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
{/* ROW 3 */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="commentAddress"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Comment Address</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="Near the market..." {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="letterAddress"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Letter Address</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="123 Lemon St" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
{/* ROW 4 */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="shortLetterAddress"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Short Letter Address</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="Lmn St 123" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="latitude"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Latitude</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="41.0082"
|
||||
value={field.value ?? ""}
|
||||
onChange={(e) =>
|
||||
field.onChange(e.target.value ? Number(e.target.value) : undefined)
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
{/* ROW 5 */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="longitude"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Longitude</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="28.9784"
|
||||
value={field.value ?? ""}
|
||||
onChange={(e) =>
|
||||
field.onChange(e.target.value ? Number(e.target.value) : undefined)
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* EXPIRY DATES */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="expiryStarts"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Expiry Starts</FormLabel>
|
||||
<FormControl>
|
||||
<DateTimePicker {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="expiryEnds"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Expiry Ends</FormLabel>
|
||||
<FormControl>
|
||||
<DateTimePicker {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" className="w-full">
|
||||
Add Build Address
|
||||
</Button>
|
||||
|
||||
</form>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export { BuildAddressForm }
|
||||
26
frontend/pages/build-address/add/page.tsx
Normal file
26
frontend/pages/build-address/add/page.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import { BuildAddressForm } from '@/pages/build-address/add/form';
|
||||
import { PeopleDataTableUpdate } from './table/data-table';
|
||||
import { useGraphQlBuildAddressesList } from '@/pages/build-address/queries';
|
||||
|
||||
const PageAddBuildAddress = () => {
|
||||
const [page, setPage] = useState(1);
|
||||
const [limit, setLimit] = useState(10);
|
||||
const [sort, setSort] = useState({ createdAt: 'desc' });
|
||||
const [filters, setFilters] = useState({});
|
||||
|
||||
const { data, isLoading, error, refetch } = useGraphQlBuildAddressesList({ limit, skip: (page - 1) * limit, sort, filters });
|
||||
|
||||
return (
|
||||
<>
|
||||
<PeopleDataTableUpdate
|
||||
data={data?.data || []} totalCount={data?.totalCount || 0} currentPage={page} pageSize={limit}
|
||||
onPageChange={setPage} onPageSizeChange={setLimit} refetchTable={refetch}
|
||||
/>
|
||||
<BuildAddressForm refetchTable={refetch} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export { PageAddBuildAddress };
|
||||
22
frontend/pages/build-address/add/queries.tsx
Normal file
22
frontend/pages/build-address/add/queries.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
'use client'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { toISOIfNotZ } from '@/lib/utils';
|
||||
import { BuildAddressAdd } from './schema';
|
||||
|
||||
const fetchGraphQlBuildAddressAdd = async (record: BuildAddressAdd): Promise<{ data: BuildAddressAdd | null; status: number }> => {
|
||||
console.log('Fetching test data from local API');
|
||||
try {
|
||||
const res = await fetch('/api/build-address/add', { method: 'POST', cache: 'no-store', credentials: "include", body: JSON.stringify(record) });
|
||||
if (!res.ok) { const errorText = await res.text(); console.error('Test data API error:', errorText); throw new Error(`API error: ${res.status} ${res.statusText}`) }
|
||||
const data = await res.json();
|
||||
return { data: data.data, status: res.status }
|
||||
} catch (error) { console.error('Error fetching test data:', error); throw error }
|
||||
};
|
||||
|
||||
export function useAddBuildAddressMutation() {
|
||||
return useMutation({
|
||||
mutationFn: ({ data }: { data: BuildAddressAdd }) => fetchGraphQlBuildAddressAdd(data),
|
||||
onSuccess: () => { console.log("Build address created successfully") },
|
||||
onError: (error) => { console.error("Create build address failed:", error) },
|
||||
})
|
||||
}
|
||||
17
frontend/pages/build-address/add/schema.ts
Normal file
17
frontend/pages/build-address/add/schema.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const buildAddressAddSchema = z.object({
|
||||
buildNumber: z.string(),
|
||||
doorNumber: z.string(),
|
||||
floorNumber: z.string(),
|
||||
commentAddress: z.string(),
|
||||
letterAddress: z.string(),
|
||||
shortLetterAddress: z.string(),
|
||||
latitude: z.number(),
|
||||
longitude: z.number(),
|
||||
street: z.string().optional(),
|
||||
expiryStarts: z.string().optional(),
|
||||
expiryEnds: z.string().optional(),
|
||||
});
|
||||
|
||||
export type BuildAddressAdd = z.infer<typeof buildAddressAddSchema>;
|
||||
124
frontend/pages/build-address/add/table/columns.tsx
Normal file
124
frontend/pages/build-address/add/table/columns.tsx
Normal file
@@ -0,0 +1,124 @@
|
||||
"use client"
|
||||
import { z } from "zod"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Drawer, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTrigger } from "@/components/ui/drawer"
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { useSortable } from "@dnd-kit/sortable"
|
||||
import { IconGripVertical } from "@tabler/icons-react"
|
||||
import { useIsMobile } from "@/hooks/use-mobile"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { ColumnDef, flexRender, Row } from "@tanstack/react-table"
|
||||
import { TableCell, TableRow } from "@/components/ui/table"
|
||||
import { CSS } from "@dnd-kit/utilities"
|
||||
import { schema, schemaType } from "./schema"
|
||||
import { dateToLocaleString } from "@/lib/utils"
|
||||
import { Pencil, Trash } from "lucide-react"
|
||||
|
||||
function DragHandle({ id }: { id: number }) {
|
||||
const { attributes, listeners } = useSortable({ id })
|
||||
return (
|
||||
<Button {...attributes} {...listeners} variant="ghost" size="icon" className="text-muted-foreground size-7 hover:bg-transparent">
|
||||
<IconGripVertical className="text-muted-foreground size-3" />
|
||||
<span className="sr-only">Drag to reorder</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
export function DraggableRow({ row }: { row: Row<z.infer<typeof schema>> }) {
|
||||
const { transform, transition, setNodeRef, isDragging } = useSortable({ id: row.original._id })
|
||||
return (
|
||||
<TableRow data-state={row.getIsSelected() && "selected"} data-dragging={isDragging} ref={setNodeRef}
|
||||
className="relative z-0 data-[dragging=true]:z-10 data-[dragging=true]:opacity-80"
|
||||
style={{ transform: CSS.Transform.toString(transform), transition: transition }}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
<TableCell key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
)
|
||||
}
|
||||
|
||||
function getColumns(router: any, deleteHandler: (id: string) => void): ColumnDef<schemaType>[] {
|
||||
return [
|
||||
{
|
||||
accessorKey: "uuid",
|
||||
header: "UUID",
|
||||
cell: ({ getValue }) => (<div className="font-mono text-xs bg-muted px-2 py-1 rounded break-all">{String(getValue())}</div>),
|
||||
},
|
||||
{
|
||||
accessorKey: "buildNumber",
|
||||
header: "Build Number",
|
||||
},
|
||||
{
|
||||
accessorKey: "doorNumber",
|
||||
header: "Door Number",
|
||||
},
|
||||
{
|
||||
accessorKey: "floorNumber",
|
||||
header: "Floor Number",
|
||||
},
|
||||
{
|
||||
accessorKey: "commentAddress",
|
||||
header: "Comment Address",
|
||||
},
|
||||
{
|
||||
accessorKey: "letterAddress",
|
||||
header: "Letter Address",
|
||||
},
|
||||
{
|
||||
accessorKey: "shortLetterAddress",
|
||||
header: "Short Letter Address",
|
||||
},
|
||||
{
|
||||
accessorKey: "latitude",
|
||||
header: "Latitude",
|
||||
},
|
||||
{
|
||||
accessorKey: "longitude",
|
||||
header: "Longitude",
|
||||
},
|
||||
{
|
||||
accessorKey: "street",
|
||||
header: "StreetId",
|
||||
},
|
||||
{
|
||||
accessorKey: "createdAt",
|
||||
header: "Created",
|
||||
cell: ({ getValue }) => dateToLocaleString(getValue() as string),
|
||||
},
|
||||
{
|
||||
accessorKey: "updatedAt",
|
||||
header: "Updated",
|
||||
cell: ({ getValue }) => dateToLocaleString(getValue() as string),
|
||||
},
|
||||
{
|
||||
accessorKey: "expiryStarts",
|
||||
header: "Expiry Starts",
|
||||
cell: ({ getValue }) => getValue() ? dateToLocaleString(getValue() as string) : "-",
|
||||
},
|
||||
{
|
||||
accessorKey: "expiryEnds",
|
||||
header: "Expiry Ends",
|
||||
cell: ({ getValue }) => getValue() ? dateToLocaleString(getValue() as string) : "-",
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "Actions",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<div>
|
||||
<Button className="bg-amber-400 text-black border-amber-400" variant="outline" size="sm" onClick={() => { router.push(`/build-address/update?uuid=${row.original.uuid}`) }}>
|
||||
<Pencil />
|
||||
</Button>
|
||||
<Button className="bg-red-700 text-white border-red-700 mx-4" variant="outline" size="sm" onClick={() => { deleteHandler(row.original.uuid || "") }}>
|
||||
<Trash />
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
export { getColumns };
|
||||
282
frontend/pages/build-address/add/table/data-table.tsx
Normal file
282
frontend/pages/build-address/add/table/data-table.tsx
Normal file
@@ -0,0 +1,282 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import {
|
||||
closestCenter,
|
||||
DndContext,
|
||||
KeyboardSensor,
|
||||
MouseSensor,
|
||||
TouchSensor,
|
||||
useSensor,
|
||||
useSensors,
|
||||
type UniqueIdentifier,
|
||||
} from "@dnd-kit/core"
|
||||
import { restrictToVerticalAxis } from "@dnd-kit/modifiers"
|
||||
import {
|
||||
SortableContext,
|
||||
verticalListSortingStrategy,
|
||||
} from "@dnd-kit/sortable"
|
||||
import {
|
||||
IconChevronDown,
|
||||
IconChevronLeft,
|
||||
IconChevronRight,
|
||||
IconChevronsLeft,
|
||||
IconChevronsRight,
|
||||
IconLayoutColumns,
|
||||
} from "@tabler/icons-react"
|
||||
import {
|
||||
ColumnFiltersState,
|
||||
flexRender,
|
||||
getCoreRowModel,
|
||||
getFacetedRowModel,
|
||||
getFacetedUniqueValues,
|
||||
getFilteredRowModel,
|
||||
getSortedRowModel,
|
||||
SortingState,
|
||||
useReactTable,
|
||||
VisibilityState,
|
||||
} from "@tanstack/react-table"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table"
|
||||
import {
|
||||
Tabs,
|
||||
TabsContent,
|
||||
TabsList,
|
||||
TabsTrigger,
|
||||
} from "@/components/ui/tabs"
|
||||
import { schemaType } from "./schema"
|
||||
import { getColumns, DraggableRow } from "./columns"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { Home } from "lucide-react"
|
||||
import { useDeleteBuildAddressMutation } from "@/pages/build-address/queries"
|
||||
|
||||
export function PeopleDataTableUpdate({
|
||||
data,
|
||||
totalCount,
|
||||
currentPage,
|
||||
pageSize,
|
||||
onPageChange,
|
||||
onPageSizeChange,
|
||||
refetchTable,
|
||||
}: {
|
||||
data: schemaType[],
|
||||
totalCount: number,
|
||||
currentPage: number,
|
||||
pageSize: number,
|
||||
onPageChange: (page: number) => void,
|
||||
onPageSizeChange: (size: number) => void,
|
||||
refetchTable: () => void
|
||||
}) {
|
||||
|
||||
const router = useRouter();
|
||||
const [rowSelection, setRowSelection] = React.useState({})
|
||||
const [columnVisibility, setColumnVisibility] = React.useState<VisibilityState>({})
|
||||
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>([])
|
||||
const [sorting, setSorting] = React.useState<SortingState>([])
|
||||
const sortableId = React.useId()
|
||||
const sensors = useSensors(useSensor(MouseSensor, {}), useSensor(TouchSensor, {}), useSensor(KeyboardSensor, {}))
|
||||
const dataIds = React.useMemo<UniqueIdentifier[]>(() => data?.map(({ _id }) => _id) || [], [data])
|
||||
|
||||
const deleteMutation = useDeleteBuildAddressMutation()
|
||||
const deleteHandler = (id: string) => { deleteMutation.mutate({ uuid: id }); setTimeout(() => { refetchTable() }, 200) }
|
||||
const columns = getColumns(router, deleteHandler);
|
||||
const pagination = React.useMemo(() => ({ pageIndex: currentPage - 1, pageSize: pageSize, }), [currentPage, pageSize])
|
||||
const totalPages = Math.ceil(totalCount / pageSize)
|
||||
|
||||
const table = useReactTable({
|
||||
data,
|
||||
columns,
|
||||
pageCount: totalPages,
|
||||
state: { sorting, columnVisibility, rowSelection, columnFilters, pagination },
|
||||
manualPagination: true,
|
||||
enableRowSelection: true,
|
||||
getRowId: (row) => row._id.toString(),
|
||||
onRowSelectionChange: setRowSelection,
|
||||
onSortingChange: setSorting,
|
||||
onColumnFiltersChange: setColumnFilters,
|
||||
onColumnVisibilityChange: setColumnVisibility,
|
||||
onPaginationChange: (updater) => {
|
||||
const nextPagination = typeof updater === "function" ? updater(pagination) : updater;
|
||||
onPageChange(nextPagination.pageIndex + 1); onPageSizeChange(nextPagination.pageSize);
|
||||
},
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getFilteredRowModel: getFilteredRowModel(),
|
||||
getSortedRowModel: getSortedRowModel(),
|
||||
getFacetedRowModel: getFacetedRowModel(),
|
||||
getFacetedUniqueValues: getFacetedUniqueValues(),
|
||||
})
|
||||
|
||||
const handlePageSizeChange = (value: string) => { const newSize = Number(value); onPageSizeChange(newSize); onPageChange(1) }
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
defaultValue="outline"
|
||||
className="w-full flex-col justify-start gap-6"
|
||||
>
|
||||
<div className="flex items-center justify-between px-4 lg:px-6">
|
||||
<Label htmlFor="view-selector" className="sr-only">
|
||||
View
|
||||
</Label>
|
||||
<Select defaultValue="outline">
|
||||
<SelectTrigger className="flex w-fit @4xl/main:hidden" size="sm" id="view-selector">
|
||||
<SelectValue placeholder="Select a view" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="outline">Outline</SelectItem>
|
||||
<SelectItem value="past-performance">Past Performance</SelectItem>
|
||||
<SelectItem value="key-personnel">Key Personnel</SelectItem>
|
||||
<SelectItem value="focus-documents">Focus Documents</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div className="flex items-center gap-2">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="sm">
|
||||
<IconLayoutColumns />
|
||||
<span className="hidden lg:inline">Customize Columns</span>
|
||||
<span className="lg:hidden">Columns</span>
|
||||
<IconChevronDown />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-56">
|
||||
{table.getAllColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide()).map((column) => {
|
||||
return (
|
||||
<DropdownMenuCheckboxItem key={column.id} className="capitalize" checked={column.getIsVisible()} onCheckedChange={(value) => column.toggleVisibility(!!value)} >
|
||||
{column.id}
|
||||
</DropdownMenuCheckboxItem>
|
||||
)
|
||||
})}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<Button variant="outline" size="sm" onClick={() => { router.push("/build-address") }}>
|
||||
<Home />
|
||||
<span className="hidden lg:inline">Back to Build Address</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<TabsContent value="outline"
|
||||
className="relative flex flex-col gap-4 overflow-auto px-4 lg:px-6"
|
||||
>
|
||||
<div className="overflow-hidden rounded-lg border">
|
||||
<DndContext collisionDetection={closestCenter} modifiers={[restrictToVerticalAxis]} sensors={sensors} id={sortableId} >
|
||||
<Table>
|
||||
<TableHeader className="bg-muted sticky top-0 z-10">
|
||||
{table.getHeaderGroups().map((headerGroup) => (
|
||||
<TableRow key={headerGroup.id}>
|
||||
{headerGroup.headers.map((header) => {
|
||||
return (
|
||||
<TableHead key={header.id} colSpan={header.colSpan}>
|
||||
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
|
||||
</TableHead>
|
||||
)
|
||||
})}
|
||||
</TableRow>
|
||||
))}
|
||||
</TableHeader>
|
||||
<TableBody className="**:data-[slot=table-cell]:first:w-8">
|
||||
{table.getRowModel().rows?.length ? (<SortableContext items={dataIds} strategy={verticalListSortingStrategy} >
|
||||
{table.getRowModel().rows.map((row) => <DraggableRow key={row.id} row={row} />)}
|
||||
</SortableContext>) : (
|
||||
<TableRow><TableCell colSpan={columns.length} className="h-24 text-center">No results.</TableCell></TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</DndContext>
|
||||
</div>
|
||||
<div className="flex items-center justify-between px-4">
|
||||
<div className="text-muted-foreground hidden flex-1 text-sm lg:flex">
|
||||
{table.getFilteredSelectedRowModel().rows.length} of{" "}
|
||||
{table.getFilteredRowModel().rows.length} row(s) selected.
|
||||
</div>
|
||||
<div className="flex w-full items-center gap-8 lg:w-fit">
|
||||
<div className="hidden items-center gap-2 lg:flex">
|
||||
<Label htmlFor="rows-per-page" className="text-sm font-medium">Rows per page</Label>
|
||||
<Select value={`${pageSize}`} onValueChange={handlePageSizeChange}>
|
||||
<SelectTrigger size="sm" className="w-20" id="rows-per-page">
|
||||
<SelectValue placeholder={pageSize} />
|
||||
</SelectTrigger>
|
||||
<SelectContent side="top">
|
||||
{[10, 20, 30].map((size) => <SelectItem key={size} value={`${size}`}>{size}</SelectItem>)}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="flex w-fit items-center justify-center text-sm font-medium">
|
||||
Page {currentPage} of {totalPages}
|
||||
</div>
|
||||
<div className="flex w-fit items-center justify-center text-sm font-medium">
|
||||
Total Count: {totalCount}
|
||||
</div>
|
||||
<div className="ml-auto flex items-center gap-2 lg:ml-0">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => onPageChange(1)}
|
||||
disabled={currentPage === 1}
|
||||
>
|
||||
<IconChevronsLeft />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => onPageChange(currentPage - 1)}
|
||||
disabled={currentPage === 1}
|
||||
>
|
||||
<IconChevronLeft />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => onPageChange(currentPage + 1)}
|
||||
disabled={currentPage >= totalPages}
|
||||
>
|
||||
<IconChevronRight />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => onPageChange(totalPages)}
|
||||
disabled={currentPage >= totalPages}
|
||||
>
|
||||
<IconChevronsRight />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent value="past-performance" className="flex flex-col px-4 lg:px-6">
|
||||
<div className="aspect-video w-full flex-1 rounded-lg border border-dashed"></div>
|
||||
</TabsContent>
|
||||
<TabsContent value="key-personnel" className="flex flex-col px-4 lg:px-6">
|
||||
<div className="aspect-video w-full flex-1 rounded-lg border border-dashed"></div>
|
||||
</TabsContent>
|
||||
<TabsContent value="focus-documents" className="flex flex-col px-4 lg:px-6">
|
||||
<div className="aspect-video w-full flex-1 rounded-lg border border-dashed"></div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
)
|
||||
}
|
||||
24
frontend/pages/build-address/add/table/schema.tsx
Normal file
24
frontend/pages/build-address/add/table/schema.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const schema = z.object({
|
||||
_id: z.string(),
|
||||
uuid: z.string(),
|
||||
firstName: z.string().optional(),
|
||||
surname: z.string().optional(),
|
||||
middleName: z.string().optional(),
|
||||
sexCode: z.string().optional(),
|
||||
personRef: z.string().optional(),
|
||||
personTag: z.string().optional(),
|
||||
fatherName: z.string().optional(),
|
||||
motherName: z.string().optional(),
|
||||
countryCode: z.string().optional(),
|
||||
nationalIdentityId: z.string().optional(),
|
||||
birthPlace: z.string().optional(),
|
||||
birthDate: z.string().optional(),
|
||||
taxNo: z.string().optional(),
|
||||
birthname: z.string().optional(),
|
||||
expiryStarts: z.string().optional(),
|
||||
expiryEnds: z.string().optional(),
|
||||
});
|
||||
|
||||
export type schemaType = z.infer<typeof schema>;
|
||||
24
frontend/pages/build-address/add/types.ts
Normal file
24
frontend/pages/build-address/add/types.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
interface PeopleAdd {
|
||||
|
||||
firstName: string;
|
||||
surname: string;
|
||||
middleName?: string;
|
||||
sexCode: string;
|
||||
personRef?: string;
|
||||
personTag?: string;
|
||||
fatherName?: string;
|
||||
motherName?: string;
|
||||
countryCode: string;
|
||||
nationalIdentityId: string;
|
||||
birthPlace: string;
|
||||
birthDate: string;
|
||||
taxNo?: string;
|
||||
birthname?: string;
|
||||
expiryStarts?: string;
|
||||
expiryEnds?: string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
export type { PeopleAdd };
|
||||
Reference in New Issue
Block a user