Skip to content

Commit

Permalink
wip: some redirect logic frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbjoralt committed Oct 19, 2023
1 parent 890f169 commit 1c5af9f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import FilteredConsultantsList from "@/components/FilteredConsultantsList";
import { fetchWithToken } from "@/data/fetchWithToken";
import { Consultant } from "@/types";

export default async function Bemanning() {
const consultants = (await fetchWithToken<Consultant[]>("consultants")) ?? [];
export default async function Bemanning({params}: {params: {organisation: string}}) {
const consultants = (await fetchWithToken<Consultant[]>(`${params.organisation}/consultants`)) ?? [];

return (
<div>
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { redirect } from "next/navigation";
import { fetchWithToken } from "@/data/fetchWithToken";
import { Consultant, Organisation } from "@/types";
import Link from "next/link";

export default function Root() {
redirect("/bemanning");
export default async function Root() {
const orgs = await fetchWithToken<Organisation[]>('organisations') ?? []
return <ul>
{orgs.map(o => <li key={o.urlKey}><Link href={`/${o.urlKey}/bemanning`}>{o.name}</Link></li>)}
</ul>
//redirect("/bemanning");
}
2 changes: 1 addition & 1 deletion frontend/src/components/DepartmentFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fetchWithToken } from "@/data/fetchWithToken";
import { Department } from "@/types";

export default async function DepartmentFilter() {
const departments = (await fetchWithToken<Department[]>("departments")) ?? [];
const departments = (await fetchWithToken<Department[]>("organisations/variant-norge/departments")) ?? [];

if (departments.length > 0) {
return (
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PopoverVirtualElement } from "@mui/material";

export type Consultant = {
id: string;
name: string;
Expand All @@ -17,3 +19,16 @@ export type Department = {
id: string;
name: string;
};

export type Organisation = {
name: string,
urlKey: string
}

export type AnchorProp =
| Element
| (() => Element)
| PopoverVirtualElement
| (() => PopoverVirtualElement)
| null
| undefined;

0 comments on commit 1c5af9f

Please sign in to comment.