mirror of
https://github.com/diced/zipline.git
synced 2025-12-12 15:50:11 -08:00
fix: date normalization in ssr
This commit is contained in:
@@ -44,6 +44,13 @@ export default function ViewFileId() {
|
||||
|
||||
const { file, password, code, user, host, metrics, filesRoute, pw } = data;
|
||||
|
||||
// Fix dates that were stringified during SSR
|
||||
if (file?.createdAt) (file as any).createdAt = new Date(file.createdAt);
|
||||
if (file?.updatedAt) (file as any).updatedAt = new Date(file.updatedAt);
|
||||
if (file?.deletesAt) (file as any).deletesAt = new Date(file.deletesAt);
|
||||
if (user?.createdAt) (user as any).createdAt = new Date(user.createdAt);
|
||||
if (user?.updatedAt) (user as any).updatedAt = new Date(user.updatedAt);
|
||||
|
||||
const [passwordValue, setPassword] = useState<string>('');
|
||||
const [passwordError, setPasswordError] = useState<string>('');
|
||||
const [detailsOpen, setDetailsOpen] = useState<boolean>(false);
|
||||
|
||||
@@ -88,13 +88,6 @@ export async function render(
|
||||
host = proto === 'https' || zConfig.core.returnHttpsUrls ? `https://${host}` : `http://${host}`;
|
||||
}
|
||||
|
||||
// Date normalization
|
||||
(file as any).createdAt = file.createdAt.toISOString();
|
||||
(file as any).updatedAt = file.updatedAt.toISOString();
|
||||
(file as any).deletesAt = file.deletesAt?.toISOString() || null;
|
||||
(user as any).createdAt = user.createdAt.toISOString();
|
||||
(user as any).updatedAt = user.updatedAt.toISOString();
|
||||
|
||||
const code = await isCode(file.name);
|
||||
const themes = await readThemes();
|
||||
const metrics = await parserMetrics(user.id);
|
||||
|
||||
Reference in New Issue
Block a user