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

22 odpc minimaal document in publicatieformulier #48

Merged
merged 19 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
94 changes: 72 additions & 22 deletions odpc.client/mock/api.mock.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
import { type MockHandler } from "vite-plugin-mock-server";
import type { Publicatie } from "@/features/publicatie/types";
import { randomUUID } from "crypto";
import type { Publicatie, MimeTypes, PublicatieDocument } from "@/features/publicatie/types";

import publicatiesJson from "./publicaties.json";
import documentenJson from "./documenten.json";
import mimeTypesJson from "./mime-types.json";

const getIndex = (url: string | undefined) => +(url?.substring(url.lastIndexOf("/") + 1) || 0); // ...

const publicaties: Publicatie[] = [
{
uuid: "0",
officieleTitel:
"Openbaarheid en Verantwoording: De Impact van de Wet open overheid op Bestuurlijke Transparantie",
verkorteTitel: "Openbaarheid en Verantwoording",
omschrijving: "",
creatiedatum: "2024-08-24"
},
{
uuid: "1",
officieleTitel: "Inzicht voor Iedereen: Toepassing en Resultaten van de Wet open overheid",
verkorteTitel: "Inzicht voor Iedereen",
omschrijving: "",
creatiedatum: "2024-05-02"
}
];
const publicaties: Publicatie[] = publicatiesJson;
const documenten: PublicatieDocument[] = documentenJson;
const mimeTypes: MimeTypes[] = mimeTypesJson;

