-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…areAPI [Feat/#325] web Share api 배포본 테스트
- Loading branch information
Showing
3 changed files
with
48 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useParams } from 'react-router-dom'; | ||
import { notify } from 'utils/toast/copyLinkToast'; | ||
|
||
const useShareLink = () => { | ||
const { meetingId } = useParams(); | ||
|
||
const inviteURL = `${window.location.origin}/meet/${meetingId}`; | ||
const shareData = { | ||
title: 'ASAP', | ||
text: '회의 시간을 입력해주세요', | ||
url: inviteURL, | ||
}; | ||
|
||
const handleCopyToClipboard = async () => { | ||
try { | ||
await navigator.clipboard.writeText(inviteURL); | ||
notify(); | ||
} catch { | ||
alert('링크복사에 실패했습니다. \n 다시 시도해주세요.'); | ||
} | ||
}; | ||
|
||
const handleWebShare = async () => { | ||
if (navigator.share) { | ||
navigator.share(shareData); | ||
} else { | ||
handleCopyToClipboard(); | ||
} | ||
}; | ||
|
||
return { inviteURL, handleCopyToClipboard, handleWebShare }; | ||
}; | ||
|
||
export default useShareLink; |
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