Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 the data contract changed, we need script instead #922

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/SQFormTransferTool/AccordionBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function AccordionBody({
transferProduct,
onTransfer,
}: AccordionBodyProps): React.ReactElement {
const {productDisplayName, modalLinkText} = transferProduct;
const {productDisplayName, linkText} = transferProduct;
/* while the name formik Helpers is slightly misleading as it contains more
* than that, it is at least safe given that the rest is inclusive of the helpers
*/
Expand All @@ -60,7 +60,7 @@ export default function AccordionBody({
values.questionValues
);

const tooltip = isTransferConditionMet ? modalLinkText : 'Condition Not Met';
const tooltip = isTransferConditionMet ? linkText : 'Condition Not Met';

return (
<Section sx={{marginBottom: '0px'}}>
Expand All @@ -70,7 +70,7 @@ export default function AccordionBody({
tooltip={tooltip}
isDisabled={!isTransferConditionMet}
>
{modalLinkText}
{linkText}
</TextButton>
</SectionHeader>
<SectionBody>
Expand Down
4 changes: 2 additions & 2 deletions src/components/SQFormTransferTool/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export default function StepRendering({
);
}

// for scripting steps, if the condition is not met we do not want to render anything
if (type === 'scripting' && isConditionMet) {
// for script steps, if the condition is not met we do not want to render anything
if (type === 'script' && isConditionMet) {
return <ScriptedText text={text} key={`script_${id}`} sx={styles.script} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/SQFormTransferTool/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type QuestionStep = BaseStep & {
};

export type ScriptingStep = BaseStep & {
type: 'scripting';
type: 'script';
text: string;
options: null;
};
Expand All @@ -41,7 +41,7 @@ export type TransferProduct = {
productID: number;
productTag: string;
productDisplayName: string;
modalLinkText: string;
linkText: string;
transferLine: string;
enabled: boolean;
steps: Step[];
Expand Down
5 changes: 4 additions & 1 deletion src/components/SQFormTransferTool/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export function getIsConditionMet(
return answers.every((answer) => checkAnswer(answer, values));
}

if (logicalOperator === 'or') {
/* In the case where there is only one question step, the
logical operator will be null. We still need to check that answer
*/
if (logicalOperator === 'or' || logicalOperator === null) {
return answers.some((answer) => checkAnswer(answer, values));
}
}
Expand Down
12 changes: 6 additions & 6 deletions stories/SQFormTransferTool.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const questionStepFour: Step = {
};

const stepScriptOne: Step = {
type: 'scripting',
type: 'script',
id: MOCK_IDs.SCRIPTING_ONE_ID,
text: 'Question 3 demonstrates AND logic, pick no for question one AND "an option" for question two',
options: null,
Expand All @@ -147,7 +147,7 @@ const stepScriptThree: Step = {
const stepScriptFour: Step = {
...stepScriptOne,
id: MOCK_IDs.SCRIPTING_FOUR_ID,
text: 'Scripting steps are also conditional, this script is shown on the same condition that enables question 4',
text: 'Script steps are also conditional, this script is shown on the same condition that enables question 4',
condition: questionStepFour.condition,
};

Expand All @@ -172,7 +172,7 @@ const conditionalMock: TransferProduct = {
productTag: 'Product Tag',
// Note the product name and transfer button text have to share space
productDisplayName: 'Conditional Example',
modalLinkText: `Transfer to DIV AB`,
linkText: `Transfer to DIV AB`,
transferLine: '7777777777',
enabled: true,
steps: [
Expand All @@ -195,7 +195,7 @@ function getMockData(
productID: 2 + idx,
productTag: 'Product Tag ' + idx,
productDisplayName: 'Product Name ' + idx,
modalLinkText: `Transfer to div ${idx}`, // any longer than this and the button will truncate
linkText: `Transfer to div ${idx}`, // any longer than this and the button will truncate
transferLine: '7777777777',
enabled: idx < 3,
steps: [
Expand Down Expand Up @@ -223,9 +223,9 @@ function getMockData(
condition: null,
},
{
type: 'scripting',
type: 'script',
id: 3 + idx,
text: 'This is the scripting',
text: 'This is the script',
options: null,
condition: null,
},
Expand Down
Loading