-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fe-dev' into feature/#562
- Loading branch information
Showing
13 changed files
with
203 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
client/src/components/KakaoInitializer/KakaoInitializer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {useEffect} from 'react'; | ||
|
||
const KakaoInitializer = ({children}: React.PropsWithChildren) => { | ||
useEffect(() => { | ||
if (!window.Kakao) return; | ||
|
||
if (!window.Kakao.isInitialized()) { | ||
window.Kakao.init(process.env.KAKAO_JAVASCRIPT_KEY); | ||
} | ||
}, []); | ||
|
||
return children; | ||
}; | ||
|
||
export default KakaoInitializer; |
41 changes: 41 additions & 0 deletions
41
client/src/components/ShareEventButton/ShareEventButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import CopyToClipboard from 'react-copy-to-clipboard'; | ||
|
||
import {useToast} from '@hooks/useToast/useToast'; | ||
|
||
import useShareEvent from '@hooks/useShareEvent'; | ||
|
||
import {Button} from '@components/Design'; | ||
|
||
import isMobileDevice from '@utils/isMobileDevice'; | ||
|
||
const ShareEventButton = () => { | ||
const {showToast} = useToast(); | ||
|
||
const isMobile = isMobileDevice(); | ||
const {shareText, onShareButtonClick} = useShareEvent(isMobile); | ||
|
||
return isMobile ? ( | ||
<Button size="small" variants="secondary" onClick={onShareButtonClick}> | ||
μΉ΄μΉ΄μ€ν‘μΌλ‘ μ μ° μ΄λνκΈ° | ||
</Button> | ||
) : ( | ||
<CopyToClipboard | ||
text={shareText} | ||
onCopy={() => | ||
showToast({ | ||
showingTime: 3000, | ||
message: 'λ§ν¬κ° 볡μ¬λμμ΄μ :) \nμ°Έμ¬μλ€μκ² λ§ν¬λ₯Ό 곡μ ν΄ μ£ΌμΈμ!', | ||
type: 'confirm', | ||
position: 'bottom', | ||
bottom: '8rem', | ||
}) | ||
} | ||
> | ||
<Button size="small" variants="secondary" onClick={onShareButtonClick}> | ||
μ μ° μ΄λνκΈ° | ||
</Button> | ||
</CopyToClipboard> | ||
); | ||
}; | ||
|
||
export default ShareEventButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default as ShareEventButton} from './ShareEventButton'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {useMatch} from 'react-router-dom'; | ||
|
||
import {ROUTER_URLS} from '@constants/routerUrls'; | ||
|
||
import useNavSwitch from './useNavSwitch'; | ||
import useRequestGetEvent from './queries/event/useRequestGetEvent'; | ||
|
||
const useEventPageLayout = () => { | ||
const navProps = useNavSwitch(); | ||
const {eventName} = useRequestGetEvent(); | ||
|
||
const isAdmin = useMatch(ROUTER_URLS.eventManage) !== null; | ||
const isLoginPage = useMatch(ROUTER_URLS.eventLogin) !== null; | ||
|
||
return { | ||
navProps, | ||
isAdmin, | ||
eventName, | ||
isLoginPage, | ||
}; | ||
}; | ||
|
||
export default useEventPageLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import getEventIdByUrl from '@utils/getEventIdByUrl'; | ||
import getEventPageUrlByEnvironment from '@utils/getEventPageUrlByEnvironment'; | ||
|
||
import useRequestGetEvent from './queries/event/useRequestGetEvent'; | ||
|
||
const useShareEvent = (isMobile: boolean) => { | ||
const {eventName} = useRequestGetEvent(); | ||
|
||
const eventId = getEventIdByUrl(); | ||
const url = getEventPageUrlByEnvironment(eventId, 'home'); | ||
|
||
const shareInfo = { | ||
title: `[νλλμ₯]\n${eventName}μ λν μ μ°μ μμν κ²μ:)`, | ||
text: 'μλ λ§ν¬μ μ μν΄μ μ μ° λ΄μμ νμΈν΄ μ£ΌμΈμ!', | ||
url, | ||
}; | ||
|
||
// λͺ¨λ°μΌμ΄ μλ κΈ°κΈ°λ λ¨μ ν μ€νΈ λ³΅μ¬ | ||
// λͺ¨λ°μΌ κΈ°κΈ°μμλ μΉ΄μΉ΄μ€ν‘ 곡μ λ₯Ό μ¬μ© | ||
const onShareButtonClick = () => { | ||
if (!isMobile) return; | ||
|
||
kakaoShare(); | ||
}; | ||
|
||
const kakaoShare = () => { | ||
window.Kakao.Share.sendDefault({ | ||
objectType: 'feed', | ||
content: { | ||
title: shareInfo.title, | ||
description: shareInfo.text, | ||
imageUrl: | ||
'https://wooteco-crew-wiki.s3.ap-northeast-2.amazonaws.com/%EC%9B%A8%EB%94%94%286%EA%B8%B0%29/g583lirp8yg.jpg', | ||
link: { | ||
mobileWebUrl: url, | ||
webUrl: url, | ||
}, | ||
}, | ||
buttonTitle: 'μ μ° νμΈνκΈ°', | ||
}); | ||
}; | ||
|
||
const shareText = `${shareInfo.title}\n${shareInfo.text}\n${url}`; | ||
|
||
return { | ||
shareText, | ||
onShareButtonClick, | ||
}; | ||
}; | ||
|
||
export default useShareEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
declare global { | ||
interface Window { | ||
Kakao: typeof Kakao; | ||
} | ||
} | ||
|
||
namespace Kakao { | ||
function init(appKey: string): void; | ||
function isInitialized(): boolean; | ||
|
||
namespace Share { | ||
function cleanup(): void; | ||
function sendDefault(params: sendDefaultParams): void; | ||
|
||
interface sendDefaultParams { | ||
objectType: 'feed'; | ||
content: { | ||
title: string; | ||
imageUrl: string; | ||
imageWidth?: number; | ||
imageHeight?: number; | ||
description: string; | ||
link: { | ||
mobileWebUrl: string; | ||
webUrl: string; | ||
}; | ||
}; | ||
buttonTitle?: string; | ||
buttons?: { | ||
title: string; | ||
link: { | ||
webUrl: string; | ||
mobileWebUrl: string; | ||
}; | ||
}[]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const isMobileDevice = () => { | ||
const userAgent = window.navigator.userAgent; | ||
const mobileRegex = [/Android/i, /iPhone/i, /iPad/i, /iPod/i, /BlackBerry/i, /Windows Phone/i]; | ||
|
||
return mobileRegex.some(mobile => userAgent.match(mobile)); | ||
}; | ||
|
||
export default isMobileDevice; |