feat: attributes page

This commit is contained in:
2025-11-02 16:07:49 +04:00
parent 8020561da6
commit 03be3903cb
16 changed files with 348 additions and 48 deletions

View File

@ -0,0 +1,35 @@
import { FC } from "react";
import { IconCheck, IconX } from "@tabler/icons-react";
import { AttributeSchema } from "@/lib/client";
import {
naiveDateTimeStringToUtc,
utcDateTimeToLocalString,
utcDateToLocalString,
} from "@/utils/datetime";
type Props = {
attribute: AttributeSchema;
};
const AttributeDefaultValue: FC<Props> = ({ attribute }) => {
if (!attribute.defaultValue) return <>-</>;
const value = attribute.defaultValue;
if (value === null) return <>-</>;
const type = attribute.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}</>;
};
export default AttributeDefaultValue;