const mocks: MockHandler[] = [
{
pattern: "/api-mock/publicaties",
pattern: "/api-mock/v1/publicaties",
method: "GET",
handle: (_req, res) => {
res.setHeader("Content-Type", "application/json");
Expand All @@ -32,7 +23,7 @@ const mocks: MockHandler[] = [
}
},
{
pattern: "/api-mock/publicaties",
pattern: "/api-mock/v1/publicaties",
method: "POST",
handle: (req, res) => {
res.setHeader("Content-Type", "application/json");
Expand All @@ -50,7 +41,7 @@ const mocks: MockHandler[] = [
}
},
{
pattern: "/api-mock/publicaties/*",
pattern: "/api-mock/v1/publicaties/*",
method: "GET",
handle: (req, res) => {
res.setHeader("Content-Type", "application/json");
Expand All @@ -59,7 +50,7 @@ const mocks: MockHandler[] = [
}
},
{
pattern: "/api-mock/publicaties/*",
pattern: "/api-mock/v1/publicaties/*",
method: "PUT",
handle: (req, res) => {
res.setHeader("Content-Type", "application/json");
Expand All @@ -72,6 +63,65 @@ const mocks: MockHandler[] = [
setTimeout(() => res.end(JSON.stringify(publicatie)), 500);
});
}
},
{
pattern: "/api-mock/v1/documenten/*",
method: "GET",
handle: (_req, res) => {
res.setHeader("Content-Type", "application/json");

setTimeout(() => res.end(JSON.stringify(documenten[0])), 500);
}
},
{
pattern: "/api-mock/v1/documenten/**",
method: "POST",
handle: (req, res) => {
res.setHeader("Content-Type", "application/json");

req.on("data", (bodyString: string) => {
const body: any = JSON.parse(bodyString);
const { bestandsomvang } = body;

const uuid = randomUUID();
const halve = bestandsomvang / 2;
const firstSize = Math.ceil(halve);
const secondSize = Math.floor(halve);

const responseBody = {
...documenten[0],
bestandsdelen: [
{
url: `/api-mock/v1/documenten/${uuid}/bestandsdelen/1`,
volgnummer: 0,
omvang: firstSize
},
{
url: `/api-mock/v1/documenten/${uuid}/bestandsdelen/2`,
volgnummer: 1,
omvang: secondSize
}
]
};

setTimeout(() => res.end(JSON.stringify(responseBody)), 500);
});
}
},
{
pattern: "/api-mock/v1/documenten/*/bestandsdelen/*",
method: "PUT",
handle: (_req, res) => {
setTimeout(() => res.end(), 500);
}
},
{
pattern: "/api-mock/v1/formats",
method: "GET",
handle: (_req, res) => {
res.setHeader("Content-Type", "application/json");
setTimeout(() => res.end(JSON.stringify(mimeTypes)), 500);
}
}
];

Expand Down
13 changes: 13 additions & 0 deletions odpc.client/mock/documenten.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"uuid": "0",
"publicatie": "0",
"officieleTitel": "Belangrijk document",
"verkorteTitel": "Document",
"omschrijving": "",
"creatiedatum": "2024-09-23",
"bestandsnaam": "belangrijk.docx",
"bestandsformaat": "DOCX",
"bestandsomvang": 100000
}
]
85 changes: 85 additions & 0 deletions odpc.client/mock/mime-types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[
{
"name": "7z",
"mimeType": "application/x-7z-compressed",
"identifier": "a81129a3-ec70-40f3-8eb6-fc94e97ef865"
},
{ "name": "CSV", "mimeType": "text/csv", "identifier": "6bdd2631-b5d5-472a-b336-9cc643822f0a" },
{
"name": "Excel XLS",
"mimeType": "application/vnd.ms-excel",
"identifier": "822928f7-73f0-45d3-b1a0-4f3a3dbc361a"
},
{
"name": "Excel XLSX",
"mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"identifier": "fd16ded8-f013-4ca7-ba21-ee3ca36a6054"
},
{ "name": "HTML", "mimeType": "text/html", "identifier": "bf16a8af-f40b-4e36-96e3-0bdd5d6f5316" },
{
"name": "ODF",
"mimeType": "application/vnd.oasis.opendocument.formula",
"identifier": "26a3df9c-290c-40a4-98cb-387842816698"
},
{
"name": "ODP",
"mimeType": "application/vnd.oasis.opendocument.presentation",
"identifier": "8b31aa20-d284-4540-aca4-222e1394c1d5"
},
{
"name": "ODS",
"mimeType": "application/vnd.oasis.opendocument.spreadsheet",
"identifier": "837abc18-616f-4e82-945b-fe78ab939860"
},
{
"name": "ODT",
"mimeType": "application/vnd.oasis.opendocument.text",
"identifier": "53b7d662-4413-4901-a3a4-6c129fcb93c1"
},
{
"name": "PDF",
"mimeType": "application/pdf",
"identifier": "a8836b30-8b25-4af6-9b35-e68e4f644c59"
},
{ "name": "TXT", "mimeType": "text/plain", "identifier": "549c6a31-6274-4b51-8528-fa9de141681e" },
{
"name": "PPSX",
"mimeType": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
"identifier": "ff7cf4ad-372f-4996-b6af-5bf8c5b178d8"
},
{
"name": "PPT",
"mimeType": "application/vnd.ms-powerpoint",
"identifier": "580e3592-c5b2-40d0-ab7a-0c626c8e171a"
},
{
"name": "PPTX",
"mimeType": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"identifier": "fc188a40-f0bf-415f-a339-fd7520b531f8"
},
{
"name": "PPS",
"mimeType": "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
"identifier": "65298a3a-346d-4614-9fee-028f532ed8bc"
},
{
"name": "RTF",
"mimeType": "application/rtf",
"identifier": "63026476-5d40-424e-a113-b02ed7fba760"
},
{
"name": "DOC",
"mimeType": "application/msword",
"identifier": "26ccc5e3-acf2-4251-9618-46321e2b9d36"
},
{
"name": "DOCX",
"mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"identifier": "ae0ea877-3207-4a97-b5df-bf552bc9b895"
},
{
"name": "ZIP",
"mimeType": "application/zip",
"identifier": "f879f55e-a9c2-4779-96b2-288d6359d86b"
}
]
16 changes: 16 additions & 0 deletions odpc.client/mock/publicaties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"uuid": "0",
"officieleTitel": "Openbaarheid en Verantwoording: De Impact van de Wet open overheid op Bestuurlijke Transparantie",
"verkorteTitel": "Openbaarheid en Verantwoording",
"omschrijving": "",
"creatiedatum": "2024-08-24"
},
{
"uuid": "1",
"officieleTitel": "Inzicht voor Iedereen: Toepassing en Resultaten van de Wet open overheid",
"verkorteTitel": "Inzicht voor Iedereen",
"omschrijving": "",
"creatiedatum": "2024-05-02"
}
]
3 changes: 2 additions & 1 deletion odpc.client/src/assets/simple.css
Original file line number Diff line number Diff line change
Expand Up @@ -709,5 +709,6 @@ sub {
border: 2px solid var(--border);
border-radius: var(--standard-border-radius);
padding: 1.5rem;
margin: 2rem 0;
margin-block-start: 0;
margin-block-end: 2rem;
}
Loading