feat: update CardAttributeField to handle date values without timezone
This commit is contained in:
@@ -4,6 +4,7 @@ import { UseFormReturnType } from "@mantine/form";
|
|||||||
import { DatePickerInput, DateTimePicker } from "@mantine/dates";
|
import { DatePickerInput, DateTimePicker } from "@mantine/dates";
|
||||||
import { CardGeneralFormType } from "../../../pages/CardsPage/drawers/CardEditDrawer/tabs/GeneralTab/GeneralTab.tsx";
|
import { CardGeneralFormType } from "../../../pages/CardsPage/drawers/CardEditDrawer/tabs/GeneralTab/GeneralTab.tsx";
|
||||||
import { IconInfoCircle } from "@tabler/icons-react";
|
import { IconInfoCircle } from "@tabler/icons-react";
|
||||||
|
import { dateWithoutTimezone } from "../../../shared/lib/date.ts";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
attribute: AttributeSchema;
|
attribute: AttributeSchema;
|
||||||
@@ -45,6 +46,15 @@ const CardAttributeField = ({ attribute, form, readOnly }: Props) => {
|
|||||||
<DatePickerInput
|
<DatePickerInput
|
||||||
label={label}
|
label={label}
|
||||||
{...form.getInputProps(attribute.name)}
|
{...form.getInputProps(attribute.name)}
|
||||||
|
onChange={(value) => {
|
||||||
|
if (!value) {
|
||||||
|
form.getInputProps(attribute.name).onChange(null);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
form.getInputProps(attribute.name).onChange(
|
||||||
|
dateWithoutTimezone(value),
|
||||||
|
);
|
||||||
|
}}
|
||||||
value={getDateValue()}
|
value={getDateValue()}
|
||||||
clearable
|
clearable
|
||||||
locale={"ru-RU"}
|
locale={"ru-RU"}
|
||||||
@@ -58,6 +68,15 @@ const CardAttributeField = ({ attribute, form, readOnly }: Props) => {
|
|||||||
<DateTimePicker
|
<DateTimePicker
|
||||||
label={label}
|
label={label}
|
||||||
{...form.getInputProps(attribute.name)}
|
{...form.getInputProps(attribute.name)}
|
||||||
|
onChange={(value) => {
|
||||||
|
if (!value) {
|
||||||
|
form.getInputProps(attribute.name).onChange(null);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
form.getInputProps(attribute.name).onChange(
|
||||||
|
dateWithoutTimezone(value),
|
||||||
|
);
|
||||||
|
}}
|
||||||
value={getDateValue()}
|
value={getDateValue()}
|
||||||
clearable
|
clearable
|
||||||
locale={"ru-RU"}
|
locale={"ru-RU"}
|
||||||
|
|||||||
Reference in New Issue
Block a user