Adding page layout, added react query

This commit is contained in:
Khalim Conn-Kowlessar 2023-05-30 11:41:08 +01:00
parent 36085d5912
commit 3c160ea6a5
8 changed files with 140 additions and 790 deletions

44
package-lock.json generated
View file

@ -10,6 +10,7 @@
"dependencies": {
"@headlessui/react": "^1.7.14",
"@heroicons/react": "^2.0.18",
"@tanstack/react-query": "^4.29.12",
"@types/node": "20.2.3",
"@types/react": "18.2.7",
"@types/react-dom": "18.2.4",
@ -422,6 +423,41 @@
"tslib": "^2.4.0"
}
},
"node_modules/@tanstack/query-core": {
"version": "4.29.11",
"resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-4.29.11.tgz",
"integrity": "sha512-8C+hF6SFAb/TlFZyS9FItgNwrw4PMa7YeX+KQYe2ZAiEz6uzg6yIr+QBzPkUwZ/L0bXvGd1sufTm3wotoz+GwQ==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/tannerlinsley"
}
},
"node_modules/@tanstack/react-query": {
"version": "4.29.12",
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-4.29.12.tgz",
"integrity": "sha512-zhcN6+zF6cxprxhTHQajHGlvxgK8npnp9uLe9yaWhGc6sYcPWXzyO4raL4HomUzQOPzu3jLvkriJQ7BOrDM8vA==",
"dependencies": {
"@tanstack/query-core": "4.29.11",
"use-sync-external-store": "^1.2.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/tannerlinsley"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-native": "*"
},
"peerDependenciesMeta": {
"react-dom": {
"optional": true
},
"react-native": {
"optional": true
}
}
},
"node_modules/@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
@ -4312,6 +4348,14 @@
"punycode": "^2.1.0"
}
},
"node_modules/use-sync-external-store": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz",
"integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==",
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",

View file

