mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
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} 13 14/** 15 * {@link https://support.zendesk.com/hc/en-us/articles/4408839114522-Creating-pre-filled-ticket-forms} 16 */ 17export function useCreateSupportLink() { 18 const {_} = useLingui() 19 const {currentAccount} = useSession() 20 21 return useCallback( 22 ({code, email}: {code: SupportCode; email?: string}) => { 23 const url = new URL(ZENDESK_SUPPORT_URL) 24 if (currentAccount) { 25 url.search = new URLSearchParams({ 26 tf_anonymous_requester_email: email || currentAccount.email || '', // email will be defined 27 tf_description: 28 `[Code: ${code}] — ` + _(msg`Please write your message below:`), 29 /** 30 * Custom field specific to {@link ZENDESK_SUPPORT_URL} form 31 */ 32 tf_17205412673421: currentAccount.handle + ` (${currentAccount.did})`, 33 }).toString() 34 } 35 return url.toString() 36 }, 37 [_, currentAccount], 38 ) 39}