File size: 787 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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,
	};
}