@ -11,6 +11,7 @@
"dependencies": {
"@headlessui/react": "^1.7.14",
"@heroicons/react": "^2.0.18",
"@tanstack/react-query": "^4.29.12",
"@types/node": "20.2.3",
"@types/react": "18.2.7",
"@types/react-dom": "18.2.4",

View file

@ -0,0 +1,15 @@
"use client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
const queryClient = new QueryClient();
export const ReactQueryProvider = ({
children,
}: {
children: React.ReactNode;
}) => {
return (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
};

View file

@ -21,776 +21,11 @@ export async function GET(request: NextRequest) {
Authorization: `Basic ${process.env.EPC_AUTH_TOKEN ?? ""}`,
};
// const response = await fetch(url, {
// headers: headers,
// next: { revalidate: 60 },
// });
// const data = await response.json();
console.log("PUT ME BACK");
const data = {
rows: [
{
"low-energy-fixed-light-count": "1",
address: "53 Distillery Wharf, Regatta Lane",
"uprn-source": "Address Matched",
"floor-height": "",
"heating-cost-potential": "142",
"unheated-corridor-length": "",
"hot-water-cost-potential": "96",
"construction-age-band": "NO DATA!",
"potential-energy-rating": "B",
"mainheat-energy-eff": "Very Good",
"windows-env-eff": "Very Good",
"lighting-energy-eff": "Very Good",
"environment-impact-potential": "91",
"glazed-type": "NO DATA!",
"heating-cost-current": "142",
address3: "",
"mainheatcont-description":
"Charging system linked to use of community heating, TRVs",
"sheating-energy-eff": "N/A",
"property-type": "Flat",
"local-authority-label": "Hammersmith and Fulham",
"fixed-lighting-outlets-count": "1",
"energy-tariff": "standard tariff",
"mechanical-ventilation": "NO DATA!",
"hot-water-cost-current": "96",
county: "Greater London Authority",
postcode: "W6 9BF",
"solar-water-heating-flag": "",
constituency: "E14000726",
"co2-emissions-potential": "0.8",
"number-heated-rooms": "",
"floor-description": "Average thermal transmittance 0.19 W/m-¦K",
"energy-consumption-potential": "50",
"local-authority": "E09000013",
"built-form": "Mid-Terrace",
"number-open-fireplaces": "0",
"windows-description": "High performance glazing",
"glazed-area": "NO DATA!",
"inspection-date": "2017-04-05",
"mains-gas-flag": "",
"co2-emiss-curr-per-floor-area": "9",
address1: "53 Distillery Wharf",
"heat-loss-corridor": "NO DATA!",
"flat-storey-count": "",
"constituency-label": "Hammersmith",
"roof-energy-eff": "N/A",
"total-floor-area": "89.0",
"building-reference-number": "6013745278",
"environment-impact-current": "91",
"co2-emissions-current": "0.8",
"roof-description": "(other premises above)",
"floor-energy-eff": "Very Good",
"number-habitable-rooms": "",
address2: "Regatta Lane",
"hot-water-env-eff": "Very Good",
posttown: "LONDON",
"mainheatc-energy-eff": "Good",
"main-fuel": "NO DATA!",
"lighting-env-eff": "Very Good",
"windows-energy-eff": "Very Good",
"floor-env-eff": "Very Good",
"sheating-env-eff": "N/A",
"lighting-description": "Low energy lighting in all fixed outlets",
"roof-env-eff": "N/A",
"walls-energy-eff": "Very Good",
"photo-supply": "",
"lighting-cost-potential": "58",
"mainheat-env-eff": "Very Good",
"multi-glaze-proportion": "",
"main-heating-controls": "",
"lodgement-datetime": "2017-04-05 16:52:23",
"flat-top-storey": "",
"current-energy-rating": "B",
"secondheat-description": "None",
"walls-env-eff": "Very Good",
"transaction-type": "new dwelling",
uprn: "34154017",
"current-energy-efficiency": "86",
"energy-consumption-current": "50",
"mainheat-description": "Community scheme",
"lighting-cost-current": "58",
"lodgement-date": "2017-04-05",
"extension-count": "",
"mainheatc-env-eff": "Good",
"lmk-key": "1172153279062017040516522305558463",
"wind-turbine-count": "",
tenure: "unknown",
"floor-level": "mid floor",
"potential-energy-efficiency": "86",
"hot-water-energy-eff": "Very Good",
"low-energy-lighting": "100",
"walls-description": "Average thermal transmittance 0.16 W/m-¦K",
"hotwater-description": "Community scheme",
},
{
"low-energy-fixed-light-count": "1",
address: "55 Distillery Wharf, Regatta Lane",
"uprn-source": "Address Matched",
"floor-height": "",
"heating-cost-potential": "142",
"unheated-corridor-length": "",
"hot-water-cost-potential": "96",
"construction-age-band": "NO DATA!",
"potential-energy-rating": "B",
"mainheat-energy-eff": "Very Good",
"windows-env-eff": "Very Good",
"lighting-energy-eff": "Very Good",
"environment-impact-potential": "91",
"glazed-type": "NO DATA!",
"heating-cost-current": "142",
address3: "",
"mainheatcont-description":
"Charging system linked to use of community heating, TRVs",
"sheating-energy-eff": "N/A",
"property-type": "Flat",
"local-authority-label": "Hammersmith and Fulham",
"fixed-lighting-outlets-count": "1",
"energy-tariff": "standard tariff",
"mechanical-ventilation": "NO DATA!",
"hot-water-cost-current": "96",
county: "Greater London Authority",
postcode: "W6 9BF",
"solar-water-heating-flag": "",
constituency: "E14000726",
"co2-emissions-potential": "0.8",
"number-heated-rooms": "",
"floor-description": "Average thermal transmittance 0.19 W/m-¦K",
"energy-consumption-potential": "50",
"local-authority": "E09000013",
"built-form": "Mid-Terrace",
"number-open-fireplaces": "0",
"windows-description": "High performance glazing",
"glazed-area": "NO DATA!",
"inspection-date": "2017-04-05",
"mains-gas-flag": "",
"co2-emiss-curr-per-floor-area": "9",
address1: "53 Distillery Wharf",
"heat-loss-corridor": "NO DATA!",
"flat-storey-count": "",
"constituency-label": "Hammersmith",
"roof-energy-eff": "N/A",
"total-floor-area": "89.0",
"building-reference-number": "6013745278",
"environment-impact-current": "91",
"co2-emissions-current": "0.8",
"roof-description": "(other premises above)",
"floor-energy-eff": "Very Good",
"number-habitable-rooms": "",
address2: "Regatta Lane",
"hot-water-env-eff": "Very Good",
posttown: "LONDON",
"mainheatc-energy-eff": "Good",
"main-fuel": "NO DATA!",
"lighting-env-eff": "Very Good",
"windows-energy-eff": "Very Good",
"floor-env-eff": "Very Good",
"sheating-env-eff": "N/A",
"lighting-description": "Low energy lighting in all fixed outlets",
"roof-env-eff": "N/A",
"walls-energy-eff": "Very Good",
"photo-supply": "",
"lighting-cost-potential": "58",
"mainheat-env-eff": "Very Good",
"multi-glaze-proportion": "",
"main-heating-controls": "",
"lodgement-datetime": "2017-04-05 16:52:23",
"flat-top-storey": "",
"current-energy-rating": "B",
"secondheat-description": "None",
"walls-env-eff": "Very Good",
"transaction-type": "new dwelling",
uprn: "34154017",
"current-energy-efficiency": "86",
"energy-consumption-current": "50",
"mainheat-description": "Community scheme",
"lighting-cost-current": "58",
"lodgement-date": "2017-04-05",
"extension-count": "",
"mainheatc-env-eff": "Good",
"lmk-key": "117215937906201704320516522305558463",
"wind-turbine-count": "",
tenure: "unknown",
"floor-level": "mid floor",
"potential-energy-efficiency": "86",
"hot-water-energy-eff": "Very Good",
"low-energy-lighting": "100",
"walls-description": "Average thermal transmittance 0.16 W/m-¦K",
"hotwater-description": "Community scheme",
},
{
"low-energy-fixed-light-count": "1",
address: "10 Distillery Wharf, Regatta Lane",
"uprn-source": "Address Matched",
"floor-height": "",
"heating-cost-potential": "142",
"unheated-corridor-length": "",
"hot-water-cost-potential": "96",
"construction-age-band": "NO DATA!",
"potential-energy-rating": "B",
"mainheat-energy-eff": "Very Good",
"windows-env-eff": "Very Good",
"lighting-energy-eff": "Very Good",
"environment-impact-potential": "91",
"glazed-type": "NO DATA!",
"heating-cost-current": "142",
address3: "",
"mainheatcont-description":
"Charging system linked to use of community heating, TRVs",
"sheating-energy-eff": "N/A",
"property-type": "Flat",
"local-authority-label": "Hammersmith and Fulham",
"fixed-lighting-outlets-count": "1",
"energy-tariff": "standard tariff",
"mechanical-ventilation": "NO DATA!",
"hot-water-cost-current": "96",
county: "Greater London Authority",
postcode: "W6 9BF",
"solar-water-heating-flag": "",
constituency: "E14000726",
"co2-emissions-potential": "0.8",
"number-heated-rooms": "",
"floor-description": "Average thermal transmittance 0.19 W/m-¦K",
"energy-consumption-potential": "50",
"local-authority": "E09000013",
"built-form": "Mid-Terrace",
"number-open-fireplaces": "0",
"windows-description": "High performance glazing",
"glazed-area": "NO DATA!",
"inspection-date": "2017-04-05",
"mains-gas-flag": "",
"co2-emiss-curr-per-floor-area": "9",
address1: "53 Distillery Wharf",
"heat-loss-corridor": "NO DATA!",
"flat-storey-count": "",
"constituency-label": "Hammersmith",
"roof-energy-eff": "N/A",
"total-floor-area": "89.0",
"building-reference-number": "6013745278",
"environment-impact-current": "91",
"co2-emissions-current": "0.8",
"roof-description": "(other premises above)",
"floor-energy-eff": "Very Good",
"number-habitable-rooms": "",
address2: "Regatta Lane",
"hot-water-env-eff": "Very Good",
posttown: "LONDON",
"mainheatc-energy-eff": "Good",
"main-fuel": "NO DATA!",
"lighting-env-eff": "Very Good",
"windows-energy-eff": "Very Good",
"floor-env-eff": "Very Good",
"sheating-env-eff": "N/A",
"lighting-description": "Low energy lighting in all fixed outlets",
"roof-env-eff": "N/A",
"walls-energy-eff": "Very Good",
"photo-supply": "",
"lighting-cost-potential": "58",
"mainheat-env-eff": "Very Good",
"multi-glaze-proportion": "",
"main-heating-controls": "",
"lodgement-datetime": "2017-04-05 16:52:23",
"flat-top-storey": "",
"current-energy-rating": "B",
"secondheat-description": "None",
"walls-env-eff": "Very Good",
"transaction-type": "new dwelling",
uprn: "34154017",
"current-energy-efficiency": "86",
"energy-consumption-current": "50",
"mainheat-description": "Community scheme",
"lighting-cost-current": "58",
"lodgement-date": "2017-04-05",
"extension-count": "",
"mainheatc-env-eff": "Good",
"lmk-key": "11721593790620170405165223055583123",
"wind-turbine-count": "",
tenure: "unknown",
"floor-level": "mid floor",
"potential-energy-efficiency": "86",
"hot-water-energy-eff": "Very Good",
"low-energy-lighting": "100",
"walls-description": "Average thermal transmittance 0.16 W/m-¦K",
"hotwater-description": "Community scheme",
},
{
"low-energy-fixed-light-count": "1",
address: "10 Distillery Wharf, Regatta Lane",
"uprn-source": "Address Matched",
"floor-height": "",
"heating-cost-potential": "142",
"unheated-corridor-length": "",
"hot-water-cost-potential": "96",
"construction-age-band": "NO DATA!",
"potential-energy-rating": "B",
"mainheat-energy-eff": "Very Good",
"windows-env-eff": "Very Good",
"lighting-energy-eff": "Very Good",
"environment-impact-potential": "91",
"glazed-type": "NO DATA!",
"heating-cost-current": "142",
address3: "",
"mainheatcont-description":
"Charging system linked to use of community heating, TRVs",
"sheating-energy-eff": "N/A",
"property-type": "Flat",
"local-authority-label": "Hammersmith and Fulham",
"fixed-lighting-outlets-count": "1",
"energy-tariff": "standard tariff",
"mechanical-ventilation": "NO DATA!",
"hot-water-cost-current": "96",
county: "Greater London Authority",
postcode: "W6 9BF",
"solar-water-heating-flag": "",
constituency: "E14000726",
"co2-emissions-potential": "0.8",
"number-heated-rooms": "",
"floor-description": "Average thermal transmittance 0.19 W/m-¦K",
"energy-consumption-potential": "50",
"local-authority": "E09000013",
"built-form": "Mid-Terrace",
"number-open-fireplaces": "0",
"windows-description": "High performance glazing",
"glazed-area": "NO DATA!",
"inspection-date": "2017-04-05",
"mains-gas-flag": "",
"co2-emiss-curr-per-floor-area": "9",
address1: "53 Distillery Wharf",
"heat-loss-corridor": "NO DATA!",
"flat-storey-count": "",
"constituency-label": "Hammersmith",
"roof-energy-eff": "N/A",
"total-floor-area": "89.0",
"building-reference-number": "6013745278",
"environment-impact-current": "91",
"co2-emissions-current": "0.8",
"roof-description": "(other premises above)",
"floor-energy-eff": "Very Good",
"number-habitable-rooms": "",
address2: "Regatta Lane",
"hot-water-env-eff": "Very Good",
posttown: "LONDON",
"mainheatc-energy-eff": "Good",
"main-fuel": "NO DATA!",
"lighting-env-eff": "Very Good",
"windows-energy-eff": "Very Good",
"floor-env-eff": "Very Good",
"sheating-env-eff": "N/A",
"lighting-description": "Low energy lighting in all fixed outlets",
"roof-env-eff": "N/A",
"walls-energy-eff": "Very Good",
"photo-supply": "",
"lighting-cost-potential": "58",
"mainheat-env-eff": "Very Good",
"multi-glaze-proportion": "",
"main-heating-controls": "",
"lodgement-datetime": "2017-04-05 16:52:23",
"flat-top-storey": "",
"current-energy-rating": "B",
"secondheat-description": "None",
"walls-env-eff": "Very Good",
"transaction-type": "new dwelling",
uprn: "34154017",
"current-energy-efficiency": "86",
"energy-consumption-current": "50",
"mainheat-description": "Community scheme",
"lighting-cost-current": "58",
"lodgement-date": "2017-04-05",
"extension-count": "",
"mainheatc-env-eff": "Good",
"lmk-key": "dsdw11721593790620170405165223055583123",
"wind-turbine-count": "",
tenure: "unknown",
"floor-level": "mid floor",
"potential-energy-efficiency": "86",
"hot-water-energy-eff": "Very Good",
"low-energy-lighting": "100",
"walls-description": "Average thermal transmittance 0.16 W/m-¦K",
"hotwater-description": "Community scheme",
},
{
"low-energy-fixed-light-count": "1",
address: "10 Distillery Wharf, Regatta Lane",
"uprn-source": "Address Matched",
"floor-height": "",
"heating-cost-potential": "142",
"unheated-corridor-length": "",
"hot-water-cost-potential": "96",
"construction-age-band": "NO DATA!",
"potential-energy-rating": "B",
"mainheat-energy-eff": "Very Good",
"windows-env-eff": "Very Good",
"lighting-energy-eff": "Very Good",
"environment-impact-potential": "91",
"glazed-type": "NO DATA!",
"heating-cost-current": "142",
address3: "",
"mainheatcont-description":
"Charging system linked to use of community heating, TRVs",
"sheating-energy-eff": "N/A",
"property-type": "Flat",
"local-authority-label": "Hammersmith and Fulham",
"fixed-lighting-outlets-count": "1",
"energy-tariff": "standard tariff",
"mechanical-ventilation": "NO DATA!",
"hot-water-cost-current": "96",
county: "Greater London Authority",
postcode: "W6 9BF",
"solar-water-heating-flag": "",
constituency: "E14000726",
"co2-emissions-potential": "0.8",
"number-heated-rooms": "",
"floor-description": "Average thermal transmittance 0.19 W/m-¦K",
"energy-consumption-potential": "50",
"local-authority": "E09000013",
"built-form": "Mid-Terrace",
"number-open-fireplaces": "0",
"windows-description": "High performance glazing",
"glazed-area": "NO DATA!",
"inspection-date": "2017-04-05",
"mains-gas-flag": "",
"co2-emiss-curr-per-floor-area": "9",
address1: "53 Distillery Wharf",
"heat-loss-corridor": "NO DATA!",
"flat-storey-count": "",
"constituency-label": "Hammersmith",
"roof-energy-eff": "N/A",
"total-floor-area": "89.0",
"building-reference-number": "6013745278",
"environment-impact-current": "91",
"co2-emissions-current": "0.8",
"roof-description": "(other premises above)",
"floor-energy-eff": "Very Good",
"number-habitable-rooms": "",
address2: "Regatta Lane",
"hot-water-env-eff": "Very Good",
posttown: "LONDON",
"mainheatc-energy-eff": "Good",
"main-fuel": "NO DATA!",
"lighting-env-eff": "Very Good",
"windows-energy-eff": "Very Good",
"floor-env-eff": "Very Good",
"sheating-env-eff": "N/A",
"lighting-description": "Low energy lighting in all fixed outlets",
"roof-env-eff": "N/A",
"walls-energy-eff": "Very Good",
"photo-supply": "",
"lighting-cost-potential": "58",
"mainheat-env-eff": "Very Good",
"multi-glaze-proportion": "",
"main-heating-controls": "",
"lodgement-datetime": "2017-04-05 16:52:23",
"flat-top-storey": "",
"current-energy-rating": "B",
"secondheat-description": "None",
"walls-env-eff": "Very Good",
"transaction-type": "new dwelling",
uprn: "34154017",
"current-energy-efficiency": "86",
"energy-consumption-current": "50",
"mainheat-description": "Community scheme",
"lighting-cost-current": "58",
"lodgement-date": "2017-04-05",
"extension-count": "",
"mainheatc-env-eff": "Good",
"lmk-key": "11fewde721593790620170405165223055583123",
"wind-turbine-count": "",
tenure: "unknown",
"floor-level": "mid floor",
"potential-energy-efficiency": "86",
"hot-water-energy-eff": "Very Good",
"low-energy-lighting": "100",
"walls-description": "Average thermal transmittance 0.16 W/m-¦K",
"hotwater-description": "Community scheme",
},
{
"low-energy-fixed-light-count": "1",
address: "10 Distillery Wharf, Regatta Lane",
"uprn-source": "Address Matched",
"floor-height": "",
"heating-cost-potential": "142",
"unheated-corridor-length": "",
"hot-water-cost-potential": "96",
"construction-age-band": "NO DATA!",
"potential-energy-rating": "B",
"mainheat-energy-eff": "Very Good",
"windows-env-eff": "Very Good",
"lighting-energy-eff": "Very Good",
"environment-impact-potential": "91",
"glazed-type": "NO DATA!",
"heating-cost-current": "142",
address3: "",
"mainheatcont-description":
"Charging system linked to use of community heating, TRVs",
"sheating-energy-eff": "N/A",
"property-type": "Flat",
"local-authority-label": "Hammersmith and Fulham",
"fixed-lighting-outlets-count": "1",
"energy-tariff": "standard tariff",
"mechanical-ventilation": "NO DATA!",
"hot-water-cost-current": "96",
county: "Greater London Authority",
postcode: "W6 9BF",
"solar-water-heating-flag": "",
constituency: "E14000726",
"co2-emissions-potential": "0.8",
"number-heated-rooms": "",
"floor-description": "Average thermal transmittance 0.19 W/m-¦K",
"energy-consumption-potential": "50",
"local-authority": "E09000013",
"built-form": "Mid-Terrace",
"number-open-fireplaces": "0",
"windows-description": "High performance glazing",
"glazed-area": "NO DATA!",
"inspection-date": "2017-04-05",
"mains-gas-flag": "",
"co2-emiss-curr-per-floor-area": "9",
address1: "53 Distillery Wharf",
"heat-loss-corridor": "NO DATA!",
"flat-storey-count": "",
"constituency-label": "Hammersmith",
"roof-energy-eff": "N/A",
"total-floor-area": "89.0",
"building-reference-number": "6013745278",
"environment-impact-current": "91",
"co2-emissions-current": "0.8",
"roof-description": "(other premises above)",
"floor-energy-eff": "Very Good",
"number-habitable-rooms": "",
address2: "Regatta Lane",
"hot-water-env-eff": "Very Good",
posttown: "LONDON",
"mainheatc-energy-eff": "Good",
"main-fuel": "NO DATA!",
"lighting-env-eff": "Very Good",
"windows-energy-eff": "Very Good",
"floor-env-eff": "Very Good",
"sheating-env-eff": "N/A",
"lighting-description": "Low energy lighting in all fixed outlets",
"roof-env-eff": "N/A",
"walls-energy-eff": "Very Good",
"photo-supply": "",
"lighting-cost-potential": "58",
"mainheat-env-eff": "Very Good",
"multi-glaze-proportion": "",
"main-heating-controls": "",
"lodgement-datetime": "2017-04-05 16:52:23",
"flat-top-storey": "",
"current-energy-rating": "B",
"secondheat-description": "None",
"walls-env-eff": "Very Good",
"transaction-type": "new dwelling",
uprn: "34154017",
"current-energy-efficiency": "86",
"energy-consumption-current": "50",
"mainheat-description": "Community scheme",
"lighting-cost-current": "58",
"lodgement-date": "2017-04-05",
"extension-count": "",
"mainheatc-env-eff": "Good",
"lmk-key": "117215937906201704051fe432265223055583123",
"wind-turbine-count": "",
tenure: "unknown",
"floor-level": "mid floor",
"potential-energy-efficiency": "86",
"hot-water-energy-eff": "Very Good",
"low-energy-lighting": "100",
"walls-description": "Average thermal transmittance 0.16 W/m-¦K",
"hotwater-description": "Community scheme",
},
{
"low-energy-fixed-light-count": "1",
address: "10 Distillery Wharf, Regatta Lane",
"uprn-source": "Address Matched",
"floor-height": "",
"heating-cost-potential": "142",
"unheated-corridor-length": "",
"hot-water-cost-potential": "96",
"construction-age-band": "NO DATA!",
"potential-energy-rating": "B",
"mainheat-energy-eff": "Very Good",
"windows-env-eff": "Very Good",
"lighting-energy-eff": "Very Good",
"environment-impact-potential": "91",
"glazed-type": "NO DATA!",
"heating-cost-current": "142",
address3: "",
"mainheatcont-description":
"Charging system linked to use of community heating, TRVs",
"sheating-energy-eff": "N/A",
"property-type": "Flat",
"local-authority-label": "Hammersmith and Fulham",
"fixed-lighting-outlets-count": "1",
"energy-tariff": "standard tariff",
"mechanical-ventilation": "NO DATA!",
"hot-water-cost-current": "96",
county: "Greater London Authority",
postcode: "W6 9BF",
"solar-water-heating-flag": "",
constituency: "E14000726",
"co2-emissions-potential": "0.8",
"number-heated-rooms": "",
"floor-description": "Average thermal transmittance 0.19 W/m-¦K",
"energy-consumption-potential": "50",
"local-authority": "E09000013",
"built-form": "Mid-Terrace",
"number-open-fireplaces": "0",
"windows-description": "High performance glazing",
"glazed-area": "NO DATA!",
"inspection-date": "2017-04-05",
"mains-gas-flag": "",
"co2-emiss-curr-per-floor-area": "9",
address1: "53 Distillery Wharf",
"heat-loss-corridor": "NO DATA!",
"flat-storey-count": "",
"constituency-label": "Hammersmith",
"roof-energy-eff": "N/A",
"total-floor-area": "89.0",
"building-reference-number": "6013745278",
"environment-impact-current": "91",
"co2-emissions-current": "0.8",
"roof-description": "(other premises above)",
"floor-energy-eff": "Very Good",
"number-habitable-rooms": "",
address2: "Regatta Lane",
"hot-water-env-eff": "Very Good",
posttown: "LONDON",
"mainheatc-energy-eff": "Good",
"main-fuel": "NO DATA!",
"lighting-env-eff": "Very Good",
"windows-energy-eff": "Very Good",
"floor-env-eff": "Very Good",
"sheating-env-eff": "N/A",
"lighting-description": "Low energy lighting in all fixed outlets",
"roof-env-eff": "N/A",
"walls-energy-eff": "Very Good",
"photo-supply": "",
"lighting-cost-potential": "58",
"mainheat-env-eff": "Very Good",
"multi-glaze-proportion": "",
"main-heating-controls": "",
"lodgement-datetime": "2017-04-05 16:52:23",
"flat-top-storey": "",
"current-energy-rating": "B",
"secondheat-description": "None",
"walls-env-eff": "Very Good",
"transaction-type": "new dwelling",
uprn: "34154017",
"current-energy-efficiency": "86",
"energy-consumption-current": "50",
"mainheat-description": "Community scheme",
"lighting-cost-current": "58",
"lodgement-date": "2017-04-05",
"extension-count": "",
"mainheatc-env-eff": "Good",
"lmk-key": "117215937906201704051611115223055583123",
"wind-turbine-count": "",
tenure: "unknown",
"floor-level": "mid floor",
"potential-energy-efficiency": "86",
"hot-water-energy-eff": "Very Good",
"low-energy-lighting": "100",
"walls-description": "Average thermal transmittance 0.16 W/m-¦K",
"hotwater-description": "Community scheme",
},
{
"low-energy-fixed-light-count": "1",
address: "10 Distillery Wharf, Regatta Lane",
"uprn-source": "Address Matched",
"floor-height": "",
"heating-cost-potential": "142",
"unheated-corridor-length": "",
"hot-water-cost-potential": "96",
"construction-age-band": "NO DATA!",
"potential-energy-rating": "B",
"mainheat-energy-eff": "Very Good",
"windows-env-eff": "Very Good",
"lighting-energy-eff": "Very Good",
"environment-impact-potential": "91",
"glazed-type": "NO DATA!",
"heating-cost-current": "142",
address3: "",
"mainheatcont-description":
"Charging system linked to use of community heating, TRVs",
"sheating-energy-eff": "N/A",
"property-type": "Flat",
"local-authority-label": "Hammersmith and Fulham",
"fixed-lighting-outlets-count": "1",
"energy-tariff": "standard tariff",
"mechanical-ventilation": "NO DATA!",
"hot-water-cost-current": "96",
county: "Greater London Authority",
postcode: "W6 9BF",
"solar-water-heating-flag": "",
constituency: "E14000726",
"co2-emissions-potential": "0.8",
"number-heated-rooms": "",
"floor-description": "Average thermal transmittance 0.19 W/m-¦K",
"energy-consumption-potential": "50",
"local-authority": "E09000013",
"built-form": "Mid-Terrace",
"number-open-fireplaces": "0",
"windows-description": "High performance glazing",
"glazed-area": "NO DATA!",
"inspection-date": "2017-04-05",
"mains-gas-flag": "",
"co2-emiss-curr-per-floor-area": "9",
address1: "53 Distillery Wharf",
"heat-loss-corridor": "NO DATA!",
"flat-storey-count": "",
"constituency-label": "Hammersmith",
"roof-energy-eff": "N/A",
"total-floor-area": "89.0",
"building-reference-number": "6013745278",
"environment-impact-current": "91",
"co2-emissions-current": "0.8",
"roof-description": "(other premises above)",
"floor-energy-eff": "Very Good",
"number-habitable-rooms": "",
address2: "Regatta Lane",
"hot-water-env-eff": "Very Good",
posttown: "LONDON",
"mainheatc-energy-eff": "Good",
"main-fuel": "NO DATA!",
"lighting-env-eff": "Very Good",
"windows-energy-eff": "Very Good",
"floor-env-eff": "Very Good",
"sheating-env-eff": "N/A",
"lighting-description": "Low energy lighting in all fixed outlets",
"roof-env-eff": "N/A",
"walls-energy-eff": "Very Good",
"photo-supply": "",
"lighting-cost-potential": "58",
"mainheat-env-eff": "Very Good",
"multi-glaze-proportion": "",
"main-heating-controls": "",
"lodgement-datetime": "2017-04-05 16:52:23",
"flat-top-storey": "",
"current-energy-rating": "B",
"secondheat-description": "None",
"walls-env-eff": "Very Good",
"transaction-type": "new dwelling",
uprn: "34154017",
"current-energy-efficiency": "86",
"energy-consumption-current": "50",
"mainheat-description": "Community scheme",
"lighting-cost-current": "58",
"lodgement-date": "2017-04-05",
"extension-count": "",
"mainheatc-env-eff": "Good",
"lmk-key": "117215937906201704051652230550000583123",
"wind-turbine-count": "",
tenure: "unknown",
"floor-level": "mid floor",
"potential-energy-efficiency": "86",
"hot-water-energy-eff": "Very Good",
"low-energy-lighting": "100",
"walls-description": "Average thermal transmittance 0.16 W/m-¦K",
"hotwater-description": "Community scheme",
},
],
};
const response = await fetch(url, {
headers: headers,
next: { revalidate: 120 },
});
const data = await response.json();
// Handle the response from the external API and return it
return NextResponse.json(data);

View file

@ -1,6 +1,8 @@
import "./globals.css";
import Provider from "./components/Provider";
import Nav from "./components/Navbar";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryProvider } from "./ReactQueryProvider";
export const metadata = {
title: "",
@ -20,8 +22,10 @@ export default function RootLayout({
<html lang="en">
<body>
<Provider>
<Nav pageName="Home"></Nav>
{children}
<ReactQueryProvider>
<Nav pageName="Home"></Nav>
{children}
</ReactQueryProvider>
</Provider>
</body>
</html>

View file

@ -4,13 +4,70 @@ import { useState } from "react";
import { Dialog } from "@headlessui/react";
import Link from "next/link";
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
import { SearchData } from "@/types/epc";
import { useRouter } from "next/navigation";
import { useQuery } from "@tanstack/react-query";
const EpcDefaults = {
G: "C",
F: "C",
E: "C",
D: "C",
C: "B",
B: "A",
A: "A",
};
async function fetchData(postcode: string): Promise<SearchData> {
// TODO - add strict typing to the api response
const response = await fetch(`/api/search?postcode=${postcode}`);
if (!response.ok) {
// This will activate the closest `error.js` Error Boundary
throw new Error("Failed to fetch data");
}
return response.json();
}
export default function PropertyPage({
params,
searchParams,
}: {
params: { slug: string; lmkKey: string };
searchParams: { [key: string]: string | string[] | undefined };
}) {
const router = useRouter();
const PropertyPage = ({ params }: { params: { slug: string } }) => {
const portfolioId = params.slug;
const lmkKey = params.lmkKey;
const postcode = searchParams.postcode;
if (postcode === undefined) {
router.push(`/portfolio/${portfolioId}/error`);
}
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
const [isDetailModalOpen, setIsDetailModalOpen] = useState(false);
const { data, error, isLoading } = useQuery<SearchData, Error>({
queryKey: ["search", postcode],
queryFn: async () => fetchData(postcode as string),
});
// TODO: Add a loading state and error handling
if (isLoading) {
return <div>Loading...</div>;
}
if (error) {
return <div>Error fetching data: {error.message}</div>;
}
const propertyData = data.rows.filter((row) => row["lmk-key"] === lmkKey)[0];
const currentEpcRating = propertyData["current-energy-rating"];
const handleEditClick = () => {
setIsEditModalOpen(true);
};
@ -18,19 +75,13 @@ const PropertyPage = ({ params }: { params: { slug: string } }) => {
const handleDetailClick = () => {
setIsDetailModalOpen(true);
};
// NextJS docs recomment fetching data directly in the component that needs it,
// even if requeting the same data in multiple components. rather than passing data between
// components as props
return (
<section>
<div className="h-2"></div>
{/* <Link
href={`/portfolio/${portfolioId}`}
className="mt-10 ml-2 bg-brandtan hover:bg-hovertan text-white px-4 py-1 rounded transition-colors duration-200"
>
<div>
<ArrowLeftIcon className="w-5 h-5 mr-1" />
Back to portfolio
</div>
</Link> */}
<Link href={`/portfolio/${portfolioId}`}>
<div className="ml-2 px-4 py-1 inline-flex items-center bg-brandtan hover:bg-hovertan text-white rounded transition-colors duration-200 cursor-pointer">
<ArrowLeftIcon className="w-5 h-5 mr-1" />
@ -40,12 +91,12 @@ const PropertyPage = ({ params }: { params: { slug: string } }) => {
<div className="max-w-3xl mx-auto p-6">
<h1 className="text-2xl text-center font-bold mb-4">Your Property</h1>
<p className="text-center mb-4">123 Main St, City, State</p>
<p className="text-center mb-4">{propertyData.address}</p>
<div className="flex space-x-4">
<div className="flex-1 border p-4">
<h2 className="text-lg font-bold mb-2">Current EPC rating</h2>
<p>Rating: A</p>
<p>Rating: {currentEpcRating}</p>
</div>
<div
@ -53,7 +104,7 @@ const PropertyPage = ({ params }: { params: { slug: string } }) => {
onClick={handleEditClick}
>
<h2 className="text-lg font-bold mb-2">Target EPC rating</h2>
<p>Rating: B</p>
<p>Rating: {EpcDefaults[currentEpcRating]}</p>
</div>
</div>
@ -115,6 +166,4 @@ const PropertyPage = ({ params }: { params: { slug: string } }) => {
</div>
</section>
);
};
export default PropertyPage;
}

View file

@ -69,7 +69,9 @@ export default function Search({ params }: { params: { slug: string } }) {
const portfolioId = params.slug;
const lmkKey = res["lmk-key"];
router.push(`/portfolio/${portfolioId}/property/${lmkKey}`);
router.push(
`/portfolio/${portfolioId}/property/${lmkKey}?postcode=${postcode}`
);
};
const submitProps = {

View file

@ -75,7 +75,7 @@ type SearchResult = {
"main-heating-controls": string;
"lodgement-datetime": string;
"flat-top-storey": string;
"current-energy-rating": string;
"current-energy-rating": "A" | "B" | "C" | "D" | "E" | "F" | "G";
"secondheat-description": string;
"walls-env-eff": string;
"transaction-type": string;