-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #537 from Open-Earth-Foundation/feat/connect-inven…
…tory-v2 Connect add data pages
- Loading branch information
Showing
15 changed files
with
1,894 additions
and
828 deletions.
There are no files selected for viewing
File renamed without changes.
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
2,470 changes: 1,663 additions & 807 deletions
2,470
app/src/app/[lng]/[inventory]/data/[step]/[subsector]/page.tsx
Large diffs are not rendered by default.
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
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,12 +1,21 @@ | ||
import UserService from "@/backend/UserService"; | ||
import { db } from "@/models"; | ||
import { apiHandler } from "@/util/api"; | ||
import { PopulationEntry, findClosestYearToInventory } from "@/util/helpers"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export const GET = apiHandler(async (_req: Request, { session, params }) => { | ||
const city = await UserService.findUserCity(params.city, session); | ||
const population = await db.models.Population.findOne({ | ||
where: { cityId: city?.cityId, year: params.year }, | ||
const population = await db.models.Population.findAll({ | ||
where: { cityId: city?.cityId }, | ||
}); | ||
return NextResponse.json({ data: population }); | ||
}); | ||
const populations: PopulationEntry[] = population.map(({population, year})=>{ | ||
return { | ||
year, | ||
population: population! | ||
} | ||
}) | ||
|
||
const closestYearPopulationData = findClosestYearToInventory(populations, parseInt(params.year)) | ||
return NextResponse.json({ data: closestYearPopulationData }); | ||
}); |
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 |
---|---|---|
|
@@ -134,4 +134,4 @@ export default class CDPService { | |
logger.debug(`Response: ${res.statusText}`); | ||
return true; | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.