Skip to content

Commit 1ff4744

Browse files
Xaohssvenvandescheur
authored andcommitted
✨ - feat: pr fixes
1 parent afcb908 commit 1ff4744

File tree

9 files changed

+40
-85
lines changed

9 files changed

+40
-85
lines changed

frontend/src/lib/api/config.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
import { request } from "./request";
22

3-
export type GetArchiveConfigReturn = {
3+
export type ArchiveConfiguration = {
44
zaaktypesShortProcess: string[]; // List of zaaktypes that should use the short process
55
};
66
/**
77
* API call to get the archive configuration
8-
* @returns {Promise<GetArchiveConfigReturn>} The archive configuration
8+
* @returns {Promise<ArchiveConfiguration>} The archive configuration
99
* @throws {Error} If the request fails
1010
* @example
1111
* const archiveConfig = await getArchiveConfig();
1212
* console.log(archiveConfig);
1313
*/
14-
export async function getArchiveConfig(): Promise<GetArchiveConfigReturn> {
14+
export async function getArchiveConfig(): Promise<ArchiveConfiguration> {
1515
const response = await request("GET", "/archive-config");
16-
const promise: Promise<GetArchiveConfigReturn> = response.json();
16+
const promise: Promise<ArchiveConfiguration> = response.json();
1717
return promise;
1818
}
1919

20-
export type PatchArchiveConfigPayload = GetArchiveConfigReturn;
21-
export type PatchArchiveConfigReturn = void;
2220
/**
2321
* API call to PATCH the archive configuration
24-
* @param {PatchArchiveConfigPayload} archiveConfig The archive configuration
25-
* @returns {Promise<PatchArchiveConfigReturn>} The archive configuration
22+
* @param {ArchiveConfiguration } archiveConfig The archive configuration
23+
* @returns {Promise<void>} The archive configuration
2624
* @throws {Error} If the request fails
2725
* @example
2826
* await patchArchiveConfig(archiveConfig);
2927
* console.log("Archive configuration updated");
3028
*/
3129
export async function patchArchiveConfig(
32-
archiveConfig: PatchArchiveConfigPayload,
30+
archiveConfig: ArchiveConfiguration,
3331
): Promise<void> {
3432
const response = await request(
3533
"PATCH",
-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
.SettingsPage {
22
/* Rules here. */
33
}
4-
5-
.mykn-body {
6-
width: 100%;
7-
}
8-
9-
.mykn-card {
10-
padding: 20px;
11-
}

frontend/src/pages/settings/Settings.stories.tsx

+15-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,21 @@ const meta: Meta<typeof SettingsPage> = {
1212
export default meta;
1313
type Story = StoryObj<typeof meta>;
1414

15+
const FIXTURE = {
16+
zaaktypesShortProcess: ["1", "2", "3"],
17+
zaaktypeChoices: [
18+
{ value: 1, label: "Zaaktype 1" },
19+
{ value: 2, label: "Zaaktype 2" },
20+
{ value: 3, label: "Zaaktype 3" },
21+
],
22+
};
23+
1524
export const settingsPage: Story = {
16-
args: {
17-
children: "The quick brown fox jumps over the lazy dog.",
25+
parameters: {
26+
reactRouterDecorator: {
27+
route: {
28+
loader: async () => FIXTURE,
29+
},
30+
},
1831
},
1932
};

frontend/src/pages/settings/Settings.tsx

+14-32
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import {
2-
BaseTemplate,
32
Body,
3+
Card,
4+
CardBaseTemplate,
45
Column,
56
Form,
67
FormField,
78
Grid,
8-
H1,
9+
H2,
910
Modal,
1011
P,
1112
SerializedFormData,
1213
} from "@maykin-ui/admin-ui";
13-
import { FormEvent, Fragment, useState } from "react";
14+
import { FormEvent, useState } from "react";
1415
import { useLoaderData } from "react-router-dom";
1516

1617
import { useSubmitAction } from "../../hooks";
1718
import "./Settings.css";
18-
import { SettingsSection, SettingsSectionProps } from "./components";
1919
import { UpdateSettingsAction } from "./settings.action";
2020
import { SettingsContext } from "./settings.loader";
2121

@@ -61,23 +61,8 @@ export function SettingsPage({ children, ...props }: SettingsPageProps) {
6161
setModalOpenState(true);
6262
};
6363

64-
const settingsArray: SettingsSectionProps[] = [
65-
{
66-
settingTitle: "Verkorte procedure",
67-
settingDescription:
68-
"Pas hier de zaaktypes aan die in aanmerking komen voor de verkorte procedure.",
69-
children: (
70-
<Form
71-
fields={verkorteProcedureFormFields}
72-
validateOnChange={true}
73-
onSubmit={handleSubmitPatchArchiveConfig}
74-
/>
75-
),
76-
},
77-
];
78-
7964
return (
80-
<BaseTemplate>
65+
<CardBaseTemplate>
8166
<Modal
8267
title={"Instellingen opgeslagen"}
8368
open={modalOpenState}
@@ -91,25 +76,22 @@ export function SettingsPage({ children, ...props }: SettingsPageProps) {
9176
<Body>
9277
<Grid>
9378
<Column span={12}>
94-
<H1>Instellingen</H1>
79+
<H2>Instellingen</H2>
9580
<P>
9681
Hier kun je instellingen aanpassen die van invloed zijn op de
9782
applicatie.
9883
</P>
9984
<br />
100-
<br />
10185
</Column>
10286
</Grid>
103-
<Grid cols={4}>
104-
{settingsArray.map((setting, index) => (
105-
<Fragment key={index}>
106-
<SettingsSection {...setting} />
107-
{/* TODO: Can add a Separator here once we have more setting entries. Currently we don't have a Separator component. For example: */}
108-
{/* {index < settingsArray.length - 1 && <Separator />} */}
109-
</Fragment>
110-
))}
111-
</Grid>
87+
<Card>
88+
<Form
89+
fields={verkorteProcedureFormFields}
90+
validateOnChange={true}
91+
onSubmit={handleSubmitPatchArchiveConfig}
92+
/>
93+
</Card>
11294
</Body>
113-
</BaseTemplate>
95+
</CardBaseTemplate>
11496
);
11597
}

frontend/src/pages/settings/components/SettingsSection.tsx

-25
This file was deleted.

frontend/src/pages/settings/components/index.ts

-1
This file was deleted.

frontend/src/pages/settings/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * from "./components";
21
export * from "./Settings";
32
export * from "./settings.action";
43
export * from "./settings.loader";

frontend/src/pages/settings/settings.action.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { ActionFunctionArgs } from "react-router-dom";
22

33
import { JsonValue, TypedAction } from "../../hooks";
4-
import {
5-
PatchArchiveConfigPayload,
6-
patchArchiveConfig,
7-
} from "../../lib/api/config";
4+
import { ArchiveConfiguration, patchArchiveConfig } from "../../lib/api/config";
85

96
export type UpdateSettingsAction<T = JsonValue> = TypedAction<
107
"PATCH-ARCHIVE-CONFIG",
@@ -28,7 +25,7 @@ export async function settingsAction({ request, params }: ActionFunctionArgs) {
2825

2926
async function patchArchiveConfigAction({ request }: ActionFunctionArgs) {
3027
const { payload } = await request.json();
31-
const _payload = payload as PatchArchiveConfigPayload;
28+
const _payload = payload as ArchiveConfiguration;
3229
await patchArchiveConfig(_payload);
3330
return null;
3431
}

frontend/src/pages/settings/settings.loader.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { ActionFunctionArgs } from "react-router-dom";
22

3-
import { GetArchiveConfigReturn, getArchiveConfig } from "../../lib/api/config";
3+
import { ArchiveConfiguration, getArchiveConfig } from "../../lib/api/config";
44
import { ZaaktypeChoice, listZaaktypeChoices } from "../../lib/api/private";
55
import { loginRequired } from "../../lib/auth/loaders";
66

77
export type SettingsContext = {
8-
zaaktypesShortProcess: GetArchiveConfigReturn["zaaktypesShortProcess"];
8+
zaaktypesShortProcess: ArchiveConfiguration["zaaktypesShortProcess"];
99
zaaktypeChoices: ZaaktypeChoice[];
1010
};
1111

0 commit comments

Comments
 (0)