File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import SizeText from "@/components/archive-detail/SizeText";
1313import { useCreateChatRoom } from "@/hooks/useCreateChatRoom" ;
1414import { getArtworkDetail } from "@/services/artworks" ;
1515import { normalizeImageUrl } from "@/utils/normalizeImageUrl" ;
16+ import { useRequireAuth } from "@/hooks/useRequireAuth" ;
1617
1718function formatDate ( date : string | null ) {
1819 if ( ! date ) return "-" ;
@@ -32,6 +33,7 @@ export default function ArtDetailPage() {
3233 const params = useParams < { id : string } > ( ) ;
3334 const artworkId = params . id ;
3435 const createChatRoom = useCreateChatRoom ( ) ;
36+ const { isAuthReady, isAuthenticated } = useRequireAuth ( "/auth" ) ;
3537 const [ inquiryErrorMessage , setInquiryErrorMessage ] = useState < string | null > ( null ) ;
3638
3739 const query = useQuery ( {
@@ -56,6 +58,8 @@ export default function ArtDetailPage() {
5658 const handleInquiryClick = ( ) => {
5759 if ( ! Number . isFinite ( numericArtworkId ) ) return ;
5860
61+ if ( ! isAuthReady || ! isAuthenticated ) return ;
62+
5963 setInquiryErrorMessage ( null ) ;
6064 createChatRoom . mutate (
6165 { targetType : "ARTWORK" , targetId : numericArtworkId } ,
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ export default function LoginPage() {
1010 const router = useRouter ( ) ;
1111
1212 const handleClose = ( ) => {
13- router . push ( "/" ) ;
13+ if ( window . history . length > 1 ) {
14+ router . back ( ) ;
15+ } else {
16+ router . push ( "/" ) ;
17+ }
1418 } ;
1519
1620 return (
Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ import type { ReactNode } from "react" ;
4+
5+ import { useRequireAuth } from "@/hooks/useRequireAuth" ;
6+
7+ interface ChatLayoutProps {
8+ children : ReactNode ;
9+ }
10+
11+ export default function ChatLayout ( { children } : ChatLayoutProps ) {
12+ const { isAuthReady, isAuthenticated } = useRequireAuth ( "/auth" ) ;
13+
14+ if ( ! isAuthReady || ! isAuthenticated ) {
15+ return null ;
16+ }
17+
18+ return children ;
19+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import SizeText from "@/components/archive-detail/SizeText";
1212import { useCreateChatRoom } from "@/hooks/useCreateChatRoom" ;
1313import { getSpaceDetail } from "@/services/spaces" ;
1414import { normalizeImageUrl } from "@/utils/normalizeImageUrl" ;
15+ import { useRequireAuth } from "@/hooks/useRequireAuth" ;
1516
1617function hasText ( value ?: string | null ) {
1718 return Boolean ( value ?. trim ( ) ) ;
@@ -26,6 +27,7 @@ export default function SpaceDetailPage() {
2627 const params = useParams < { id : string } > ( ) ;
2728 const spaceId = params . id ;
2829 const createChatRoom = useCreateChatRoom ( ) ;
30+ const { isAuthReady, isAuthenticated } = useRequireAuth ( "/auth" ) ;
2931 const [ inquiryErrorMessage , setInquiryErrorMessage ] = useState < string | null > ( null ) ;
3032
3133 const query = useQuery ( {
@@ -51,6 +53,8 @@ export default function SpaceDetailPage() {
5153 const handleInquiryClick = ( ) => {
5254 if ( ! Number . isFinite ( numericSpaceId ) ) return ;
5355
56+ if ( ! isAuthReady || ! isAuthenticated ) return ;
57+
5458 setInquiryErrorMessage ( null ) ;
5559 createChatRoom . mutate (
5660 { targetType : "SPACE" , targetId : numericSpaceId } ,
You can’t perform that action at this time.
0 commit comments