1- // app/(main)/calendar/new/page.tsx
21'use client' ;
32
43import { STICKER_SRC } from '@/components/calendar/stickers' ;
@@ -13,33 +12,57 @@ import { useMemo, useState } from 'react';
1312
1413type StickerKey = keyof typeof STICKER_SRC ;
1514
15+ const ICON_CFG : Record <
16+ StickerKey ,
17+ { w : number ; h : number ; className ?: string }
18+ > = {
19+ INVITATION : {
20+ w : 60 ,
21+ h : 62 ,
22+ className :
23+ 'origin-top-left rotate-[-30.22deg] -translate-x-4 translate-y-7' ,
24+ } ,
25+ STUDIO : { w : 50 , h : 46 } ,
26+ WEDDING_HALL : { w : 46 , h : 46 , className : 'translate-y-0.5' } ,
27+ DRESS : { w : 40 , h : 50 } ,
28+ PARTY : { w : 51 , h : 61 } ,
29+ BRIDAL_SHOWER : { w : 61 , h : 61 } ,
30+ MAKEUP : { w : 33 , h : 47 } ,
31+ } ;
32+
1633export default function CalendarNewPage ( ) {
1734 const router = useRouter ( ) ;
1835 const [ title , setTitle ] = useState ( '' ) ;
1936 const [ titleStarted , setTitleStarted ] = useState ( false ) ;
2037 const [ memo , setMemo ] = useState ( '' ) ;
2138 const [ sticker , setSticker ] = useState < StickerKey | null > ( null ) ;
39+ const [ loading , setLoading ] = useState ( false ) ;
2240
2341 const disabled = ! title . trim ( ) || ! sticker ;
2442
2543 const stickers : StickerKey [ ] = useMemo (
26- ( ) => [ 'INVITATION' , 'STUDIO' , 'WEDDING_HALL' , 'DRESS' , 'PARTY' , 'BRIDAL_SHOWER' , 'MAKEUP' ] ,
44+ ( ) => [
45+ 'INVITATION' ,
46+ 'STUDIO' ,
47+ 'WEDDING_HALL' ,
48+ 'DRESS' ,
49+ 'PARTY' ,
50+ 'BRIDAL_SHOWER' ,
51+ 'MAKEUP' ,
52+ ] ,
2753 [ ] ,
2854 ) ;
2955
30- const [ loading , setLoading ] = useState ( false ) ;
31-
3256 const onSubmit = async ( e : React . FormEvent ) => {
3357 e . preventDefault ( ) ;
3458 if ( disabled || ! sticker ) return ;
35-
3659 try {
3760 setLoading ( true ) ;
3861 await createCalendarEvent ( {
3962 title,
4063 description : memo ,
41- eventCategory : sticker . toUpperCase ( ) , // μλ² enumμ΄ 'LETTER' κ°μ UPPERCASEλΌλ©΄ λ³ν νμ
42- startDateTime : new Date ( ) . toISOString ( ) , // TODO: λ μ§ μ ν κΈ°λ₯ λΆμ΄λ©΄ κ΅μ²΄
64+ eventCategory : sticker . toUpperCase ( ) ,
65+ startDateTime : new Date ( ) . toISOString ( ) ,
4366 endDateTime : new Date ( ) . toISOString ( ) ,
4467 isAllDay : true ,
4568 } ) ;
@@ -54,8 +77,11 @@ export default function CalendarNewPage() {
5477
5578 return (
5679 < main className = "mx-auto w-full max-w-[420px]" >
57- < Header showBack onBack = { ( ) => router . push ( '/calendar' ) } value = "μΌμ λ±λ‘νκΈ°" />
58-
80+ < Header
81+ showBack
82+ onBack = { ( ) => router . push ( '/calendar' ) }
83+ value = "μΌμ λ±λ‘νκΈ°"
84+ />
5985 < form onSubmit = { onSubmit } className = "px-[22px] pb-8" >
6086 < Input
6187 type = { titleStarted ? 'defaultStrong' : 'default' }
@@ -75,33 +101,37 @@ export default function CalendarNewPage() {
75101 onChange = { setMemo }
76102 placeholder = "κΈ°μ΅νκ³ μΆμ λ΄μ©μ μ μ΄μ£ΌμΈμ."
77103 className = "mt-3 w-full"
78- textareaClassName = "text-[14px]"
104+ textareaClassName = "! text-[14px]"
79105 showCount
80106 />
81107 < div className = "mt-5 grid grid-cols-4 gap-2" >
82108 { stickers . map ( ( key ) => {
83109 const active = sticker === key ;
110+ const { w, h, className } = ICON_CFG [ key ] ;
84111 return (
85112 < button
86113 key = { key }
87114 type = "button"
88115 onClick = { ( ) => setSticker ( key ) }
116+ aria-pressed = { active }
117+ aria-label = { key }
89118 className = { clsx (
90- 'h-18 w-18 rounded-xl border bg-white transition' ,
119+ 'relative h-20 w-20 rounded-xl border bg-white transition' ,
91120 active
92121 ? 'border-primary-400 ring-2 ring-primary-200'
93122 : 'border-gray-200 hover:bg-gray-50 active:scale-[0.98]' ,
94123 ) }
95- aria-pressed = { active }
96124 >
97- < Image
98- src = { STICKER_SRC [ key ] }
99- alt = { key }
100- width = { 35 }
101- height = { 35 }
102- className = "mx-auto"
103- draggable = { false }
104- />
125+ < span className = "absolute inset-0 grid place-items-center" >
126+ < Image
127+ src = { STICKER_SRC [ key ] }
128+ alt = { key }
129+ width = { w }
130+ height = { h }
131+ draggable = { false }
132+ className = { clsx ( 'pointer-events-none' , className ) }
133+ />
134+ </ span >
105135 </ button >
106136 ) ;
107137 } ) }
@@ -110,9 +140,9 @@ export default function CalendarNewPage() {
110140 type = "submit"
111141 disabled = { disabled || loading }
112142 className = { clsx (
113- 'mt-8 h-12 w-full rounded-2xl text-[15px] font-semibold transition' ,
143+ 'mt-50 h-12 w-full rounded-2xl text-[15px] font-semibold transition' ,
114144 disabled || loading
115- ? 'bg-primary-200 text-rose-300 cursor-not-allowed'
145+ ? 'bg-primary-200/40 text-rose-300 cursor-not-allowed'
116146 : 'bg-primary-500 text-white active:scale-[0.98]' ,
117147 ) }
118148 >
0 commit comments