feat: attributes page
This commit is contained in:
@ -4,13 +4,9 @@ import { useMemo } from "react";
|
||||
import { IconCheck, IconX } from "@tabler/icons-react";
|
||||
import { DataTableColumn } from "mantine-datatable";
|
||||
import { Box } from "@mantine/core";
|
||||
import AttributeDefaultValue from "@/components/ui/AttributeDefaultValue/AttributeDefaultValue";
|
||||
import useIsMobile from "@/hooks/utils/useIsMobile";
|
||||
import { ModuleAttributeSchema } from "@/lib/client";
|
||||
import {
|
||||
naiveDateTimeStringToUtc,
|
||||
utcDateTimeToLocalString,
|
||||
utcDateToLocalString,
|
||||
} from "@/utils/datetime";
|
||||
|
||||
const useAttributesInnerTableColumns = () => {
|
||||
const isMobile = useIsMobile();
|
||||
@ -35,26 +31,7 @@ const useAttributesInnerTableColumns = () => {
|
||||
{
|
||||
title: "Значение по умолчанию",
|
||||
accessor: "defaultValue",
|
||||
render: attr => {
|
||||
if (!attr.defaultValue) return <>-</>;
|
||||
const value = attr.defaultValue;
|
||||
if (value === null) return <>-</>;
|
||||
|
||||
const type = attr.type.type;
|
||||
if (type === "datetime") {
|
||||
return utcDateTimeToLocalString(
|
||||
naiveDateTimeStringToUtc(value as string)
|
||||
);
|
||||
}
|
||||
if (type === "date") {
|
||||
return utcDateToLocalString(value as string);
|
||||
}
|
||||
if (type === "bool") {
|
||||
return value ? <IconCheck /> : <IconX />;
|
||||
}
|
||||
|
||||
return <>{value}</>;
|
||||
},
|
||||
render: attr => <AttributeDefaultValue attribute={attr} />,
|
||||
},
|
||||
{
|
||||
title: "Синхронизировано в группе",
|
||||
|
||||
Reference in New Issue
Block a user