Files
bsky-social-app/src/lib/hooks/useCreateSupportLink.ts
T
Eric Bailey c4aef9f668 Age Assurance V2 (#9479)
* Age Assurance V2

* Tighten up test

* Add todos for sdk migration

* Align RQ versions

* Use useEffect for side effect

* Improve effects, memoize

* Standarize on birthdate

* Copy feedback

* Copilot

* Add support link

* Reove double ..

* Cleanup

* Remove redirect dialog

* Cleanup todos, add comments

* Update splash in main template too

* Mock some stuff

* Exhaustive checks

Co-authored-by: Samuel Newman <mozzius@protonmail.com>

* Exhaustive checks

Co-authored-by: Samuel Newman <mozzius@protonmail.com>

* Small fix to bday handling

* Add comment

* onboarding style tweak

sneaking this in sorry!

* rm unreachable breaks

* Put useIntentHandler back on web

* Remove misleading success set

* Align on birthdate

---------

Co-authored-by: Samuel Newman <mozzius@protonmail.com>
2025-12-04 15:20:00 -06:00

41 lines
1.2 KiB
TypeScript

import {useCallback} from 'react'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useSession} from '#/state/session'
export const ZENDESK_SUPPORT_URL =
'https://blueskyweb.zendesk.com/hc/requests/new'
export enum SupportCode {
AA_DID = 'AA_DID',
AA_BIRTHDATE = 'AA_BIRTHDATE',
}
/**
* {@link https://support.zendesk.com/hc/en-us/articles/4408839114522-Creating-pre-filled-ticket-forms}
*/
export function useCreateSupportLink() {
const {_} = useLingui()
const {currentAccount} = useSession()
return useCallback(
({code, email}: {code: SupportCode; email?: string}) => {
const url = new URL(ZENDESK_SUPPORT_URL)
if (currentAccount) {
url.search = new URLSearchParams({
tf_anonymous_requester_email: email || currentAccount.email || '', // email will be defined
tf_description:
`[Code: ${code}] — ` + _(msg`Please write your message below:`),
/**
* Custom field specific to {@link ZENDESK_SUPPORT_URL} form
*/
tf_17205412673421: currentAccount.handle + ` (${currentAccount.did})`,
}).toString()
}
return url.toString()
},
[_, currentAccount],
)
}