-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 Start workin on destruction list create page
- Loading branch information
1 parent
05d5c53
commit b114b63
Showing
15 changed files
with
6,780 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
import { NavigationContext, Outline } from "@maykin-ui/admin-ui"; | ||
import React from "react"; | ||
import { Outlet, useNavigate } from "react-router-dom"; | ||
|
||
import "./App.css"; | ||
|
||
export type AppProps = React.ComponentProps<"div">; | ||
|
||
function App({ children }: AppProps) { | ||
return <div className="App">{children}</div>; | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<div className="App"> | ||
<NavigationContext.Provider | ||
value={{ | ||
primaryNavigationItems: [ | ||
{ | ||
children: <Outline.HomeIcon />, | ||
title: "Home", | ||
onClick: () => navigate("/"), | ||
}, | ||
"spacer", | ||
{ | ||
children: <Outline.ArrowRightOnRectangleIcon />, | ||
title: "Uitloggen", | ||
onClick: () => navigate("/logout"), | ||
}, | ||
], | ||
}} | ||
> | ||
<Outlet /> | ||
</NavigationContext.Provider> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DestructionListCreatePage { | ||
/* Rules here. */ | ||
} |
17 changes: 17 additions & 0 deletions
17
frontend/src/pages/destructionlist/DestructionListCreate.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { DestructionListCreatePage } from "./DestructionListCreate"; | ||
|
||
const meta: Meta<typeof DestructionListCreatePage> = { | ||
title: "Pages/DestructionList/DestructionListCreatePage", | ||
component: DestructionListCreatePage, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const destructionListCreatePage: Story = { | ||
args: { | ||
children: "The quick brown fox jumps over the lazy dog.", | ||
}, | ||
}; |
92 changes: 92 additions & 0 deletions
92
frontend/src/pages/destructionlist/DestructionListCreate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { | ||
AttributeData, | ||
DataGridProps, | ||
List, | ||
TypedField, | ||
} from "@maykin-ui/admin-ui"; | ||
import React from "react"; | ||
import { useLoaderData } from "react-router-dom"; | ||
|
||
import { loginRequired } from "../../lib/api/loginRequired"; | ||
import { PaginatedZaken, listZaken } from "../../lib/api/zaken"; | ||
import { Zaak } from "../../types"; | ||
import "./DestructionListCreate.css"; | ||
|
||
/** | ||
* React Router loader. | ||
* @param request | ||
* TOOD: Requires destruction list lists endpoint. | ||
*/ | ||
export const destructionListCreateLoader = loginRequired(listZaken); | ||
|
||
export type DestructionListCreateProps = React.ComponentProps<"main"> & { | ||
// Props here. | ||
}; | ||
|
||
/** | ||
* Destruction list creation page | ||
*/ | ||
export function DestructionListCreatePage({ | ||
children, | ||
...props | ||
}: DestructionListCreateProps) { | ||
const { count, results } = useLoaderData() as PaginatedZaken; | ||
const objectList = transformZakenForPresentation(results); | ||
|
||
console.log(results, objectList); | ||
|
||
const fields: TypedField[] = [ | ||
{ name: "identificatie", type: "string" }, | ||
{ name: "zaaktype", type: "string" }, | ||
{ name: "omschrijving", type: "string" }, | ||
{ name: "looptijd", type: "string" }, | ||
{ name: "resultaattype", type: "string" }, | ||
{ name: "bewaartermijn", type: "string" }, | ||
{ name: "vcs", type: "string" }, | ||
{ name: "relaties", type: "boolean" }, | ||
]; | ||
|
||
return ( | ||
<List | ||
count={count} | ||
fields={fields} | ||
objectList={objectList} | ||
labelSelect={"Selecteer item"} // FIXME: optional | ||
labelSelectAll={"Selecteer alle items"} // FIXME: optional | ||
pageSize={10} | ||
showPaginator={false} // TODO | ||
selectable={false} // TODO | ||
dataGridProps={ | ||
// FIXME: Required attrs, alias | ||
{ | ||
boolProps: { | ||
explicit: true, | ||
labelFalse: "Nee", // FIXME: optinal | ||
}, | ||
filterable: true, | ||
} as DataGridProps | ||
} | ||
title="Vernietigingslijst starten" | ||
/> | ||
); | ||
} | ||
|
||
export function transformZakenForPresentation(zaken: Zaak[]) { | ||
return zaken.map<AttributeData>((zaak) => { | ||
const startDate = new Date(zaak.startdatum); | ||
const endDate = zaak.einddatum ? new Date(zaak.einddatum) : new Date(); | ||
const dayDelta = | ||
(endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24); | ||
|
||
return { | ||
identificatie: zaak.identificatie || "", | ||
zaaktype: zaak.zaaktype, | ||
omschrijving: zaak.omschrijving || "", | ||
looptijd: String(dayDelta), | ||
resultaattype: "TODO", | ||
bewaartermijn: "TODO", | ||
vcs: "TODO", | ||
relaties: Boolean(zaak?.relevanteAndereZaken?.length || 0), | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./DestructionListCreate"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// Auto-generated file. Do not modify manually. | ||
export * from "./destructionlist"; | ||
export * from "./landing"; | ||
export * from "./login"; | ||
export * from "./logout"; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,10 @@ | ||
import React from "react"; | ||
import { useLoaderData } from "react-router-dom"; | ||
import { redirect, useLoaderData } from "react-router-dom"; | ||
|
||
import { loginRequired } from "../../lib/api/loginRequired"; | ||
import { listReviewers } from "../../lib/api/reviewers"; | ||
import "./Landing.css"; | ||
|
||
/** | ||
* React Router loader. | ||
* @param request | ||
* TOOD: Requires destruction list lists endpoint. | ||
*/ | ||
export const landingLoader = loginRequired(listReviewers); | ||
|
||
export type LandingProps = React.ComponentProps<"main"> & { | ||
// Props here. | ||
}; | ||
|
||
/** | ||
* Landing page | ||
*/ | ||
export function LandingPage({ children, ...props }: LandingProps) { | ||
const items = useLoaderData(); | ||
|
||
return ( | ||
<main className="LandingPage" {...props}> | ||
{JSON.stringify(items)} | ||
</main> | ||
); | ||
} | ||
export const landingLoader = () => redirect("/destruction-lists/create"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.