updated living space added

This commit is contained in:
2025-12-04 15:46:24 +03:00
parent 56b42bb906
commit 53e1f1e4fc
70 changed files with 1128 additions and 824 deletions

View File

@@ -24,7 +24,7 @@ export function DraggableRow({ row }: { row: Row<z.infer<typeof schema>> }) {
)
}
function getColumns(router: any, deleteHandler: (id: string) => void): ColumnDef<schemaType>[] {
function getColumns(deleteHandler: (id: string) => void): ColumnDef<schemaType>[] {
return [
{
accessorKey: "uuid",
@@ -32,48 +32,26 @@ function getColumns(router: any, deleteHandler: (id: string) => void): ColumnDef
cell: ({ getValue }) => (<div className="font-mono text-xs bg-muted px-2 py-1 rounded break-all">{String(getValue())}</div>),
},
{
accessorKey: "firstName",
header: "First Name",
accessorKey: "email",
header: "Email",
},
{
accessorKey: "surname",
header: "Surname",
accessorKey: "phone",
header: "Phone",
},
{
accessorKey: "middleName",
header: "Middle Name",
accessorKey: "tag",
header: "Tag",
},
{
accessorKey: "sexCode",
header: "Sex",
accessorKey: "isNotificationSend",
header: "Notificated?",
cell: ({ getValue }) => getValue() ? (<div className="text-green-600 font-medium">Yes</div>) : (<div className="text-red-600 font-medium">No</div>),
},
{
accessorKey: "personRef",
header: "Person Ref",
},
{
accessorKey: "personTag",
header: "Person Tag",
},
{
accessorKey: "fatherName",
header: "Father Name",
},
{
accessorKey: "motherName",
header: "Mother Name",
},
{
accessorKey: "countryCode",
header: "Country",
},
{
accessorKey: "nationalIdentityId",
header: "National ID",
},
{
accessorKey: "birthPlace",
header: "Birth Place",
accessorKey: "isEmailSend",
header: "Email Send?",
cell: ({ getValue }) => getValue() ? (<div className="text-green-600 font-medium">Yes</div>) : (<div className="text-red-600 font-medium">No</div>),
},
{
accessorKey: "active",
@@ -86,9 +64,9 @@ function getColumns(router: any, deleteHandler: (id: string) => void): ColumnDef
cell: ({ getValue }) => getValue() ? (<div className="text-green-600 font-medium">Yes</div>) : (<div className="text-red-600 font-medium">No</div>),
},
{
accessorKey: "birthDate",
header: "Birth Date",
cell: ({ getValue }) => dateToLocaleString(getValue() as string),
accessorKey: "deleted",
header: "Deleted",
cell: ({ getValue }) => getValue() ? (<div className="text-red-600 font-medium">Yes</div>) : (<div className="text-green-600 font-medium">No</div>),
},
{
accessorKey: "createdAt",
@@ -110,15 +88,36 @@ function getColumns(router: any, deleteHandler: (id: string) => void): ColumnDef
header: "Expiry Ends",
cell: ({ getValue }) => getValue() ? dateToLocaleString(getValue() as string) : "-",
},
{
accessorKey: "collectionTokens.tokens",
header: "Default Token",
cell: ({ row }) => {
const defaultToken = row.original.collectionTokens?.defaultSelection;
return defaultToken ? <div><div className="flex flex-col w-full"><span className="font-mono text-xs text-muted-foreground break-all">{defaultToken}</span></div></div> : <div>No Default Token</div>;
},
},
{
accessorKey: "collectionTokens.selectedBuildIDS",
header: "Selected Build IDS",
cell: ({ row }) => {
const selectedBuildIDS = row.original.collectionTokens?.selectedBuildIDS;
return selectedBuildIDS && <div><div className="flex flex-col w-full"><span className="font-mono text-xs text-muted-foreground break-all">{selectedBuildIDS.length}</span></div></div>;
},
},
{
accessorKey: "collectionTokens.selectedCompanyIDS",
header: "Selected Company IDS",
cell: ({ row }) => {
const selectedCompanyIDS = row.original.collectionTokens?.selectedCompanyIDS;
return selectedCompanyIDS && <div><div className="flex flex-col w-full"><span className="font-mono text-xs text-muted-foreground break-all">{selectedCompanyIDS.length}</span></div></div>;
},
},
{
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(`/users/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>

View File

@@ -100,7 +100,7 @@ export function UserDataTableUpdate({
const dataIds = React.useMemo<UniqueIdentifier[]>(() => data?.map(({ _id }) => _id) || [], [data])
const deleteMutation = useDeleteUserMutation()
const deleteHandler = (id: string) => { deleteMutation.mutate({ uuid: id }); setTimeout(() => { refetchTable() }, 400) }
const deleteHandler = (id: string) => { deleteMutation.mutate({ uuid: id, refetchTable }) }
const columns = getColumns(router, deleteHandler);
const pagination = React.useMemo(() => ({ pageIndex: currentPage - 1, pageSize: pageSize, }), [currentPage, pageSize])
const totalPages = Math.ceil(totalCount / pageSize)

View File

@@ -2,46 +2,23 @@ import { z } from "zod";
export const schema = z.object({
_id: z.string(),
uuid: z.string().nullable().optional(),
expiryStarts: z.string().nullable().optional(),
expiryEnds: z.string().nullable().optional(),
isConfirmed: z.boolean().nullable().optional(),
deleted: z.boolean().nullable().optional(),
active: z.boolean().nullable().optional(),
crypUuId: z.string().nullable().optional(),
createdCredentialsToken: z.string().nullable().optional(),
updatedCredentialsToken: z.string().nullable().optional(),
confirmedCredentialsToken: z.string().nullable().optional(),
isNotificationSend: z.boolean().nullable().optional(),
isEmailSend: z.boolean().nullable().optional(),
refInt: z.number().nullable().optional(),
refId: z.string().nullable().optional(),
replicationId: z.number().nullable().optional(),
expiresAt: z.string().nullable().optional(),
resetToken: z.string().nullable().optional(),
password: z.string().nullable().optional(),
history: z.array(z.string()).optional(),
tag: z.string().nullable().optional(),
email: z.string().nullable().optional(),
phone: z.string().nullable().optional(),
collectionTokens: z
.object({
default: z.string().nullable().optional(),
tokens: z
.array(
z.object({
prefix: z.string(),
token: z.string(),
})
)
.optional(),
})
.nullable()
.optional(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
uuid: z.string(),
expiryStarts: z.string(),
expiryEnds: z.string(),
isConfirmed: z.boolean(),
deleted: z.boolean(),
active: z.boolean(),
isNotificationSend: z.boolean(),
isEmailSend: z.boolean(),
expiresAt: z.string(),
tag: z.string(),
email: z.string(),
phone: z.string().optional(),
collectionTokens: z.object({
defaultSelection: z.string().nullable().optional(), selectedBuildIDS: z.array(z.string()).optional(), selectedCompanyIDS: z.array(z.string()).optional()
}).nullable().optional(),
createdAt: z.string(),
updatedAt: z.string(),
});
export type schemaType = z.infer<typeof schema>;