Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] QR코드로 초대하기 기능 추가 #783

Merged
merged 6 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions client/package-lock.json

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

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"@emotion/react": "^11.11.4",
"@sentry/react": "^8.25.0",
"@tanstack/react-query": "^5.51.23",
"qrcode.react": "^4.1.0",
"react": "^18.3.1",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18.3.1",
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Design/token/zIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const BOTTOM_SHEET_DIMMED_LAYER = NUMBER_KEYBOARD_BOTTOM_SHEET + ABOVE;
const BOTTOM_SHEET_CONTAINER = BOTTOM_SHEET_DIMMED_LAYER + ABOVE;
const TOAST = BOTTOM_SHEET_CONTAINER + ABOVE;
const SELECT_OPTION = ABOVE;
const DROPDOWN_LIST = BASE + ABOVE;
const DROPDOWN_LIST = TAB_TEXT + ABOVE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

z-index 대신 수정해줘서 고마워요~~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

소하의 zindex 창고 🚀🚀🚀


export const ZINDEX = {
bottomSheetDimmedLayer: BOTTOM_SHEET_DIMMED_LAYER,
Expand Down
24 changes: 19 additions & 5 deletions client/src/components/ShareEventButton/DesktopShareEventButton.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import {useNavigate} from 'react-router-dom';

import toast from '@hooks/useToast/toast';

import {Button} from '@components/Design';
import {Dropdown, DropdownButton} from '@components/Design';

import getEventIdByUrl from '@utils/getEventIdByUrl';

type DesktopShareEventButtonProps = React.PropsWithChildren<React.HTMLAttributes<HTMLButtonElement>> & {
onCopy: () => Promise<void>;
};

const DesktopShareEventButton = ({onCopy, children, ...buttonProps}: DesktopShareEventButtonProps) => {
const DesktopShareEventButton = ({onCopy}: DesktopShareEventButtonProps) => {
const copyAndToast = async () => {
await onCopy();
toast.confirm('링크가 복사되었어요 :) \n참여자들에게 링크를 공유해 주세요!', {
Expand All @@ -15,10 +19,20 @@ const DesktopShareEventButton = ({onCopy, children, ...buttonProps}: DesktopShar
});
};

const navigate = useNavigate();
const eventId = getEventIdByUrl();

const navigateQRPage = () => {
navigate(`/event/${eventId}/qrcode`);
};

return (
<Button size="small" variants="tertiary" onClick={copyAndToast} style={{marginRight: '1rem'}} {...buttonProps}>
{children}
</Button>
<div style={{marginRight: '1rem'}}>
<Dropdown base="button" baseButtonText="정산 초대하기">
<DropdownButton text="링크 복사하기" onClick={copyAndToast} />
<DropdownButton text="QR코드로 초대하기" onClick={navigateQRPage} />
</Dropdown>
</div>
);
Comment on lines +30 to 36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빠르게 드랍다운까지 넣어주셔서 감사합니다~~

};

Expand Down
12 changes: 12 additions & 0 deletions client/src/components/ShareEventButton/MobileShareEventButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {useNavigate} from 'react-router-dom';

import toast from '@hooks/useToast/toast';

import {Dropdown, DropdownButton} from '@components/Design';

import getEventIdByUrl from '@utils/getEventIdByUrl';

type MobileShareEventButtonProps = {
copyShare: () => Promise<void>;
kakaoShare: () => void;
Expand All @@ -16,10 +20,18 @@ const MobileShareEventButton = ({copyShare, kakaoShare}: MobileShareEventButtonP
});
};

const navigate = useNavigate();
const eventId = getEventIdByUrl();

const navigateQRPage = () => {
navigate(`/event/${eventId}/qrcode`);
};

return (
<div style={{marginRight: '1rem'}}>
<Dropdown base="button" baseButtonText="정산 초대하기">
<DropdownButton text="링크 복사하기" onClick={copyAndToast} />
<DropdownButton text="QR코드로 초대하기" onClick={navigateQRPage} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 여유있을 때 amplitude에 qr코드를 얼마나 사용자들이 클릭하는지 알아봐도 좋을 것 같아요

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋네요..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엠플리튜드 최고

<DropdownButton text="카카오톡으로 초대하기" onClick={kakaoShare} />
</Dropdown>
</div>
Expand Down
1 change: 1 addition & 0 deletions client/src/constants/routerUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export const ROUTER_URLS = {
images: '/event/:eventId/images',
addImages: '/event/:eventId/admin/add-images',
send: 'event/:eventId/:memberId/send',
qrCode: 'event/:eventId/qrcode',
};
2 changes: 1 addition & 1 deletion client/src/pages/EventPage/EventPageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const EventPageLayout = () => {
{isMobile ? (
<MobileShareEventButton copyShare={trackLinkShare} kakaoShare={trackKakaoShare} />
) : (
<DesktopShareEventButton onCopy={trackLinkShare}>정산 초대하기</DesktopShareEventButton>
<DesktopShareEventButton onCopy={trackLinkShare} />
)}
</Flex>
<Outlet context={outletContext} />
Expand Down
8 changes: 8 additions & 0 deletions client/src/pages/QRCodePage/QRCodePage.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {css} from '@emotion/react';

export const QRCodeStyle = () => css`
position: relative;
display: flex;
justify-content: center;
align-items: center;
`;
41 changes: 41 additions & 0 deletions client/src/pages/QRCodePage/QRCodePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {css} from '@emotion/react';
import {QRCodeSVG} from 'qrcode.react';

import {MainLayout, Top, TopNav} from '@components/Design';
import {useTheme} from '@components/Design';

import getEventPageUrlByEnvironment from '@utils/getEventPageUrlByEnvironment';
import getEventIdByUrl from '@utils/getEventIdByUrl';

import {QRCodeStyle} from './QRCodePage.style';

const QRCodePage = () => {
const {theme} = useTheme();
const eventId = getEventIdByUrl();

return (
<MainLayout backgroundColor="white">
<TopNav>
<TopNav.Item displayName="뒤로가기" noEmphasis routePath="-1" />
</TopNav>
<div
css={css`
display: flex;
flex-direction: column;
gap: 1rem;
padding: 1rem;
`}
>
Comment on lines +21 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분 FunnelLayout을 사용해도 적용이 됩니다 :) (뭔가 만들어놓고 홍보를 못 해서 아쉽긴하지만..)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오홍! 그런게 있었는지 몰랐네요!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그리고 style 분리해도 좋을 것 같아요~!~!

<Top>
<Top.Line text="QR코드를 공유하여" emphasize={['QR코드']} />
<Top.Line text="참여자를 초대해 보세요" />
</Top>
</div>
<div css={QRCodeStyle()}>
<QRCodeSVG value={getEventPageUrlByEnvironment(eventId, 'home')} size={240} fgColor={`${theme.colors.black}`} />
</div>
</MainLayout>
);
};

export default QRCodePage;
5 changes: 5 additions & 0 deletions client/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const EditBillPage = lazy(() => import('@pages/EditBillPage/EditBillPage'));
const Account = lazy(() => import('@pages/AccountPage/Account'));
const ImagesPage = lazy(() => import('@pages/ImagesPage/ImagesPage'));
const AddImagesPage = lazy(() => import('@pages/AddImagesPage/AddImagesPage'));
const QRCodePage = lazy(() => import('@pages/QRCodePage/QRCodePage'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lazy loading까지 꼼꼼하게.. 너무 좋아요


const router = createBrowserRouter([
{
Expand Down Expand Up @@ -92,6 +93,10 @@ const router = createBrowserRouter([
element: <SendPage />,
errorElement: <SendErrorPage />,
},
{
path: ROUTER_URLS.qrCode,
element: <QRCodePage />,
},
{
path: '*',
element: <ErrorPage />,
Expand Down
Loading