Skip to content

Commit

Permalink
getWeddingInvitation 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhello0507 committed Jan 18, 2025
1 parent d1b14f0 commit d38e0fa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/page/wedding/WeddingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import weddingApi from "@remote/api/WeddingApi";
import {useParams} from "react-router-dom";
import {Row} from "@designsystem/component/flexLayout";
import TemplateComponent from "@src/component/template/TemplateComponent";
import {getDeviceType} from "@remote/enumeration/Device";
import Cookies from "js-cookie";

function WeddingPage() {
const {url} = useParams();
Expand All @@ -12,8 +14,19 @@ function WeddingPage() {
useEffect(() => {
if (!url) return;

const cookieKey = `firstVisitor_${url}`;

const isFirstVisitor = !Cookies.get(cookieKey);

if (isFirstVisitor) {
Cookies.set(cookieKey, "false", { expires: 365 }); // 1년 동안 유지
}

(async () => {
const {data} = await weddingApi.getWedding(url);
const {data} = await weddingApi.getWeddingInvitation(url, {
deviceType: getDeviceType(),
firstVisitor: isFirstVisitor
});
setWedding(data);
})();
}, []);
Expand Down
8 changes: 8 additions & 0 deletions src/remote/enumeration/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ enum Device {
DESKTOP = 'DESKTOP',
}

export function getDeviceType(): Device {
const userAgent = navigator.userAgent.toLowerCase();
if (/mobile|android|iphone|ipad|ipod|blackberry|iemobile|opera mini/.test(userAgent)) {
return Device.MOBILE;
}
return Device.DESKTOP;
}

export default Device;

0 comments on commit d38e0fa

Please sign in to comment.