react-code-dataset / wp-calypso /packages /help-center /src /hooks /use-flow-zendesk-user-fields.ts
Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame contribute delete
787 Bytes
import { FLOWS_ZENDESK_FLOWNAME, FLOWS_ZENDESK_INITIAL_MESSAGES } from '../constants';
// We want to give the Help Center custom options based on the flow in which the user is in
export function useFlowZendeskUserFields( flowName: string ) {
const url = window?.location.href;
let userFieldFlowName = null;
let userFieldMessage = null;
if ( Object.keys( FLOWS_ZENDESK_INITIAL_MESSAGES ).includes( flowName ) ) {
userFieldMessage = `${
FLOWS_ZENDESK_INITIAL_MESSAGES[ flowName as keyof typeof FLOWS_ZENDESK_INITIAL_MESSAGES ]
} URL: ${ url }`;
}
if ( Object.keys( FLOWS_ZENDESK_FLOWNAME ).includes( flowName ) ) {
userFieldFlowName = FLOWS_ZENDESK_FLOWNAME[ flowName as keyof typeof FLOWS_ZENDESK_FLOWNAME ];
}
return {
userFieldMessage,
userFieldFlowName,
};
}