File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -223,18 +223,33 @@ export default function PostrueCrew(props: PostureCrewProps): ReactElement {
223
223
} )
224
224
}
225
225
226
- const onClickAllCrewCheer = ( ) => {
226
+ const onClickAllCrewCheer = async ( ) => {
227
227
const allCrewUids = crews . map ( ( item ) => item . uid )
228
228
if ( ! allCrewUids || allCrewUids . length === 0 ) {
229
229
toast . error ( "접속한 크루가 없습니다." )
230
230
return
231
231
}
232
+ const today = dayjs ( ) . format ( "YYYY-MM-DD" )
233
+ try {
234
+ const { data } = await getMyCheerUpInfo ( today )
235
+ const sortedCheeredUpUids = data . cheeredUpUids . sort ( )
236
+ const sortedCrewUids = allCrewUids . sort ( )
237
+ if (
238
+ sortedCheeredUpUids . length === sortedCrewUids . length &&
239
+ sortedCheeredUpUids . every ( ( value , index ) => value === sortedCrewUids [ index ] )
240
+ ) {
241
+ toast . error ( "현재 접속한 모든 크루에게 응원하기를 보냈습니다." )
242
+ return
243
+ }
244
+ } catch ( error ) {
245
+ console . log ( "error: " , error )
246
+ }
247
+
232
248
requestSendCrewCheer ( {
233
249
uids : allCrewUids ,
234
250
} ) . then ( ( { data } ) => {
235
251
if ( data ) {
236
252
toast . success ( "모든 크루에게 응원하기 전송이 성공했습니다" )
237
- const today = dayjs ( ) . format ( "YYYY-MM-DD" )
238
253
getMyCheerUpInfo ( today ) . then ( ( { data } ) => {
239
254
setCheeredUpCrewList ( data . cheeredUpUids )
240
255
setMyCheerCount ( data . countCheeredUp )
You can’t perform that action at this time.
0 commit comments