amend api endpoints
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m56s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m56s
This commit is contained in:
parent
f77aa0358e
commit
fce26a2bc4
@ -40,7 +40,7 @@ type CrmProject = {
|
|||||||
custom_mobile_phone_no?: string | null;
|
custom_mobile_phone_no?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const API = process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:8000';
|
const API = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
|
|
||||||
// Adjust this to your FastAPI route
|
// Adjust this to your FastAPI route
|
||||||
const START_LOGGING_ENDPOINT = (siteId: string) =>
|
const START_LOGGING_ENDPOINT = (siteId: string) =>
|
||||||
|
|||||||
@ -16,7 +16,7 @@ type CrmProject = {
|
|||||||
custom_mobile_phone_no?: string | null;
|
custom_mobile_phone_no?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const API = process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:8000';
|
const API = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
|
|
||||||
const SitesPage = () => {
|
const SitesPage = () => {
|
||||||
const [projects, setProjects] = useState<CrmProject[]>([]);
|
const [projects, setProjects] = useState<CrmProject[]>([]);
|
||||||
|
|||||||
@ -9,12 +9,12 @@ export interface TimeSeriesResponse {
|
|||||||
generation: TimeSeriesEntry[];
|
generation: TimeSeriesEntry[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const API_BASE_URL =
|
const API_URL =
|
||||||
process.env.FASTAPI_URL ?? "http://127.0.0.1:8000";
|
process.env.NEXT_PUBLIC_FASTAPI_URL ;
|
||||||
|
|
||||||
export const crmapi = {
|
export const crmapi = {
|
||||||
getProjects: async () => {
|
getProjects: async () => {
|
||||||
const res = await fetch(`${API_BASE_URL}/crm/projects`, {
|
const res = await fetch(`${API_URL}/crm/projects`, {
|
||||||
});
|
});
|
||||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||||
return res.json();
|
return res.json();
|
||||||
@ -28,7 +28,7 @@ export async function fetchPowerTimeseries(
|
|||||||
): Promise<TimeSeriesResponse> { // <-- Change here
|
): Promise<TimeSeriesResponse> { // <-- Change here
|
||||||
const params = new URLSearchParams({ site, start, end });
|
const params = new URLSearchParams({ site, start, end });
|
||||||
|
|
||||||
const res = await fetch(`http://localhost:8000/power-timeseries?${params.toString()}`);
|
const res = await fetch(`${API_URL}/power-timeseries?${params.toString()}`);
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(`Failed to fetch data: ${res.status}`);
|
throw new Error(`Failed to fetch data: ${res.status}`);
|
||||||
@ -54,7 +54,7 @@ export async function fetchForecast(
|
|||||||
kwp: kwp.toString(),
|
kwp: kwp.toString(),
|
||||||
}).toString();
|
}).toString();
|
||||||
|
|
||||||
const res = await fetch(`http://localhost:8000/forecast?${query}`);
|
const res = await fetch(`${API_URL}/forecast?${query}`);
|
||||||
if (!res.ok) throw new Error("Failed to fetch forecast");
|
if (!res.ok) throw new Error("Failed to fetch forecast");
|
||||||
|
|
||||||
return res.json();
|
return res.json();
|
||||||
@ -73,7 +73,7 @@ export type MonthlyKPI = {
|
|||||||
error?: string;
|
error?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const API = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8000";
|
const API = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
|
|
||||||
export async function fetchMonthlyKpi(params: {
|
export async function fetchMonthlyKpi(params: {
|
||||||
site: string;
|
site: string;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const ComponentsAuthLoginForm = () => {
|
|||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const API = process.env.NEXT_PUBLIC_FASTAPI_URL; // e.g. http://localhost:8000
|
const API = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
|
|
||||||
const submitForm = async (e: React.FormEvent<HTMLFormElement>) => {
|
const submitForm = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@ -21,6 +21,8 @@ const KPI_Table: React.FC<KPI_TableProps> = ({ siteId, month }) => {
|
|||||||
const [kpiData, setKpiData] = useState<MonthlyKPI | null>(null);
|
const [kpiData, setKpiData] = useState<MonthlyKPI | null>(null);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const API_URL = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!siteId || !month) return;
|
if (!siteId || !month) return;
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ const KPI_Table: React.FC<KPI_TableProps> = ({ siteId, month }) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`http://localhost:8000/kpi/monthly?site=${siteId}&month=${month}`
|
`${API_URL}/kpi/monthly?site=${siteId}&month=${month}`
|
||||||
);
|
);
|
||||||
setKpiData(await res.json());
|
setKpiData(await res.json());
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ interface LoggingControlCardProps {
|
|||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const API_URL = process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:8000';
|
const API_URL = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
|
|
||||||
type FnState = {
|
type FnState = {
|
||||||
serial: string;
|
serial: string;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ interface SiteCardProps {
|
|||||||
fallbackStatus?: string; // optional backup status if CRM is missing it
|
fallbackStatus?: string; // optional backup status if CRM is missing it
|
||||||
}
|
}
|
||||||
|
|
||||||
const API = process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:8000';
|
const API = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
|
|
||||||
const SiteCard: React.FC<SiteCardProps> = ({ siteId, className = '', fallbackStatus }) => {
|
const SiteCard: React.FC<SiteCardProps> = ({ siteId, className = '', fallbackStatus }) => {
|
||||||
const [project, setProject] = useState<CrmProject | null>(null);
|
const [project, setProject] = useState<CrmProject | null>(null);
|
||||||
|
|||||||
@ -15,8 +15,7 @@ interface SiteStatusProps {
|
|||||||
lastSyncTimestamp: string;
|
lastSyncTimestamp: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const API_URL = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8000";
|
const API_URL = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
const WS_URL = process.env.NEXT_PUBLIC_WS_URL ?? "ws://localhost:8000/ws";
|
|
||||||
|
|
||||||
const SiteStatus = ({
|
const SiteStatus = ({
|
||||||
selectedSite,
|
selectedSite,
|
||||||
@ -30,7 +29,7 @@ const SiteStatus = ({
|
|||||||
|
|
||||||
// --- WebSocket to receive MQTT-forwarded messages ---
|
// --- WebSocket to receive MQTT-forwarded messages ---
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const ws = new WebSocket(WS_URL);
|
const ws = new WebSocket(`${API_URL}/ws`);
|
||||||
|
|
||||||
ws.onopen = () => console.log("WebSocket connected");
|
ws.onopen = () => console.log("WebSocket connected");
|
||||||
ws.onclose = () => console.log("WebSocket disconnected");
|
ws.onclose = () => console.log("WebSocket disconnected");
|
||||||
|
|||||||
@ -26,7 +26,7 @@ export default function Header() {
|
|||||||
const [user, setUser] = useState<UserData | null>(null);
|
const [user, setUser] = useState<UserData | null>(null);
|
||||||
const [loadingUser, setLoadingUser] = useState(true);
|
const [loadingUser, setLoadingUser] = useState(true);
|
||||||
|
|
||||||
const API = process.env.NEXT_PUBLIC_FASTAPI_URL || 'http://127.0.0.1:8000';
|
const API = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||||
|
|
||||||
// highlight active menu
|
// highlight active menu
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user