Skip to content

Commit

Permalink
fix: add suspsese and add type safety
Browse files Browse the repository at this point in the history
  • Loading branch information
loopy-lim committed Nov 11, 2024
1 parent 15f7a07 commit 1b66f69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/components/Conversation/Save/Chatting.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { cn } from "@/lib/utils";

interface ConversationSaveChatViewerProps {
chats: {
chats?: {
date: string;
name: string;
email: string;
message: string;
}[];
voice: {
voice?: {
date: string;
name: string;
email: string;
Expand All @@ -20,8 +20,8 @@ const ConversationSaveChatViewer = ({
voice,
}: ConversationSaveChatViewerProps) => {
const chatting = [
...chats.map((c) => ({ ...c, status: "chat" })),
...voice.map((v) => ({ ...v, status: "voice" })),
...(chats ?? []).map((c) => ({ ...c, status: "chat" })),
...(voice ?? []).map((v) => ({ ...v, status: "voice" })),
];

const sortedChatting = [...chatting].sort((a, b) => {
Expand Down Expand Up @@ -57,7 +57,7 @@ const ConversationSaveChatViewer = ({
<div
className={cn(
"mr-3 flex h-8 w-8 items-center justify-center rounded-full font-bold",
chat.name === chats[0].name
chats && chats.length > 0 && chat.name === chats[0].name
? "bg-gray-300 text-black"
: "bg-black text-white",
)}
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/Users/useCheckUserValid.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode, useEffect } from "react";
import { ReactNode, Suspense, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import useCheckUserQuery from "@/hooks/Users/useCheckUserQuery";

Expand All @@ -20,7 +20,7 @@ export const UserLoginPageGuard = ({ children }: UserGuardProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [checkUser, isError]);

return children;
return <Suspense>{children}</Suspense>;
};

export const UserGuard = ({ children }: UserGuardProps) => {
Expand All @@ -35,5 +35,5 @@ export const UserGuard = ({ children }: UserGuardProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [checkUser, isError]);

return children;
return <Suspense>{children}</Suspense>;
};

0 comments on commit 1b66f69

Please sign in to comment.