Skip to content

Commit

Permalink
Merge pull request #145 from DDD-Community/feat/#133-hotfix
Browse files Browse the repository at this point in the history
feat: 모든 크루 응원하기 하려고 할 때, 이미 접속한 모든 크루를 응원한 상태라면 전송이 안되도록 구현
  • Loading branch information
G-hoon authored Jan 21, 2025
2 parents 5347697 + 2125367 commit b0a615d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/components/Posture/PostrueCrew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,33 @@ export default function PostrueCrew(props: PostureCrewProps): ReactElement {
})
}

const onClickAllCrewCheer = () => {
const onClickAllCrewCheer = async () => {
const allCrewUids = crews.map((item) => item.uid)
if (!allCrewUids || allCrewUids.length === 0) {
toast.error("접속한 크루가 없습니다.")
return
}
const today = dayjs().format("YYYY-MM-DD")
try {
const { data } = await getMyCheerUpInfo(today)
const sortedCheeredUpUids = data.cheeredUpUids.sort()
const sortedCrewUids = allCrewUids.sort()
if (
sortedCheeredUpUids.length === sortedCrewUids.length &&
sortedCheeredUpUids.every((value, index) => value === sortedCrewUids[index])
) {
toast.error("현재 접속한 모든 크루에게 응원하기를 보냈습니다.")
return
}
} catch (error) {
console.log("error: ", error)
}

requestSendCrewCheer({
uids: allCrewUids,
}).then(({ data }) => {
if (data) {
toast.success("모든 크루에게 응원하기 전송이 성공했습니다")
const today = dayjs().format("YYYY-MM-DD")
getMyCheerUpInfo(today).then(({ data }) => {
setCheeredUpCrewList(data.cheeredUpUids)
setMyCheerCount(data.countCheeredUp)
Expand Down

0 comments on commit b0a615d

Please sign in to comment.