@@ -3,7 +3,7 @@ import { TextArea } from "@/component/common/input";
33import { Icon } from "@/component/common/Icon" ;
44import { Typography } from "@/component/common/typography" ;
55import { css } from "@emotion/react" ;
6- import { useState , useEffect } from "react" ;
6+ import { useState , useEffect , useMemo } from "react" ;
77import { DESIGN_TOKEN_COLOR } from "@/style/designTokens" ;
88import { useQuery , useQueryClient } from "@tanstack/react-query" ;
99import { useApiOptionsGetRetrospects } from "@/hooks/api/retrospect/useApiOptionsGetRetrospects" ;
@@ -21,7 +21,10 @@ export default function ActionItemAddSection({ spaceId, onClose }: ActionItemAdd
2121 const queryClient = useQueryClient ( ) ;
2222
2323 const { toast } = useToast ( ) ;
24- const { data : retrospectOptions } = useQuery ( useApiOptionsGetRetrospects ( spaceId ) ) ;
24+ const { data : retrospects } = useQuery ( useApiOptionsGetRetrospects ( spaceId ) ) ;
25+
26+ // * 마감된 회고 필터링
27+ const completedRetrospects = useMemo ( ( ) => retrospects ?. filter ( ( retrospect ) => retrospect . retrospectStatus === "DONE" ) || [ ] , [ retrospects ] ) ;
2528
2629 const [ selectedRetrospect , setSelectedRetrospect ] = useState < Retrospect > ( ) ;
2730 const [ content , setContent ] = useState < string > ( "" ) ;
@@ -59,8 +62,8 @@ export default function ActionItemAddSection({ spaceId, onClose }: ActionItemAdd
5962 const handleCancel = ( ) => {
6063 onClose ( ) ;
6164
62- if ( retrospectOptions && retrospectOptions . length > 0 ) {
63- setSelectedRetrospect ( retrospectOptions [ 0 ] ) ;
65+ if ( completedRetrospects . length > 0 ) {
66+ setSelectedRetrospect ( completedRetrospects [ 0 ] ) ;
6467 }
6568
6669 setContent ( "" ) ;
@@ -112,10 +115,10 @@ export default function ActionItemAddSection({ spaceId, onClose }: ActionItemAdd
112115 } ;
113116
114117 useEffect ( ( ) => {
115- if ( retrospectOptions && retrospectOptions . length > 0 && ! selectedRetrospect ) {
116- setSelectedRetrospect ( retrospectOptions [ 0 ] ) ;
118+ if ( completedRetrospects . length > 0 && ! selectedRetrospect ) {
119+ setSelectedRetrospect ( completedRetrospects [ 0 ] ) ;
117120 }
118- } , [ retrospectOptions , selectedRetrospect ] ) ;
121+ } , [ completedRetrospects , selectedRetrospect ] ) ;
119122
120123 return (
121124 < >
@@ -205,55 +208,54 @@ export default function ActionItemAddSection({ spaceId, onClose }: ActionItemAdd
205208 }
206209 ` }
207210 >
208- { retrospectOptions &&
209- retrospectOptions . map ( ( option , index ) => (
210- < div
211- key = { index }
212- onClick = { ( ) => handleRetrospectSelect ( option ) }
213- css = { css `
214- align-content : center;
215- height : 4.2rem ;
216- padding : 0.8rem 2rem ;
217- cursor : pointer;
218-
219- /* 순차적 애니메이션 효과 */
220- animation : ${ isClosing ? "itemFadeOut" : "itemFadeIn" } 0.15s ease-out;
221- animation-delay : ${ isClosing ? ( retrospectOptions . length - index - 1 ) * 0.03 : index * 0.05 } s;
222- animation-fill-mode : both;
223-
224- @keyframes itemFadeIn {
225- from {
226- opacity : 0 ;
227- transform : translateY (-5px );
228- }
229- to {
230- opacity : 1 ;
231- transform : translateY (0 );
232- }
211+ { completedRetrospects . map ( ( option , index ) => (
212+ < div
213+ key = { index }
214+ onClick = { ( ) => handleRetrospectSelect ( option ) }
215+ css = { css `
216+ align-content : center;
217+ height : 4.2rem ;
218+ padding : 0.8rem 2rem ;
219+ cursor : pointer;
220+
221+ /* 순차적 애니메이션 효과 */
222+ animation : ${ isClosing ? "itemFadeOut" : "itemFadeIn" } 0.15s ease-out;
223+ animation-delay : ${ isClosing ? ( completedRetrospects . length - index - 1 ) * 0.03 : index * 0.05 } s;
224+ animation-fill-mode : both;
225+
226+ @keyframes itemFadeIn {
227+ from {
228+ opacity : 0 ;
229+ transform : translateY (-5px );
233230 }
234-
235- @keyframes itemFadeOut {
236- from {
237- opacity : 1 ;
238- transform : translateY (0 );
239- }
240- to {
241- opacity : 0 ;
242- transform : translateY (-5px );
243- }
231+ to {
232+ opacity : 1 ;
233+ transform : translateY (0 );
244234 }
235+ }
245236
246- & : hover {
247- background-color : ${ DESIGN_TOKEN_COLOR . gray100 } ;
248- transition : background-color 0.2s ease-in-out;
237+ @keyframes itemFadeOut {
238+ from {
239+ opacity : 1 ;
240+ transform : translateY (0 );
241+ }
242+ to {
243+ opacity : 0 ;
244+ transform : translateY (-5px );
249245 }
250- ` }
251- >
252- < Typography variant = "body15Medium" color = "gray800" >
253- { option . title }
254- </ Typography >
255- </ div >
256- ) ) }
246+ }
247+
248+ & : hover {
249+ background-color : ${ DESIGN_TOKEN_COLOR . gray100 } ;
250+ transition : background-color 0.2s ease-in-out;
251+ }
252+ ` }
253+ >
254+ < Typography variant = "body15Medium" color = "gray800" >
255+ { option . title }
256+ </ Typography >
257+ </ div >
258+ ) ) }
257259 </ section >
258260 ) }
259261 </ article >
0 commit comments