Skip to content

Comments

SNT-285 i can create a assignment rule#191

Merged
Bewi merged 13 commits intomainfrom
SNT-285-i-can-create-a-assignment-rule
Feb 19, 2026
Merged

SNT-285 i can create a assignment rule#191
Bewi merged 13 commits intomainfrom
SNT-285-i-can-create-a-assignment-rule

Conversation

@Bewi
Copy link
Contributor

@Bewi Bewi commented Feb 17, 2026

What problem is this PR solving?

Initiate V2 of intervention assignment, purpose of this is only to have the form, BE is not ready yet.

Related JIRA tickets

SNT-285

Changes

What is done:

  • This is still using dummies as BE is not ready yet.
  • Added a new page for intervention assignment V2.
  • Added Scenario rule form
  • Cover Create, Update and Delete

What still need to be done:

  • Better validation
  • Connect to the Back-end and don't use dummies anymore

How to test

Print screen / video

N/A

Notes

This is a first PR, state is far from final but to reduce the size of the PR I will do this in multiple steps.
This is not visible by the end user unless they know the url, in which case, it is fine.
This does not yet connect to the Backend

Related IASO PR: BLSQ/iaso#2752

Doc

N/A

Copy link
Member

@quang-le quang-le left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the enum thing that is a bit annoying I know.
The rest is mostly comments at this stage

Comment on lines 1 to 5
export enum LegendTypes {
THRESHOLD = 'threshold',
ORDINAL = 'ordinal',
SCALE = 'scale',
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use TS enums please, they are TS dirty little secret. On a serious note, when using enums, TS code in not just JS code + types anymore, so I'm not sure the babel plugin we use support it (we don't use the TS compiler IIRC, we just remove all TS typing)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allright, I'll replace this with a json object then

const groupedOptions = useMemo(
() =>
groupOptions
? options.reduce(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using reduce to produce a dictionary, and then we convert the dictionary to a list to iterate on its values?
I think that:

  • forEach would be more legible
  • You should output an array directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I do like the syntax of reduce though, downside is indeed the double loop through, let me change that.

Comment on lines 100 to 117
<MenuList>
{groupOptions ? (
Object.values(groupedOptions).map(group => (
<Fragment key={group.label}>
<ListSubheader>{group.label}</ListSubheader>
<DropdownOptionItems
options={group.options}
onClick={handleOnClick}
/>
</Fragment>
))
) : (
<DropdownOptionItems
options={options}
onClick={handleOnClick}
/>
)}
</MenuList>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth grouping this and groupedOptions in a component at some point, when the feature get finalized

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would split that in 2 components

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean, in two files ?

},
};

const list_field_key = 'matching_criteria';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uppercase for constants. We're not consistent with this, I know, but I think it's good practice


export const useCreateUpdateScenarioRule = (
scenarioId: number,
): UseMutationResult =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can type this when you have the backend

import { useSnackMutation } from 'Iaso/libs/apiHooks';
import { MESSAGES } from '../../messages';

export const useDeleteScenarioRule = (scenarioId: number): UseMutationResult =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same same

// );

// return response?.results || [];
return dummyScenarioRulesResponse;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a waitFor util that allows yo to make the queryFn truly async so you can test the loading state

@Bewi Bewi requested a review from quang-le February 19, 2026 16:13
@Bewi Bewi force-pushed the SNT-285-i-can-create-a-assignment-rule branch from 6c3c337 to 05a40b7 Compare February 19, 2026 19:18
@Bewi Bewi merged commit ec959f0 into main Feb 19, 2026
2 checks passed
@Bewi Bewi deleted the SNT-285-i-can-create-a-assignment-rule branch February 19, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants