Skip to content

Commit

Permalink
Merge pull request #8 from OpenUpSA/feature/image-store
Browse files Browse the repository at this point in the history
Feature/image store
  • Loading branch information
paulmwatson authored Jul 8, 2024
2 parents 7913226 + ea3226b commit 9b8be41
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
14 changes: 4 additions & 10 deletions app/api/power-stations/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function GET(req: Request) {
"Decommission start",
"Decommission end",
"Thumbnail image",
"Short description"
"Short description",
],
});
const powerStations: PowerStation[] = [];
Expand Down Expand Up @@ -103,20 +103,14 @@ export async function GET(req: Request) {
decommissionEnd: new Date(fields["Decommission end"] as string),
years: 0,
},
description: fields["Short description"] as PowerStation["description"],
description: fields[
"Short description"
] as PowerStation["description"],
};

if (fields["Thumbnail image"]) {
const image: any = (fields["Thumbnail image"] as any)[0];
powerStation.images = {
small: {
id: image.id,
url: image.thumbnails.small.url,
width: image.thumbnails.small.width,
height: image.thumbnails.small.height,
filename: image.filename,
type: image.type,
},
large: {
id: image.id,
url: image.thumbnails.large.url,
Expand Down
4 changes: 2 additions & 2 deletions components/filterPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ function Component(props: Props) {
case "power":
newParams.delete("power");
break;

}
window.history.pushState(null, "", `?${newParams.toString()}`);
};
Expand Down Expand Up @@ -342,7 +341,8 @@ function Component(props: Props) {
async function getData() {
initialized.current = true;
const res = await fetch(
`${process.env.NEXT_PUBLIC_URL}/api/power-stations`
`${process.env.NEXT_PUBLIC_URL}/api/power-stations`,
{ next: { revalidate: 3600 } }
);
const powerStationsData = await res.json();
setPowerStations(powerStationsData.powerStations);
Expand Down
3 changes: 2 additions & 1 deletion components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ function Component({ powerStations, panelOpen, setPanelOpen }: Props) {
async function getData() {
if (sidePanelEntity) {
const res = await fetch(
`${process.env.NEXT_PUBLIC_URL}/api/entity-info?id=${sidePanelEntity}`
`${process.env.NEXT_PUBLIC_URL}/api/entity-info?id=${sidePanelEntity}`,
{ next: { revalidate: 3600 } }
);
const entityInfoData = await res.json();
setSidePanelEntityInfo(entityInfoData);
Expand Down
1 change: 0 additions & 1 deletion types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export type PowerStation = {
operator?: Entity;
owner?: Entity;
images?: {
small: Image;
large: Image;
full: Image;
};
Expand Down

0 comments on commit 9b8be41

Please sign in to comment.