Bluesky app fork with some witchin' additions 💫
at main 40 lines 1.2 kB view raw
1import {useCallback} from 'react' 2import {msg} from '@lingui/macro' 3import {useLingui} from '@lingui/react' 4 5import {useSession} from '#/state/session' 6 7export const ZENDESK_SUPPORT_URL = 8 'https://blueskyweb.zendesk.com/hc/requests/new' 9 10export enum SupportCode { 11 AA_DID = 'AA_DID', 12 AA_BIRTHDATE = 'AA_BIRTHDATE', 13} 14 15/** 16 * {@link https://support.zendesk.com/hc/en-us/articles/4408839114522-Creating-pre-filled-ticket-forms} 17 */ 18export function useCreateSupportLink() { 19 const {_} = useLingui() 20 const {currentAccount} = useSession() 21 22 return useCallback( 23 ({code, email}: {code: SupportCode; email?: string}) => { 24 const url = new URL(ZENDESK_SUPPORT_URL) 25 if (currentAccount) { 26 url.search = new URLSearchParams({ 27 tf_anonymous_requester_email: email || currentAccount.email || '', // email will be defined 28 tf_description: 29 `[Code: ${code}] — ` + _(msg`Please write your message below:`), 30 /** 31 * Custom field specific to {@link ZENDESK_SUPPORT_URL} form 32 */ 33 tf_17205412673421: currentAccount.handle + ` (${currentAccount.did})`, 34 }).toString() 35 } 36 return url.toString() 37 }, 38 [_, currentAccount], 39 ) 40}