Skip to content

Commit b0a615d

Browse files
authored
Merge pull request #145 from DDD-Community/feat/#133-hotfix
feat: 모든 크루 응원하기 하려고 할 때, 이미 접속한 모든 크루를 응원한 상태라면 전송이 안되도록 구현
2 parents 5347697 + 2125367 commit b0a615d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/components/Posture/PostrueCrew.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,33 @@ export default function PostrueCrew(props: PostureCrewProps): ReactElement {
223223
})
224224
}
225225

226-
const onClickAllCrewCheer = () => {
226+
const onClickAllCrewCheer = async () => {
227227
const allCrewUids = crews.map((item) => item.uid)
228228
if (!allCrewUids || allCrewUids.length === 0) {
229229
toast.error("접속한 크루가 없습니다.")
230230
return
231231
}
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+
232248
requestSendCrewCheer({
233249
uids: allCrewUids,
234250
}).then(({ data }) => {
235251
if (data) {
236252
toast.success("모든 크루에게 응원하기 전송이 성공했습니다")
237-
const today = dayjs().format("YYYY-MM-DD")
238253
getMyCheerUpInfo(today).then(({ data }) => {
239254
setCheeredUpCrewList(data.cheeredUpUids)
240255
setMyCheerCount(data.countCheeredUp)

0 commit comments

Comments
 (0)