@@ -6,6 +6,8 @@ import { Button, Header } from "@compasser/design-system";
66import type {
77 StoreUpdateReqDTO ,
88 StoreLocationUpdateReqDTO ,
9+ StoreTag ,
10+ BankType ,
911} from "@compasser/api" ;
1012
1113import StoreNameField from "@/app/signup/register/_components/fields/StoreNameField" ;
@@ -18,13 +20,14 @@ import PhotoUploadSection from "@/app/signup/register/_components/sections/Photo
1820import TagSection from "@/app/signup/register/_components/sections/TagSection" ;
1921import BusinessHoursModal from "@/app/signup/register/_components/modals/BusinessHoursModal" ;
2022import RandomBoxModal from "@/app/signup/register/_components/modals/RandomBoxModal" ;
23+ import AddressSearchBottomSheet from "@/app/signup/register/_components/AddressSearchBottomSheet" ;
24+ import type { AddressSearchItem } from "@/app/signup/register/_types/address-search" ;
2125
2226import { useMyStoreQuery } from "@/shared/queries/query/useMyStoreQuery" ;
2327import { usePatchMyStoreMutation } from "@/shared/queries/mutation/auth/usePatchMyStoreMutation" ;
2428import { usePatchMyStoreLocationMutation } from "@/shared/queries/mutation/auth/usePatchMyStoreLocationMutation" ;
2529import { useRandomBoxListQuery } from "@/shared/queries/query/useRandomBoxListQuery" ;
2630import { useCreateRandomBoxMutation } from "@/shared/queries/mutation/auth/useCreateRandomBoxMutation" ;
27- import { useUpdateRandomBoxMutation } from "@/shared/queries/mutation/auth/useUpdateRandomBoxMutation" ;
2831import { useDeleteRandomBoxMutation } from "@/shared/queries/mutation/auth/useDeleteRandomBoxMutation" ;
2932import { useStoreImageQuery } from "@/shared/queries/query/useStoreImageQuery" ;
3033import { useUploadStoreImageMutation } from "@/shared/queries/mutation/auth/useUploadStoreImageMutation" ;
@@ -35,7 +38,21 @@ import {
3538 EMPTY_BUSINESS_HOURS ,
3639} from "@/app/signup/register/_utils/business-hours" ;
3740
38- type FixedTag = "카페" | "베이커리" | "식당" ;
41+ const tagOptions = [ "카페" , "베이커리" , "식당" ] as const ;
42+
43+ type TagLabel = ( typeof tagOptions ) [ number ] ;
44+
45+ const tagMap : Record < TagLabel , StoreTag > = {
46+ 카페 : "CAFE" ,
47+ 베이커리 : "BAKERY" ,
48+ 식당 : "RESTAURANT" ,
49+ } ;
50+
51+ const reverseTagMap : Record < StoreTag , TagLabel > = {
52+ CAFE : "카페" ,
53+ BAKERY : "베이커리" ,
54+ RESTAURANT : "식당" ,
55+ } ;
3956
4057export default function StoreInfoEditPage ( ) {
4158 const router = useRouter ( ) ;
@@ -49,54 +66,39 @@ export default function StoreInfoEditPage() {
4966 const patchMyStoreMutation = usePatchMyStoreMutation ( ) ;
5067 const patchMyStoreLocationMutation = usePatchMyStoreLocationMutation ( ) ;
5168 const createRandomBoxMutation = useCreateRandomBoxMutation ( ) ;
52- const updateRandomBoxMutation = useUpdateRandomBoxMutation ( ) ;
5369 const deleteRandomBoxMutation = useDeleteRandomBoxMutation ( ) ;
5470 const uploadStoreImageMutation = useUploadStoreImageMutation ( ) ;
5571 const removeStoreImageMutation = useRemoveStoreImageMutation ( ) ;
5672
5773 const [ storeName , setStoreName ] = useState ( "" ) ;
5874 const [ storeEmail , setStoreEmail ] = useState ( "" ) ;
5975 const [ inputAddress , setInputAddress ] = useState ( "" ) ;
60- const [ bankName , setBankName ] = useState ( "" ) ;
76+ const [ bankType , setBankType ] = useState < BankType | "" > ( "" ) ;
6177 const [ depositor , setDepositor ] = useState ( "" ) ;
6278 const [ bankAccount , setBankAccount ] = useState ( "" ) ;
6379 const [ businessHours , setBusinessHours ] = useState ( EMPTY_BUSINESS_HOURS ) ;
6480
65- const tagOptions : FixedTag [ ] = [ "카페" , "베이커리" , "식당" ] ;
66- const [ selectedTag , setSelectedTag ] = useState < FixedTag | "" > ( "" ) ;
67-
68- const [ selectedRandomBoxIds , setSelectedRandomBoxIds ] = useState < number [ ] > (
69- [ ] ,
70- ) ;
71- const [ isBusinessHoursModalOpen , setIsBusinessHoursModalOpen ] =
72- useState ( false ) ;
81+ const [ selectedTag , setSelectedTag ] = useState < "" | TagLabel > ( "" ) ;
82+ const [ selectedRandomBoxIds , setSelectedRandomBoxIds ] = useState < number [ ] > ( [ ] ) ;
83+ const [ isBusinessHoursModalOpen , setIsBusinessHoursModalOpen ] = useState ( false ) ;
7384 const [ isRandomBoxModalOpen , setIsRandomBoxModalOpen ] = useState ( false ) ;
85+ const [ isAddressSearchOpen , setIsAddressSearchOpen ] = useState ( false ) ;
7486
7587 const [ photoFile , setPhotoFile ] = useState < File | null > ( null ) ;
7688 const [ photoPreviewUrl , setPhotoPreviewUrl ] = useState ( "" ) ;
7789 const [ imageRemoved , setImageRemoved ] = useState ( false ) ;
7890
79- const mapStoreTagToLabel = ( tag : string | undefined ) : FixedTag | "" => {
80- switch ( tag ) {
81- case "CAFE" :
82- return "카페" ;
83- case "BAKERY" :
84- return "베이커리" ;
85- case "RESTAURANT" :
86- return "식당" ;
87- default :
88- return "" ;
89- }
90- } ;
91-
9291 useEffect ( ( ) => {
9392 if ( ! myStore ) return ;
9493
9594 setStoreName ( myStore . storeName ?? "" ) ;
96- setStoreEmail ( "" ) ;
95+ setStoreEmail ( myStore . storeEmail ?? "" ) ;
9796 setInputAddress ( myStore . inputAddress ?? "" ) ;
9897 setBusinessHours ( parseBusinessHours ( myStore . businessHours ) ) ;
99- setSelectedTag ( mapStoreTagToLabel ( myStore . tag ) ) ;
98+
99+ if ( myStore . tag ) {
100+ setSelectedTag ( reverseTagMap [ myStore . tag as StoreTag ] ?? "" ) ;
101+ }
100102 } , [ myStore ] ) ;
101103
102104 useEffect ( ( ) => {
@@ -105,6 +107,16 @@ export default function StoreInfoEditPage() {
105107 } , [ storeImage , imageRemoved ] ) ;
106108
107109 const businessHoursRows = useMemo ( ( ) => {
110+ const dayKeyMap = {
111+ mon : "MON" ,
112+ tue : "TUE" ,
113+ wed : "WED" ,
114+ thu : "THU" ,
115+ fri : "FRI" ,
116+ sat : "SAT" ,
117+ sun : "SUN" ,
118+ } as const ;
119+
108120 const dayLabelMap = {
109121 mon : "월" ,
110122 tue : "화" ,
@@ -115,19 +127,14 @@ export default function StoreInfoEditPage() {
115127 sun : "일" ,
116128 } as const ;
117129
118- const orderedDays = [
119- "mon" ,
120- "tue" ,
121- "wed" ,
122- "thu" ,
123- "fri" ,
124- "sat" ,
125- "sun" ,
126- ] as const ;
130+ const orderedDays = [ "mon" , "tue" , "wed" , "thu" , "fri" , "sat" , "sun" ] as const ;
127131
128132 return orderedDays . map ( ( day ) => {
129- const value = businessHours [ day ] ;
130- const formatted = value === "closed" ? "휴무" : value || "-" ;
133+ const value = businessHours . weekly [ dayKeyMap [ day ] ] ;
134+
135+ const formatted = value . closed
136+ ? "휴무"
137+ : `${ value . open || "-" } - ${ value . close || "-" } ` ;
131138
132139 return {
133140 dayLabel : dayLabelMap [ day ] ,
@@ -136,6 +143,11 @@ export default function StoreInfoEditPage() {
136143 } ) ;
137144 } , [ businessHours ] ) ;
138145
146+ const handleSelectAddress = ( item : AddressSearchItem ) => {
147+ setInputAddress ( item . roadAddress || item . lotNumberAddress || item . label ) ;
148+ setIsAddressSearchOpen ( false ) ;
149+ } ;
150+
139151 const toggleRandomBoxSelection = ( id : number ) => {
140152 setSelectedRandomBoxIds ( ( prev ) =>
141153 prev . includes ( id ) ? prev . filter ( ( item ) => item !== id ) : [ ...prev , id ] ,
@@ -160,25 +172,13 @@ export default function StoreInfoEditPage() {
160172 price : number ;
161173 buyLimit : number ;
162174 content : string ;
163- boxId ?: number ;
175+ pickupTimeInfo : {
176+ start : string ;
177+ end : string ;
178+ } ;
164179 } ) => {
165180 if ( ! storeId ) return ;
166181
167- if ( form . boxId ) {
168- await updateRandomBoxMutation . mutateAsync ( {
169- storeId,
170- boxId : form . boxId ,
171- body : {
172- boxName : form . boxName ,
173- stock : form . stock ,
174- price : form . price ,
175- buyLimit : form . buyLimit ,
176- content : form . content ,
177- } ,
178- } ) ;
179- return ;
180- }
181-
182182 await createRandomBoxMutation . mutateAsync ( {
183183 storeId,
184184 body : {
@@ -187,6 +187,7 @@ export default function StoreInfoEditPage() {
187187 price : form . price ,
188188 buyLimit : form . buyLimit ,
189189 content : form . content ,
190+ pickupTimeInfo : form . pickupTimeInfo ,
190191 } ,
191192 } ) ;
192193 } ;
@@ -218,10 +219,11 @@ export default function StoreInfoEditPage() {
218219 const storePayload : StoreUpdateReqDTO = {
219220 storeName,
220221 storeEmail,
221- bankName ,
222+ bankType : bankType || undefined ,
222223 depositor,
223224 bankAccount,
224225 businessHours,
226+ tag : selectedTag ? tagMap [ selectedTag ] : undefined ,
225227 } ;
226228
227229 const locationPayload : StoreLocationUpdateReqDTO = {
@@ -256,17 +258,18 @@ export default function StoreInfoEditPage() {
256258 < div className = "pb-[3.6rem] pt-[1.6rem]" >
257259 < StoreNameField value = { storeName } onChange = { setStoreName } />
258260 < EmailField value = { storeEmail } onChange = { setStoreEmail } />
261+
259262 < StoreAddressField
260263 value = { inputAddress }
261264 onChange = { setInputAddress }
262- onSearchAddress = { ( ) => { } }
265+ onSearchAddress = { ( ) => setIsAddressSearchOpen ( true ) }
263266 />
264267
265268 < AccountField
266- bankName = { bankName }
269+ bankType = { bankType }
267270 depositor = { depositor }
268271 bankAccount = { bankAccount }
269- onChangeBankName = { setBankName }
272+ onChangeBankType = { ( value ) => setBankType ( value as BankType ) }
270273 onChangeDepositor = { setDepositor }
271274 onChangeBankAccount = { setBankAccount }
272275 />
@@ -293,7 +296,7 @@ export default function StoreInfoEditPage() {
293296 />
294297
295298 < TagSection
296- tagOptions = { tagOptions }
299+ tagOptions = { [ ... tagOptions ] }
297300 selectedTag = { selectedTag }
298301 onSelectTag = { setSelectedTag }
299302 />
@@ -326,6 +329,12 @@ export default function StoreInfoEditPage() {
326329 onClose = { ( ) => setIsRandomBoxModalOpen ( false ) }
327330 onSubmit = { handleSubmitRandomBox }
328331 />
332+
333+ < AddressSearchBottomSheet
334+ open = { isAddressSearchOpen }
335+ onClose = { ( ) => setIsAddressSearchOpen ( false ) }
336+ onSelectAddress = { handleSelectAddress }
337+ />
329338 </ >
330339 ) ;
331340}
0 commit comments