Skip to content

Commit

Permalink
Merge pull request #438 from Neogasogaeseo/feature/#437
Browse files Browse the repository at this point in the history
  • Loading branch information
SeojinSeojin authored Jan 15, 2023
2 parents 627cf76 + dabc267 commit 002de45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/presentation/components/InAppBrowserEscape/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import CommonModal from '@components/common/Modal';
import React, { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';

import { useLoginUser } from '@hooks/useLoginUser';

const InAppBrowserEscape = () => {
const [isModalOpened, setIsModalOpened] = useState(false);
const { isAuthenticated } = useLoginUser();

const openRealBrowser = useCallback(() => {
const isIOS = navigator.userAgent.match(/iPhone|iPad/i);
if (isIOS) {
Expand All @@ -14,21 +18,29 @@ const InAppBrowserEscape = () => {
'#Intent;scheme=http;package=com.android.chrome;end';
}
}, []);

useEffect(() => {
if (!isAuthenticated) return;

const isInAppBrowser = navigator.userAgent.match(
/inapp|NAVER|KAKAOTALK|Snapchat|Line|WirtschaftsWoche|Thunderbird|Instagram|everytimeApp|WhatsApp|Electron|wadiz|AliApp|zumapp|iPhone(.*)Whale|Android(.*)Whale|kakaostory|band|twitter|DaumApps|DaumDevice\/mobile|FB_IAB|FB4A|FBAN|FBIOS|FBSS|SamsungBrowser\/[^1]/i,
);
if (isInAppBrowser !== null) setIsModalOpened(true);
}, []);
}, [isAuthenticated]);

return (
<CommonModal
title="알림"
description={
'더 쾌적하게 너가소개서를 이용하기 위해' + '\n' + '외부 브라우저에서 접속해 주세요.'
'크롬 앱으로 접속하면' +
'\n' +
'더 쾌적한 환경에서 이용할 수 있습니다.' +
'\n' +
'*크롬 앱이 없다면 취소를 눌러주세요'
}
onClickCancel={() => setIsModalOpened(false)}
onClickConfirm={openRealBrowser}
confirmLabel="크롬에서 보기"
isOpened={isModalOpened}
/>
);
Expand Down
5 changes: 3 additions & 2 deletions src/presentation/components/common/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ interface CommonModalProps {
title: string;
description?: string;
isOpened: boolean;
confirmLabel?: string;
}

export default function CommonModal(props: CommonModalProps) {
const { onClickConfirm, onClickCancel, title, description, isOpened } = props;
const { onClickConfirm, onClickCancel, title, description, isOpened, confirmLabel } = props;
return (
<ModalWrapper isOpened={isOpened}>
<StCommonModal>
Expand All @@ -20,7 +21,7 @@ export default function CommonModal(props: CommonModalProps) {
{description && <StDescription>{description}</StDescription>}
<div>
<button onClick={onClickCancel}>취소</button>
<button onClick={onClickConfirm}>확인</button>
<button onClick={onClickConfirm}>{confirmLabel ?? '확인'}</button>
</div>
</StCommonModal>
</ModalWrapper>
Expand Down

0 comments on commit 002de45

Please sign in to comment.