-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55456ac
commit 305e995
Showing
4 changed files
with
114 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { NextResponse } from "next/server" | ||
import type { Incubator } from "@/types/incubator" | ||
import type { Startup } from "@/types/startup" | ||
|
||
interface BetaGouvStartupsData { | ||
links: { | ||
self: string | ||
} | ||
data: Startup[] | ||
included: Incubator[] | ||
} | ||
|
||
export async function GET() { | ||
const res = await fetch("https://beta.gouv.fr/api/v2.5/startups.json", { | ||
cache: "no-store", | ||
}) | ||
|
||
const betaGouvData: BetaGouvStartupsData = await res.json() | ||
|
||
const ourStartups = betaGouvData.data | ||
.filter((startup) => { | ||
return startup.relationships.incubator.data.id === "sgmas" | ||
}) | ||
.map((startup) => { | ||
// remove the incubator relationship | ||
// delete startup.relationships | ||
// delete startup.attributes?.content_url_encoded_markdown | ||
const { relationships, attributes, ...rest } = startup | ||
const { content_url_encoded_markdown, ...restAttributes } = attributes | ||
return { | ||
...rest, | ||
attributes: restAttributes, | ||
} | ||
}) | ||
|
||
return NextResponse.json({ data: ourStartups }) | ||
} |
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,9 +1,27 @@ | ||
import { fr } from "@codegouvfr/react-dsfr" | ||
|
||
export default function Startups() { | ||
async function getData() { | ||
const res = await fetch("http://localhost:3000/api/startups") | ||
// The return value is *not* serialized | ||
// You can return Date, Map, Set, etc. | ||
|
||
if (!res.ok) { | ||
// This will activate the closest `error.js` Error Boundary | ||
throw new Error("Failed to fetch data") | ||
} | ||
|
||
return res.json() | ||
} | ||
|
||
export const revalidate = 3600 // revalidate at most every hour | ||
|
||
export default async function Recrutement() { | ||
const data = await getData() | ||
|
||
return ( | ||
<section> | ||
<h1 className={fr.cx("fr-h1")}>Nos startups</h1> | ||
<h1 className={fr.cx("fr-h1")}>Recrutement</h1> | ||
<pre>{JSON.stringify(data, null, 2)}</pre> | ||
</section> | ||
) | ||
} |
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,11 @@ | ||
export interface Incubator { | ||
id: string | ||
type: string | ||
attributes: { | ||
title: string | ||
owner: string | ||
website: string | ||
github: string | ||
contact: string | ||
} | ||
} |
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,46 @@ | ||
export interface Startup { | ||
id: string | ||
type: string | ||
attributes: { | ||
name: string | ||
pitch: string | ||
stats_url?: string | ||
budget_url?: string | ||
link?: string | ||
repository?: string | ||
contact: string | ||
content_url_encoded_markdown: string | ||
events: StartupEvent[] | ||
phases: StartupPhase[] | ||
analyse_risques?: string | ||
analyse_risques_url?: string | ||
dashlord_url?: string | ||
accessibility_status?: string | ||
} | ||
relationships: { | ||
incubator: { | ||
data: { | ||
type: "incubator" | ||
id: string | ||
} | ||
} | ||
} | ||
} | ||
|
||
interface StartupEvent { | ||
name: string | ||
date: string | ||
comment: string | ||
} | ||
|
||
interface StartupPhase { | ||
name: | ||
| "acceleration" | ||
| "alumni" | ||
| "construction" | ||
| "investigation" | ||
| "success" | ||
| "transfer" | ||
start: string | ||
end: string | ||
} |