fix: Prevent edit page crash and correct date formatting
On the company edit page, added optional chaining to the `defaultValues` prop. This prevents a potential runtime error if the company data is undefined when the page loads. Additionally, this commit corrects the `unixToDate` utility function. The previous logic could incorrectly include 'false' in the format string when time was not required. It now uses a ternary operator to conditionally add the time format, ensuring correct output. Minor code formatting adjustments are also included.
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ export const unixToDate = ({
|
||||
unix: number;
|
||||
hasTime?: boolean;
|
||||
}) => {
|
||||
return moment.unix(unix).format(`YYYY/MM/DD ${hasTime && "HH:MM"}`);
|
||||
return moment.unix(unix).format(`YYYY/MM/DD ${hasTime ? "HH:MM" : ""}`);
|
||||
};
|
||||
export const msToDate = (ms: number) => {
|
||||
return moment.default(ms).format("YYYY/MM/DD");
|
||||
|
||||
Reference in New Issue
Block a user