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:
AmirReza Jamali
2025-09-28 23:19:12 +03:30
parent 120331a886
commit dde2fc5a05
5 changed files with 120 additions and 4 deletions
+1 -1
View File
@@ -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");