1+ import { Badge } from '@/components/ui/badge' ;
12import { Button } from '@/components/ui/button' ;
23import { Checkbox } from '@/components/ui/checkbox' ;
34import {
@@ -10,7 +11,9 @@ import {
1011} from '@/components/ui/table' ;
1112import { ROUTES } from '@/constants/route' ;
1213import useChecked from '@/hooks/useChecked' ;
14+ import { useCheckedStore } from '@/stores/checkedStore' ;
1315import { IProjectProps } from '@/types/project' ;
16+ import { convertDateFormat } from '@/utils/date' ;
1417import { SquareArrowOutUpRightIcon } from 'lucide-react' ;
1518import { useEffect , useState } from 'react' ;
1619import { NavigateFunction , useNavigate } from 'react-router-dom' ;
@@ -37,6 +40,8 @@ const ListView = ({ option = 'list', data }: Omit<IListViewProps, 'navi'>) => {
3740} ;
3841
3942const List = ( { data, navi } : IListViewProps ) => {
43+ const { addChecked, removeChecked, removeAll } = useCheckedStore ( ) ;
44+
4045 const [ items , setItems ] = useState < IProjectProps [ ] > ( ( ) => {
4146 const initialData = data || [ ] ;
4247 return initialData . map ( ( item ) => ( { ...item , checked : false } ) ) ;
@@ -47,10 +52,10 @@ const List = ({ data, navi }: IListViewProps) => {
4752 const handleCheckboxChange = ( id : number ) : void => {
4853 setItems (
4954 items . map ( ( item ) => {
50- if ( item . projectId === id ) {
55+ if ( item . projectSeq === id ) {
5156 handleCheckedList . set ( id ) ;
5257 }
53- return item . projectId === id
58+ return item . projectSeq === id
5459 ? { ...item , checked : ! item . checked }
5560 : item ;
5661 } )
@@ -65,7 +70,7 @@ const List = ({ data, navi }: IListViewProps) => {
6570 } ) )
6671 ) ;
6772 ! masterChecked
68- ? handleCheckedList . addAll ( items . map ( ( item ) => item . projectId ) )
73+ ? handleCheckedList . addAll ( items . map ( ( item ) => item . projectSeq ) )
6974 : handleCheckedList . removeAll ( ) ;
7075 } ;
7176
@@ -74,10 +79,14 @@ const List = ({ data, navi }: IListViewProps) => {
7479 setMasterChecked ( allChecked ) ;
7580 } , [ items ] ) ;
7681
77- const onTest = ( ) => {
78- alert ( `삭제요청 리스트: ${ checkedList } ` ) ;
79- // 삭제요청 API 호출
80- } ;
82+ useEffect ( ( ) => {
83+ const currentChecked = new Set ( checkedList ) ;
84+ // 한 번의 업데이트로 처리
85+ useCheckedStore . setState ( ( state ) => ( {
86+ ...state ,
87+ checkedList : Array . from ( currentChecked ) ,
88+ } ) ) ;
89+ } , [ checkedList ] ) ;
8190
8291 return (
8392 < div >
@@ -87,31 +96,53 @@ const List = ({ data, navi }: IListViewProps) => {
8796 < TableHead className = 'w-10' >
8897 < Checkbox onClick = { handleSelectAll } checked = { masterChecked } />
8998 </ TableHead >
90- < TableHead className = 'w-[50%]' > Name</ TableHead >
91- < TableHead > Last modified</ TableHead >
92- < TableHead > Created</ TableHead >
99+ < TableHead className = 'w-[50%]' > 프로젝트 명</ TableHead >
100+ < TableHead > 작업목록</ TableHead >
101+ < TableHead > 수정일</ TableHead >
102+ < TableHead > 생성일</ TableHead >
93103 < TableHead > 바로가기</ TableHead >
94104 </ TableRow >
95105 </ TableHeader >
96106 < TableBody >
97107 { items . map ( ( item , idx ) => {
98108 return (
99- < TableRow key = { item . name + idx } >
109+ < TableRow key = { item . projectName + idx } >
100110 < TableCell >
101111 < Checkbox
102112 onClick = { ( ) => {
103- handleCheckboxChange ( item . projectId ) ;
113+ handleCheckboxChange ( item . projectSeq ) ;
104114 } }
105115 checked = { item . checked }
106116 />
107117 </ TableCell >
108- < TableCell className = 'font-medium' > { item . name } </ TableCell >
109- < TableCell > { item . modDate } </ TableCell >
110- < TableCell > { item . regDate } </ TableCell >
118+ < TableCell className = 'font-medium' >
119+ { item . projectName }
120+ </ TableCell >
121+ < TableCell className = 'flex gap-1' >
122+ { item . tts ? < Badge variant = { 'outline' } > TTS</ Badge > : < > </ > }
123+ { item . vc ? < Badge variant = { 'destructive' } > VC</ Badge > : < > </ > }
124+ { item . concat ? (
125+ < Badge variant = { 'default' } > Concat</ Badge >
126+ ) : (
127+ < > </ >
128+ ) }
129+ </ TableCell >
130+ < TableCell >
131+ { convertDateFormat (
132+ new Date ( item . projectUpdateDate ) ,
133+ 'YYYY-MM-DD hh:mm:ss'
134+ ) }
135+ </ TableCell >
136+ < TableCell >
137+ { convertDateFormat (
138+ new Date ( item . projectDate ) ,
139+ 'YYYY-MM-DD hh:mm:ss'
140+ ) }
141+ </ TableCell >
111142 < TableCell
112143 className = 'hover:cursor-pointer'
113144 onClick = { ( ) => {
114- navi ( ROUTES . PROJECT + ROUTES . TTS + `/${ item . projectId } ` ) ;
145+ navi ( ROUTES . PROJECT + ROUTES . TTS + `/${ item . projectSeq } ` ) ;
115146 } }
116147 >
117148 < SquareArrowOutUpRightIcon />
@@ -121,13 +152,6 @@ const List = ({ data, navi }: IListViewProps) => {
121152 } ) }
122153 </ TableBody >
123154 </ Table >
124- { checkedList . length > 0 ? (
125- < Button variant = { 'destructive' } onClick = { onTest } >
126- 삭제하기
127- </ Button >
128- ) : (
129- < > </ >
130- ) }
131155 </ div >
132156 ) ;
133157} ;
@@ -138,27 +162,27 @@ const Tile = ({ data, navi }: IListViewProps) => {
138162 } ;
139163 return (
140164 < div >
141- < ul className = 'flex flex-wrap flex-1' >
165+ < ul className = 'flex flex-wrap flex-1 gap-5 ' >
142166 { data ? (
143167 data . map ( ( item , idx ) => (
144168 < li
145- key = { item . name + idx }
146- className = 'p-5 m-5 w-[30%] border hover:cursor-pointer hover:scale-95 duration-100 rounded-lg z-10'
169+ key = { item . projectName + idx }
170+ className = 'p-5 w-[30%] border hover:cursor-pointer hover:scale-95 duration-100 rounded-lg z-10'
147171 onClick = { ( ) => {
148- navi ( ROUTES . PROJECT + ROUTES . TTS + `/${ item . projectId } ` ) ;
172+ navi ( ROUTES . PROJECT + ROUTES . TTS + `/${ item . projectSeq } ` ) ;
149173 } }
150174 >
151- < Checkbox
175+ { /* <Checkbox
152176 className='relative z-0 hover:bg-neutral-100'
153177 onClick={(
154178 e: React.MouseEvent<HTMLInputElement, MouseEvent>
155179 ) => {
156180 e.stopPropagation();
157181 onTest(e);
158182 }}
159- />
183+ /> */ }
160184 < div className = 'content-center h-40 text-center' > 썸네일</ div >
161- < div > { item . name } </ div >
185+ < div > { item . projectName } </ div >
162186 </ li >
163187 ) )
164188 ) : (
0 commit comments