Skip to content

Commit

Permalink
feat(project): added cleengutil for cleengcapture
Browse files Browse the repository at this point in the history
  • Loading branch information
RCVZ committed Jul 27, 2021
1 parent 807a981 commit 636e47c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/utils/cleengUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { PersonalDetailsCustomField } from 'types/account';

export type CleengCaptureField = {
key: string;
enabled: boolean;
required: boolean;
value?: string;
question?: string;
answer: string | null | Record<string, unknown>;
};

export const deconstructCustomField = (
field: CleengCaptureField,
): { values?: string[]; value?: string; type: PersonalDetailsCustomField['type'] } => {
if (!field.value) return { type: 'text' };
const values = field.value.split(';');

if (values.length == 1) {
return { value: values[0], type: 'checkbox' };
} else if (values.length == 2) {
return { values: values, type: 'radio' };
} else {
return { values: values, type: 'dropdown' };
}
};

0 comments on commit 636e47c

Please sign in to comment.