-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
8 changed files
with
119 additions
and
1,129 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
frontend/src/components/company-survey-v2/time-series/time-series-electricity.tsx
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,40 @@ | ||
import {targetYear} from "./time-series-util" | ||
import {TimeSeriesTextareaAdapter} from "./time-series-textarea-adapter" | ||
import {FunctionComponent} from "react" | ||
import {UseFormReturn} from "react-hook-form" | ||
import {TimeSeriesType} from "zero-zummon" | ||
|
||
export const TimeSeriesElectricity: FunctionComponent<{form: UseFormReturn, prefix: string}> = ({form, prefix}) => { | ||
return ( | ||
<> | ||
<> | ||
<h2>2. Kwartierwaarden electriciteit</h2> | ||
|
||
<p>Richtlijnen</p> | ||
|
||
<ul> | ||
<li>Geef waarden op van het gehele jaar {targetYear}.</li> | ||
<li>De eerste waarde betreft het verbruik in het kwartier van 1 januari {targetYear} van 00:00 | ||
tot 00:15 CET. | ||
</li> | ||
<li>De laatste waarde betreft het verbruik in het kwartier van 31 december {targetYear} 23:45 | ||
tot 1 januari {targetYear + 1} om 00:00 CET. | ||
</li> | ||
<li>Een langere periode mag.</li> | ||
</ul> | ||
</> | ||
<TimeSeriesTextareaAdapter | ||
timeSeries={form.watch(`${prefix}.quarterHourlyDelivery_kWh`)} | ||
timeSeriesType={TimeSeriesType.ELECTRICITY_DELIVERY} | ||
setTimeSeries={timeSeries => form.setValue(`${prefix}.quarterHourlyDelivery_kWh`, timeSeries)} /> | ||
<TimeSeriesTextareaAdapter | ||
timeSeries={form.watch(`${prefix}.quarterHourlyFeedIn_kWh`)} | ||
timeSeriesType={TimeSeriesType.ELECTRICITY_FEED_IN} | ||
setTimeSeries={timeSeries => form.setValue(`${prefix}.quarterHourlyFeedIn_kWh`, timeSeries)} /> | ||
<TimeSeriesTextareaAdapter | ||
timeSeries={form.watch(`${prefix}.quarterHourlyProduction_kWh`)} | ||
timeSeriesType={TimeSeriesType.ELECTRICITY_PRODUCTION} | ||
setTimeSeries={timeSeries => form.setValue(`${prefix}.quarterHourlyProduction_kWh`, timeSeries)} /> | ||
</> | ||
) | ||
} |
22 changes: 22 additions & 0 deletions
22
frontend/src/components/company-survey-v2/time-series/time-series-textarea-adapter.tsx
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,22 @@ | ||
import {FunctionComponent} from "react" | ||
import {targetYear} from "./time-series-util" | ||
import {TimeSeries, TimeSeriesType, timeSeriesFromJson, createEmptyTimeSeriesForYear} from "zero-zummon" | ||
import {TimeSeriesTextarea} from "./time-series-textarea" | ||
|
||
/** | ||
* Has a plain JS object as input and output. | ||
* Converts that objects to a {@link TimeSeries} domain object for use in {@link TimeSeriesTextarea} | ||
*/ | ||
export const TimeSeriesTextareaAdapter: FunctionComponent<{ | ||
timeSeries?: any, | ||
timeSeriesType?: TimeSeriesType, | ||
setTimeSeries?: (obj: any) => void | ||
}> = ({ | ||
timeSeries, | ||
timeSeriesType = TimeSeriesType.ELECTRICITY_DELIVERY, | ||
setTimeSeries = console.log, | ||
}) => { | ||
const timeSeriesDomainObject = timeSeries ? timeSeriesFromJson(timeSeries) : createEmptyTimeSeriesForYear(timeSeriesType, targetYear) | ||
|
||
return <TimeSeriesTextarea timeSeries={timeSeriesDomainObject} setTimeSeries={setTimeSeries} /> | ||
} |
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
22 changes: 22 additions & 0 deletions
22
frontend/src/components/company-survey-v2/time-series/time-series-util.ts
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,22 @@ | ||
import {convert, Instant} from "@js-joda/core" | ||
import "@js-joda/timezone/dist/js-joda-timezone-2017-2027.esm.js" | ||
import {toJsJodaInstant} from "zero-zummon" | ||
|
||
export const targetYear = 2023 | ||
export const displayTimeZone = "Europe/Amsterdam" | ||
|
||
// This seems dubious because it mixes different versions of js-joda. | ||
// If this leads to issues we can do it with a conversion through epoch seconds | ||
export const kotlinInstantToJsJodaInstant = (kotlinInstant: any): Instant => toJsJodaInstant(kotlinInstant) | ||
|
||
// We use native date formatting because js-joda does not support Dutch locale | ||
const dateFormatter = new Intl.DateTimeFormat("nl-NL", { | ||
dateStyle: "full", | ||
timeStyle: "long", | ||
timeZone: displayTimeZone, | ||
}) | ||
|
||
export function prettyPrint(instant: Instant): string { | ||
const jsDate = convert(instant).toDate() | ||
return dateFormatter.format(jsDate) | ||
} |
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,4 +1,3 @@ | ||
|
||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import { | ||
|
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