1- import { useCallback , useMemo , useRef } from "react" ;
1+ import { useCallback , useMemo , useRef , useEffect } from "react" ;
22
33import { useNavigate } from "react-router-dom" ;
44
@@ -7,7 +7,9 @@ import EmptyStateCard from "@/components/EmptyStateCard";
77import PostCard from "@/components/Post/PostCard" ;
88import PostList from "@/components/Post/PostList" ;
99import { ROUTES } from "@/constants/router" ;
10+ import { useUserStore } from "@/hooks/useUserStore" ;
1011import { useShopData } from "@/pages/ShopPage/hooks/useShopData" ;
12+ import { useModalStore } from "@/store/useModalStore" ;
1113
1214export interface PostListItem {
1315 id : string ;
@@ -24,6 +26,8 @@ export interface PostListItem {
2426
2527export default function ShopPage ( ) {
2628 const navigate = useNavigate ( ) ;
29+ const { openModal, closeModal } = useModalStore ( ) ;
30+ const { user } = useUserStore ( ) ;
2731
2832 const {
2933 shop,
@@ -36,6 +40,46 @@ export default function ShopPage() {
3640 LIMIT ,
3741 } = useShopData ( ) ;
3842
43+ useEffect ( ( ) => {
44+ if ( ! user ) {
45+ openModal ( {
46+ type : "alert" ,
47+ message : "로그인 후에 이용 가능한 기능입니다." ,
48+ iconType : "warning" ,
49+ buttons : [
50+ {
51+ label : "확인" ,
52+ style : "white" ,
53+ onClick : ( ) => {
54+ closeModal ( ) ;
55+ } ,
56+ } ,
57+ ] ,
58+ onClose : ( ) => {
59+ navigate ( ROUTES . AUTH . SIGNIN ) ;
60+ } ,
61+ } ) ;
62+ } else if ( user . type === "employee" ) {
63+ openModal ( {
64+ type : "alert" ,
65+ message : "사장님 계정으로만 이용 가능한 기능입니다." ,
66+ iconType : "warning" ,
67+ buttons : [
68+ {
69+ label : "확인" ,
70+ style : "white" ,
71+ onClick : ( ) => {
72+ closeModal ( ) ;
73+ } ,
74+ } ,
75+ ] ,
76+ onClose : ( ) => {
77+ navigate ( ROUTES . PROFILE . ROOT ) ;
78+ } ,
79+ } ) ;
80+ }
81+ } , [ user , openModal , closeModal , navigate ] ) ;
82+
3983 const observer = useRef < IntersectionObserver | null > ( null ) ;
4084
4185 const postListData : PostListItem [ ] = useMemo ( ( ) => {
@@ -44,7 +88,7 @@ export default function ShopPage() {
4488 return [ ...notices ]
4589 . sort (
4690 ( a , b ) =>
47- new Date ( b . startsAt ) . getTime ( ) - new Date ( a . startsAt ) . getTime ( ) ,
91+ new Date ( a . startsAt ) . getTime ( ) - new Date ( b . startsAt ) . getTime ( ) ,
4892 )
4993 . map ( ( notice ) => ( {
5094 id : notice . id ,
@@ -79,7 +123,7 @@ export default function ShopPage() {
79123
80124 return (
81125 < >
82- < section className = "xl :w-[60.25rem] xl :mx-auto px-6 xl :px-[0px] py-[3.75rem]" >
126+ < section className = "lg :w-[60.25rem] lg :mx-auto px-6 lg :px-[0px] py-[3.75rem]" >
83127 < h1 className = "text-[1.75rem] font-bold mb-6" > 내 가게</ h1 >
84128 { isShopLoading ? null : ! shop ? (
85129 < EmptyStateCard
@@ -90,6 +134,11 @@ export default function ShopPage() {
90134 ) : (
91135 < PostCard
92136 { ...shop }
137+ description = {
138+ shop . description && shop . description . trim ( ) !== ""
139+ ? shop . description
140+ : "등록된 가게 정보가 없습니다"
141+ }
93142 isShopInfo = { true }
94143 backgroundColor = "bg-red-10"
95144 buttons = {
@@ -117,7 +166,7 @@ export default function ShopPage() {
117166
118167 { shop && (
119168 < section className = "flex-1 bg-gray-5" >
120- < div className = "xl :w-[60.25rem] mx-auto px-6 xl :px-[0px] pt-[3.75rem] pb-[7.5rem]" >
169+ < div className = "lg :w-[60.25rem] mx-auto px-6 lg :px-[0px] pt-[3.75rem] pb-[7.5rem]" >
121170 < h1 className = "text-[1.75rem] font-bold mb-8" > 등록한 공고</ h1 >
122171
123172 { isNoticeLoading ? null : notices . length === 0 ? (
0 commit comments