fix: Fetch actual EVSEs instead of VariableAttributes in charging station detail
- page.tsx: Added evses relationship to Server Component query - charging.station.detail.card.tsx: Replaced VariableAttributes alias with real evses relationship - evses.ts: Fixed stationId type from Int! to String! (2 queries) - evse.dto.tsx: Removed ocppConnectionName (not a DB column on Evses) - evses.upsert.tsx: Removed ocppConnectionName prop, added String(stationId) coercion - evses.list.tsx: Fixed id type to string, extract ChargingStations[0] from GraphQL response - charging.station.detail.tabs.card.tsx: Fixed id type to string
This commit is contained in:
@@ -37,6 +37,7 @@ async function fetchStation(id: string) {
|
|||||||
coordinates
|
coordinates
|
||||||
use16StatusNotification0
|
use16StatusNotification0
|
||||||
location { id name address city postalCode state country coordinates createdAt updatedAt }
|
location { id name address city postalCode state country coordinates createdAt updatedAt }
|
||||||
|
evses { id stationId evseId evseTypeId physicalReference removed createdAt updatedAt }
|
||||||
variableAttributes { id stationId variableId value dataType }
|
variableAttributes { id stationId variableId value dataType }
|
||||||
latestStatusNotifications { id stationId statusNotificationId updatedAt createdAt StatusNotification { connectorId connectorStatus createdAt evseId id stationId timestamp updatedAt } }
|
latestStatusNotifications { id stationId statusNotificationId updatedAt createdAt StatusNotification { connectorId connectorStatus createdAt evseId id stationId timestamp updatedAt } }
|
||||||
transactions(where: {isActive: {_eq: true}}) { id stationId timeSpentCharging isActive chargingState stoppedReason transactionId evseId remoteStartId totalKwh createdAt updatedAt }
|
transactions(where: {isActive: {_eq: true}}) { id stationId timeSpentCharging isActive chargingState stoppedReason transactionId evseId remoteStartId totalKwh createdAt updatedAt }
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ export const ChargingStationDetailCard = ({
|
|||||||
coordinates
|
coordinates
|
||||||
use16StatusNotification0
|
use16StatusNotification0
|
||||||
location { id name address city postalCode state country coordinates createdAt updatedAt }
|
location { id name address city postalCode state country coordinates createdAt updatedAt }
|
||||||
evses: VariableAttributes(where: {stationId: {_eq: $id}, variableId: {_eq: "1"}}) { id stationId variableId value dataType }
|
evses { id stationId evseId evseTypeId physicalReference removed createdAt updatedAt }
|
||||||
latestStatusNotifications { id stationId statusNotificationId updatedAt createdAt statusNotification { connectorId connectorStatus createdAt evseId id stationId timestamp updatedAt } }
|
latestStatusNotifications { id stationId statusNotificationId updatedAt createdAt statusNotification { connectorId connectorStatus createdAt evseId id stationId timestamp updatedAt } }
|
||||||
transactions(where: {isActive: {_eq: true}}) { id stationId timeSpentCharging isActive chargingState stoppedReason transactionId evseId remoteStartId totalKwh createdAt updatedAt }
|
transactions(where: {isActive: {_eq: true}}) { id stationId timeSpentCharging isActive chargingState stoppedReason transactionId evseId remoteStartId totalKwh createdAt updatedAt }
|
||||||
connectors { id stationId evseId connectorId status type maximumPowerWatts maximumAmperage maximumVoltage format powerType termsAndConditionsUrl tariffId errorCode timestamp info vendorId vendorErrorCode createdAt updatedAt }
|
connectors { id stationId evseId connectorId status type maximumPowerWatts maximumAmperage maximumVoltage format powerType termsAndConditionsUrl tariffId errorCode timestamp info vendorId vendorErrorCode createdAt updatedAt }
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ enum ChargingStationDetailTabType {
|
|||||||
aggregated = 'aggregated',
|
aggregated = 'aggregated',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChargingStationDetailTabsCard = ({ id }: { id: number }) => {
|
export const ChargingStationDetailTabsCard = ({ id }: { id: string }) => {
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
|
|
||||||
const { renderedVisibleColumns } = useColumnPreferences(
|
const { renderedVisibleColumns } = useColumnPreferences(
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
|
|
||||||
interface EVSESListProps {
|
interface EVSESListProps {
|
||||||
id: number;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const evsesFormUpsertGrid = 'grid grid-cols-2 xs:grid-cols-1 gap-6';
|
export const evsesFormUpsertGrid = 'grid grid-cols-2 xs:grid-cols-1 gap-6';
|
||||||
@@ -45,8 +45,15 @@ export const EVSESList: React.FC<EVSESListProps> = ({ id }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const station = React.useMemo(() => {
|
const station = React.useMemo(() => {
|
||||||
const station = { ...data?.data } as ChargingStationDto;
|
const raw = data?.data;
|
||||||
return station;
|
if (!raw) return undefined;
|
||||||
|
// GraphQL response wraps in { ChargingStations: [...] }, extract first item
|
||||||
|
const stations = (raw as any).ChargingStations;
|
||||||
|
if (Array.isArray(stations) && stations.length > 0) {
|
||||||
|
return stations[0] as ChargingStationDto;
|
||||||
|
}
|
||||||
|
// Fallback: data might already be the station object
|
||||||
|
return { ...raw } as ChargingStationDto;
|
||||||
}, [data?.data]);
|
}, [data?.data]);
|
||||||
|
|
||||||
const openModal = useCallback(
|
const openModal = useCallback(
|
||||||
@@ -128,7 +135,6 @@ export const EVSESList: React.FC<EVSESListProps> = ({ id }) => {
|
|||||||
<EvseUpsert
|
<EvseUpsert
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
stationId={station.id}
|
stationId={station.id}
|
||||||
ocppConnectionName={station.ocppConnectionName}
|
|
||||||
evse={currentEvse}
|
evse={currentEvse}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -19,15 +19,13 @@ import { useTenantId } from '@lib/client/hooks/useTenantId';
|
|||||||
|
|
||||||
interface EvseUpsertProps {
|
interface EvseUpsertProps {
|
||||||
onSubmit: () => void;
|
onSubmit: () => void;
|
||||||
stationId: number;
|
stationId: string;
|
||||||
ocppConnectionName?: string;
|
|
||||||
evse: EvseDto | null;
|
evse: EvseDto | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EvseUpsert: React.FC<EvseUpsertProps> = ({
|
export const EvseUpsert: React.FC<EvseUpsertProps> = ({
|
||||||
onSubmit,
|
onSubmit,
|
||||||
stationId,
|
stationId,
|
||||||
ocppConnectionName,
|
|
||||||
evse,
|
evse,
|
||||||
}) => {
|
}) => {
|
||||||
const tenantId = useTenantId();
|
const tenantId = useTenantId();
|
||||||
@@ -74,8 +72,7 @@ export const EvseUpsert: React.FC<EvseUpsertProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
newItem.updatedAt = now;
|
newItem.updatedAt = now;
|
||||||
newItem.stationId = stationId;
|
newItem.stationId = String(stationId);
|
||||||
newItem.ocppConnectionName = ocppConnectionName ?? evse?.ocppConnectionName;
|
|
||||||
|
|
||||||
form.refineCore.onFinish(newItem).then(() => reset());
|
form.refineCore.onFinish(newItem).then(() => reset());
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import type { ChargingStationDto, ConnectorDto, EvseDto } from '@citrineos/base'
|
|||||||
|
|
||||||
export class EvseClass implements Partial<EvseDto> {
|
export class EvseClass implements Partial<EvseDto> {
|
||||||
id?: number;
|
id?: number;
|
||||||
ocppConnectionName!: string;
|
|
||||||
evseTypeId?: number;
|
evseTypeId?: number;
|
||||||
evseId!: string;
|
evseId!: string;
|
||||||
physicalReference?: string | null;
|
physicalReference?: string | null;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const EVSE_LIST_QUERY = gql`
|
|||||||
|
|
||||||
export const GET_EVSE_LIST_FOR_STATION = gql`
|
export const GET_EVSE_LIST_FOR_STATION = gql`
|
||||||
query GetPaginatedEvseListForStation(
|
query GetPaginatedEvseListForStation(
|
||||||
$stationId: Int!
|
$stationId: String!
|
||||||
$where: Evses_bool_exp = {}
|
$where: Evses_bool_exp = {}
|
||||||
$order_by: [Evses_order_by!] = {}
|
$order_by: [Evses_order_by!] = {}
|
||||||
$offset: Int
|
$offset: Int
|
||||||
@@ -76,7 +76,7 @@ export const GET_EVSE_LIST_FOR_STATION = gql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const GET_EVSES_FOR_STATION = gql`
|
export const GET_EVSES_FOR_STATION = gql`
|
||||||
query GetEvseListForStation($stationId: Int!) {
|
query GetEvseListForStation($stationId: String!) {
|
||||||
Evses(where: { stationId: { _eq: $stationId } }) {
|
Evses(where: { stationId: { _eq: $stationId } }) {
|
||||||
id
|
id
|
||||||
ocppConnectionName
|
ocppConnectionName
|
||||||
|
|||||||
Reference in New Issue
Block a user