Skip to content

Commit

Permalink
Add strength_of_knowledge field to risk scenario update form
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Feb 21, 2024
1 parent 408e416 commit 6085a1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/lib/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const RiskScenarioSchema = baseNamedObject({
residual_proba: z.number().optional(),
residual_impact: z.number().optional(),
treatment: z.string().optional(),
strength_of_knowledge: z.string().optional(),
justification: z.string().optional().nullable(),
risk_assessment: z.string(),
threats: z.string().uuid().optional().array(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ export const load: PageServerLoad = async ({ params, fetch }) => {
}))
);

const strengthOfKnowledgeChoicesEndpoint = `${BASE_API_URL}/${URLModel}/strength_of_knowledge/`;
const strengthOfKnowledgeChoices = await fetch(strengthOfKnowledgeChoicesEndpoint)
.then((res) => res.json())
.then((data) =>
Object.entries(data).map(([key, value]) => ({
label: value,
value: key
}))
);

const measureCreateSchema = modelSchema('security-measures');
const initialData = {
folder: scenario.project.folder.id
Expand Down Expand Up @@ -170,6 +180,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => {
probabilityChoices,
impactChoices,
treatmentChoices,
strengthOfKnowledgeChoices,
tables,
measureModel,
measureCreateForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@
</div>
</div>
<div class="card px-4 py-2 bg-white shadow-lg">
<Select
{form}
options={data.strengthOfKnowledgeChoices}
field="strength_of_knowledge"
label="Strength of knowledge"
/>
<TextArea {form} field="justification" label="Justification" />
</div>
<div class="flex flex-row justify-between space-x-4">
Expand Down

0 comments on commit 6085a1f

Please sign in to comment.