Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix hydration issues with date string
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 1e3f649 commit 9799442
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions components/AppealCard.tsx
Expand Up @@ -10,6 +10,7 @@ import {
StackDivider,
Text,
} from "@chakra-ui/react";
import { useEffect, useState } from "react";

export default function (props: {
ban_reason: string;
Expand All @@ -20,6 +21,14 @@ export default function (props: {
reason_for_unban: string;
username: string;
}) {
const [dateString, setDateString] = useState(
new Date(props.createdAt).toUTCString()
);

useEffect(() => {
setDateString(new Date(props.createdAt).toLocaleString());
}, [props.createdAt]);

return (
<>
<Card>
Expand All @@ -46,13 +55,15 @@ export default function (props: {
</Box>
<Box>
<Button colorScheme="red">Deny</Button>
<Button colorScheme="blue" ml="8px">Accept</Button>
<Button colorScheme="blue" ml="8px">
Accept
</Button>
</Box>
</Stack>
</CardBody>
<CardFooter>
<Text fontSize="xs">
Submitted at: {new Date(props.createdAt).toLocaleString()}
Submitted at: {dateString}
<br />
ID: {props.id}
</Text>
Expand Down

0 comments on commit 9799442

Please sign in to comment.