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

feat: 공유 텍스트 수정 및 공유 시 미리보기 링크로 이동되도록 수정 #228

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all 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
33 changes: 26 additions & 7 deletions apps/preview/src/pages/ShowPreviewPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ import BooltiGrayLogo from '../../components/BooltiGrayLogo';

setDefaultOptions({ locale: ko });

const getDynamicLink = (showId: number) => {
return `https://boolti.page.link/?link=https://preview.boolti.in/show/${showId}&apn=com.nexters.boolti&ibi=com.nexters.boolti&isi=6476589322`;
}

const getPreviewLink = (showId: number) => {
return `${window.location.origin}/show/${showId}`
}

const getShareText = (show: { id: number, title: string, date: Date, placeName: string, streetAddress: string, detailAddress: string }) => {
return `
공연 정보를 공유드려요!

- 공연명 : ${show.title}
- 일시 : ${format(show.date, 'yyyy.MM.dd (E) HH:mm -', { locale: ko })}
- 장소 : ${show.placeName} / ${show.streetAddress}, ${show.detailAddress}

공연 상세 정보 ▼
${getPreviewLink(show.id)}
`
}

const ShowPreviewPage = () => {
const loaderData = useLoaderData() as
| [ShowPreviewResponse, ShowCastTeamReadResponse[]]
Expand Down Expand Up @@ -41,17 +62,15 @@ const ShowPreviewPage = () => {
hostPhoneNumber,
} = previewData;

const dynamicLink = `https://boolti.page.link/?link=https://preview.boolti.in/show/${id}&apn=com.nexters.boolti&ibi=com.nexters.boolti&isi=6476589322`;

const shareButtonClickHandler = async () => {
try {
await navigator.share({
title,
text,
url: dynamicLink,
text: getShareText({ id, title, date: new Date(date), placeName, streetAddress, detailAddress }),
url: getPreviewLink(id),
});
} catch (error) {
navigator.clipboard.writeText(dynamicLink);
await navigator.clipboard.writeText(getPreviewLink(id));

alert('공연 링크가 복사되었어요');
}
Expand All @@ -64,7 +83,7 @@ const ShowPreviewPage = () => {
<Styled.DialogContainer>
<Styled.DialogQRCodeContainer>
<Styled.QRCodeContainer>
<QRCodeSVG value={dynamicLink} size={182} level="H" />
<QRCodeSVG value={getPreviewLink(id)} size={182} level="H" />
</Styled.QRCodeContainer>
<BooltiGrayLogo />
</Styled.DialogQRCodeContainer>
Expand All @@ -82,7 +101,7 @@ const ShowPreviewPage = () => {
};

const reservationButtonMobileClickHandler = () => {
window.location.href = dynamicLink;
window.location.href = getDynamicLink(id);
};

return (
Expand Down
Loading