resolves #1061, resolves #1027, resolves #1007, resolves #1001, resolves #987, resolves #890, resolves #882, resolves #837

This commit is contained in:
Amruth Pillai
2022-11-23 12:24:17 +01:00
parent d1a1b68302
commit 056c61e985
2 changed files with 7 additions and 4 deletions

View File

@ -22,6 +22,7 @@ const ResumeInput: React.FC<Props> = ({ type = 'text', label, path, className, m
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const stateValue = useAppSelector((state) => get(state.resume.present, path, '')); const stateValue = useAppSelector((state) => get(state.resume.present, path, ''));
const dateFormat = useAppSelector((state) => state.resume.present.metadata.date.format);
useEffect(() => { useEffect(() => {
setValue(stateValue); setValue(stateValue);
@ -56,14 +57,16 @@ const ResumeInput: React.FC<Props> = ({ type = 'text', label, path, className, m
if (type === 'date') { if (type === 'date') {
return ( return (
<DatePicker <DatePicker
showToolbar
openTo="year" openTo="year"
label={label} label={label}
value={value} value={value}
toolbarFormat={dateFormat}
views={['year', 'month', 'day']} views={['year', 'month', 'day']}
renderInput={(params) => <TextField {...params} error={false} className={className} />} renderInput={(params) => <TextField {...params} error={false} className={className} />}
onChange={(date: Date | null, keyboardInputValue: string | undefined) => { onChange={(date: Date | null, keyboardInputValue: string | undefined) => {
isEmpty(keyboardInputValue) && onChangeValue(''); isEmpty(keyboardInputValue) && onChangeValue('');
date && dayjs(date).utc().isValid() && onChangeValue(dayjs(date).utc().toISOString()); date && dayjs(date).isValid() && onChangeValue(dayjs(date).format('YYYY-MM-DD'));
}} }}
/> />
); );

View File

@ -30,7 +30,7 @@ export const formatDateString = (date: string | DateRange, formatStr: string): s
if (isString(date)) { if (isString(date)) {
if (!dayjs(date).isValid()) return null; if (!dayjs(date).isValid()) return null;
return dayjs(date).utc(true).format(formatStr); return dayjs(date).format(formatStr);
} }
// If `date` is a DateRange // If `date` is a DateRange
@ -39,8 +39,8 @@ export const formatDateString = (date: string | DateRange, formatStr: string): s
if (!dayjs(date.start).isValid()) return null; if (!dayjs(date.start).isValid()) return null;
if (!isEmpty(date.end) && dayjs(date.end).isValid()) { if (!isEmpty(date.end) && dayjs(date.end).isValid()) {
return `${dayjs(date.start).utc(true).format(formatStr)} - ${dayjs(date.end).utc(true).format(formatStr)}`; return `${dayjs(date.start).format(formatStr)} - ${dayjs(date.end).format(formatStr)}`;
} }
return `${dayjs(date.start).utc(true).format(formatStr)} - ${presentString}`; return `${dayjs(date.start).format(formatStr)} - ${presentString}`;
}; };