Skip to content

Commit

Permalink
feat(client): 커피챗 요청, 수락시 콘페티 이펙트 추가 (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
SEOKKAMONI committed May 1, 2024
1 parent eb1695c commit 4b602d7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"axios": "^1.6.0",
"framer-motion": "^10.16.4",
"jotai": "^2.6.0",
"js-confetti": "^0.12.0",
"lodash": "^4.17.21",
"next": "14.0.2",
"react": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useQueryClient } from '@tanstack/react-query';
import { useAcceptCoffeechat } from '@/hooks/api/coffeechat/useAcceptCoffeechat';
import { RECEIVE_COFFEE_CHAT_LIST } from '@/hooks/api/coffeechat/useGetReceiveCoffeechatList';
import { USER_QUERY_KEY } from '@/hooks/api/user/useGetUser';
import { useShowConfettiEffect } from '@/hooks/common/useShowConfettiEffect';
import { useLogAnalyticsEvent } from '@/libs/logging';

type CoffeechatAcceptConfirmProps = {
Expand All @@ -16,7 +17,7 @@ const CoffeechatAcceptConfirm = ({
}: CoffeechatAcceptConfirmProps) => {
const queryClient = useQueryClient();
const { logClickEvent } = useLogAnalyticsEvent();

const { showConfettiEffect } = useShowConfettiEffect();
const { mutate: acceptCoffeechatMutate } = useAcceptCoffeechat(coffeechatId, {
onSuccess: () => {
logClickEvent({
Expand All @@ -27,6 +28,7 @@ const CoffeechatAcceptConfirm = ({
});
queryClient.invalidateQueries({ queryKey: [RECEIVE_COFFEE_CHAT_LIST] });
queryClient.invalidateQueries({ queryKey: [USER_QUERY_KEY] });
showConfettiEffect();
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useForm } from 'react-hook-form';
import { SEND_COFFEE_CHAT_LIST } from '@/hooks/api/coffeechat/useGetSendCoffeechatList';
import { useSendCoffeechat } from '@/hooks/api/coffeechat/useSendCoffeechat';
import type { SendCoffeechatRequest } from '@/hooks/api/coffeechat/useSendCoffeechat';
import { useShowConfettiEffect } from '@/hooks/common/useShowConfettiEffect';
import { useLogAnalyticsEvent } from '@/libs/logging';
import { useToast } from '@/libs/toast';

Expand All @@ -24,6 +25,7 @@ const CoffeechatSendConfirm = ({
const router = useRouter();
const queryClient = useQueryClient();
const { toast } = useToast();
const { showConfettiEffect } = useShowConfettiEffect();
const { logClickEvent } = useLogAnalyticsEvent();
const {
register,
Expand All @@ -36,6 +38,7 @@ const CoffeechatSendConfirm = ({
logClickEvent({ name: 'click_send_coffeechat', params: sendCoffeechatRequest });
queryClient.invalidateQueries({ queryKey: [SEND_COFFEE_CHAT_LIST] });
router.replace('/profile');
showConfettiEffect();
toast.info('커피챗 요청을 보냈어요!', {
action: {
label: '확인하러 가기',
Expand Down
14 changes: 14 additions & 0 deletions apps/client/src/hooks/common/useShowConfettiEffect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import JSConfetti from 'js-confetti';

export const useShowConfettiEffect = () => {
const jsConfetti = new JSConfetti();

const showConfettiEffect = () => {
jsConfetti.addConfetti({
confettiColors: ['#7046F7', '#8D6BF9', '#A990FA', '#C6B5FC'],
confettiNumber: 500,
});
};

return { showConfettiEffect };
};
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4b602d7

Please sign in to comment.