diff --git a/src/components/DatePicker/DateTime/CustomTimeInput.tsx b/src/components/DatePicker/DateTime/CustomTimeInput.tsx index 89c8170..a8ae548 100644 --- a/src/components/DatePicker/DateTime/CustomTimeInput.tsx +++ b/src/components/DatePicker/DateTime/CustomTimeInput.tsx @@ -6,7 +6,7 @@ import { Button } from '../../Button'; import { B3 } from '../../Text'; import { color, typography } from '../../styles'; import { AMPM_FORMAT } from '../constant'; -import { SupportLocale } from 'src/utils'; +import { DatePickerLocale } from 'src/utils'; export interface Time { hh: string; @@ -22,7 +22,7 @@ export enum AMPM { export interface CustomTimeInputProps { newDate: Date; - language: SupportLocale; + language: DatePickerLocale; onConfirm: () => void; setNewDate: (date: Date) => void; } @@ -93,7 +93,7 @@ export const CustomTimeInput = ({ onChangeDate(time); }} > - {AMPM_FORMAT[language][inputValue.amPm]} + {AMPM_FORMAT[language][inputValue.amPm]} setNewDate(date)} required={inputProps?.required} diff --git a/src/components/DatePicker/SingleDate/index.tsx b/src/components/DatePicker/SingleDate/index.tsx index 6d0f6f4..09a5feb 100644 --- a/src/components/DatePicker/SingleDate/index.tsx +++ b/src/components/DatePicker/SingleDate/index.tsx @@ -4,18 +4,18 @@ import DatePicker, { type ReactDatePickerProps } from 'react-datepicker'; import styled from '@emotion/styled'; import { formatDateByLanguage } from '../../../utils/date'; -import { type SupportLocale } from '../../../utils/types/locale.types'; +import { type DatePickerLocale } from '../../../utils/types/locale.types'; import Icon from '../../Icon'; import { DateInput, type DateInputProps } from '../../Input/DateInput'; import { color } from '../../styles'; -import { LOCALE, MONTHS } from '../constant'; +import { MONTHS } from '../constant'; export interface DatePickerProps extends ReactDatePickerProps { selected: Date | null; onChange: (date: Date) => void; - language: SupportLocale; + language: DatePickerLocale; inputProps?: Omit; - dateFormatter?: (date: Date, language: SupportLocale) => string; + dateFormatter?: (date: Date, language: DatePickerLocale) => string; } export function SingleDate({ @@ -33,7 +33,7 @@ export function SingleDate({ { diff --git a/src/components/DatePicker/constant.ts b/src/components/DatePicker/constant.ts index e626bc5..c07e2e5 100644 --- a/src/components/DatePicker/constant.ts +++ b/src/components/DatePicker/constant.ts @@ -1,18 +1,7 @@ -import en from 'date-fns/locale/en-US'; -import ko from 'date-fns/locale/ko'; -import vi from 'date-fns/locale/vi'; - +import { type DatePickerLocale } from '../../utils/types/locale.types'; import { AMPM } from './DateTime/CustomTimeInput'; -import { type SupportLocale } from '../../utils/types/locale.types'; -import { Locale } from 'date-fns'; - -export const LOCALE: Record = { - ko, - en, - vn: vi, -}; -export const AMPM_FORMAT: Record> = { +export const AMPM_FORMAT: Record> = { ko: { AM: '오전', PM: '오후', @@ -21,7 +10,7 @@ export const AMPM_FORMAT: Record(null); const [dateEn, setDateEn] = useState(null); + const [dateVi, setDateVi] = useState(null); const [dateErr, setDateErr] = useState(null); return ( <> @@ -44,6 +45,13 @@ export function SingleDate() { language={'en'} inputProps={{ width: 400 }} /> + Vietnamese + Disabled (null); const [dateEn, setDateEn] = useState(null); + const [dateVi, setDateVi] = useState(null); const [dateErr, setDateErr] = useState(null); return ( <> @@ -85,6 +94,13 @@ export function DateTime() { language={'en'} inputProps={{ width: 400 }} /> + Vietnamese + Disabled