-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #539 from sparcs-kaist/dev
Main branch update from Dev branch
- Loading branch information
Showing
40 changed files
with
1,136 additions
and
603 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
import { useCallback } from "react"; | ||
|
||
import alertAtom from "atoms/alert"; | ||
import { useSetRecoilState } from "recoil"; | ||
|
||
type LinkCopyProps = { | ||
children: React.ReactNode; | ||
value: string; | ||
onCopy?: (value: string) => void; | ||
}; | ||
|
||
const LinkCopy = ({ children, value, onCopy }: LinkCopyProps) => { | ||
const setAlert = useSetRecoilState(alertAtom); | ||
const onClick = useCallback(() => { | ||
if (!navigator.clipboard) { | ||
setAlert("복사를 지원하지 않는 브라우저입니다."); | ||
return; | ||
} | ||
navigator.clipboard.writeText(value); | ||
if (onCopy) onCopy(value); | ||
}, [value, setAlert, onCopy]); | ||
return <a onClick={onClick}>{children}</a>; | ||
}; | ||
|
||
export default LinkCopy; |
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,65 @@ | ||
import { useCallback } from "react"; | ||
import { useLocation } from "react-router-dom"; | ||
|
||
import { kakaoSDKKey } from "loadenv"; | ||
|
||
type LinkKakaotalkShareProps = { | ||
children: React.ReactNode; | ||
title?: string; | ||
description?: string; | ||
buttonText?: string; | ||
buttonTo?: string; | ||
partNum?: number; | ||
}; | ||
|
||
const LinkKakaotalkShare = ({ | ||
children, | ||
title = "Taxi", | ||
description = "KAIST 구성원들의 택시 동승 인원 모집을 위한 서비스", | ||
buttonText = "사이트로 이동", | ||
buttonTo: _buttonTo, | ||
partNum, | ||
}: LinkKakaotalkShareProps) => { | ||
const { pathname, search } = useLocation(); | ||
const buttonTo = _buttonTo ?? pathname + search; | ||
|
||
const onClick = useCallback(() => { | ||
const kakao = window.Kakao; | ||
const { origin: webUrl } = window.location; | ||
if (!kakao) { | ||
console.error("Kakao SDK is not loaded."); | ||
return; | ||
} | ||
if (!kakaoSDKKey) { | ||
console.error("Kakao SDK key is not set."); | ||
return; | ||
} | ||
if (!kakao.isInitialized()) { | ||
kakao.init(kakaoSDKKey); | ||
} | ||
kakao.Share.sendDefault({ | ||
objectType: "feed", | ||
content: { | ||
title, | ||
description, | ||
imageUrl: `${webUrl}/graph.png`, | ||
imageWidth: 1024, | ||
imageHeight: 500, | ||
link: { webUrl, mobileWebUrl: webUrl }, | ||
}, | ||
social: { subscriberCount: partNum ?? 0 }, | ||
buttons: [ | ||
{ | ||
title: buttonText, | ||
link: { | ||
mobileWebUrl: `${webUrl}${buttonTo}`, | ||
webUrl: `${webUrl}${buttonTo}`, | ||
}, | ||
}, | ||
], | ||
}); | ||
}, [title, description, buttonText, buttonTo, partNum]); | ||
return <a onClick={onClick}>{children}</a>; | ||
}; | ||
|
||
export default LinkKakaotalkShare; |
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
Oops, something went wrong.