@@ -17,7 +17,7 @@ import GsMap, { GsValue } from './GsMap';
1717import { useRecoilRefresher_UNSTABLE , useRecoilValue } from 'recoil' ;
1818import GlobalState from '../GlobalState' ;
1919import styles from './main.module.scss' ;
20- import Chart , { FuelType , TimeSlot } from './Chart' ;
20+ import Chart , { TimeSlot } from './Chart' ;
2121
2222interface GasPriceAvgs {
2323 Postcode : string
@@ -204,7 +204,7 @@ export default function Main() {
204204 signal : controller ?. signal
205205 }
206206 fetch ( `/usernotification/current/${ globalUserUuidState } ` , requestOptions1 ) . then ( myResult => myResult ?. json ( ) as Promise < Notification [ ] > ) . then ( myJson => {
207- console . log ( myJson ) ;
207+ // console.log(myJson);
208208 const result = myJson ?. map ( value => {
209209 //console.log(JSON.parse(value?.DataJson));
210210 return ( JSON . parse ( value ?. DataJson ) as MyDataJson [ ] ) ?. map ( value2 => {
@@ -226,25 +226,16 @@ export default function Main() {
226226 fetch ( `/postcode/countytimeslots/${ myPostcode } ` , requestOptions2 ) . then ( myResult1 => myResult1 . json ( ) as Promise < TimeSlotResponse [ ] > ) . then ( myJson1 => {
227227 const timeSlots = [ ] as TimeSlot [ ] ;
228228 timeSlots . push ( ...myJson1 . filter ( myValue => myValue . AvgDiesel > 10 ) . map ( myValue => {
229- let dieselTimeSlot = { fuelType : FuelType . diesel , x : new Date ( ) , y : 0 } as TimeSlot ;
230- dieselTimeSlot . x = myValue . StartDate ;
231- dieselTimeSlot . y = myValue . AvgDiesel ;
229+ const dieselTimeSlot = { x : '' , diesel : 0 , e10 : 0 , e5 : 0 } as TimeSlot ;
230+ const myDate = new Date ( myValue . StartDate ) ;
231+ dieselTimeSlot . x = '' + myDate . getHours ( ) + ':' + myDate . getMinutes ( ) ;
232+ dieselTimeSlot . diesel = myValue . AvgDiesel ;
233+ dieselTimeSlot . e10 = myValue . AvgE10 ;
234+ dieselTimeSlot . e5 = myValue . AvgE5 ;
232235 return dieselTimeSlot ;
233- } ) ) ;
234- timeSlots . push ( ...myJson1 . filter ( myValue => myValue . AvgE10 > 10 ) . map ( myValue => {
235- let e10TimeSlot = { fuelType : FuelType . e10 , x : new Date ( ) , y : 0 } as TimeSlot ;
236- e10TimeSlot . x = myValue . StartDate ;
237- e10TimeSlot . y = myValue . AvgE10 ;
238- return e10TimeSlot ;
239- } ) ) ;
240- timeSlots . push ( ...myJson1 . filter ( myValue => myValue . AvgE5 > 10 ) . map ( myValue => {
241- let e5TimeSlot = { fuelType : FuelType . e5 , x : new Date ( ) , y : 0 } as TimeSlot ;
242- e5TimeSlot . x = myValue . StartDate ;
243- e5TimeSlot . y = myValue . AvgE5 ;
244- return e5TimeSlot ;
245- } ) ) ;
236+ } ) ) ;
246237 setAvgTimeSlots ( timeSlots ) ;
247- console . log ( myJson1 ) ;
238+ // console.log(myJson1);
248239 } ) ;
249240 } )
250241 . then ( ( ) => setController ( null ) ) ;
@@ -268,7 +259,7 @@ export default function Main() {
268259 < DataTable diesel = 'Diesel' e10 = 'E10' e5 = 'E5' location = 'Location' showAverages = { true } time = 'Time' rows = { rows } > </ DataTable >
269260 </ TabPanel >
270261 < TabPanel value = { value } index = { 1 } >
271- < Chart e5 = { avgTimeSlots . filter ( value => value . fuelType === FuelType . e5 ) } e10 = { avgTimeSlots . filter ( value => value . fuelType === FuelType . e10 ) } diesel = { avgTimeSlots . filter ( value => value . fuelType === FuelType . diesel ) } > </ Chart >
262+ < Chart timeSlots = { avgTimeSlots } > </ Chart >
272263 < DataTable diesel = 'Diesel' e10 = 'E10' e5 = 'E5' location = 'Location' showAverages = { true } time = 'Time' rows = { rows } > </ DataTable >
273264 </ TabPanel >
274265 < TabPanel value = { value } index = { 2 } >
0 commit comments