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;
|
||||
};
|
||||
|
||||
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
|
||||
const START_LOGGING_ENDPOINT = (siteId: string) =>
|
||||
|
||||
@ -16,7 +16,7 @@ type CrmProject = {
|
||||
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 [projects, setProjects] = useState<CrmProject[]>([]);
|
||||
|
||||
@ -9,12 +9,12 @@ export interface TimeSeriesResponse {
|
||||
generation: TimeSeriesEntry[];
|
||||
}
|
||||
|
||||
const API_BASE_URL =
|
||||
process.env.FASTAPI_URL ?? "http://127.0.0.1:8000";
|
||||
const API_URL =
|
||||
process.env.NEXT_PUBLIC_FASTAPI_URL ;
|
||||
|
||||
export const crmapi = {
|
||||
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}`);
|
||||
return res.json();
|
||||
@ -28,7 +28,7 @@ export async function fetchPowerTimeseries(
|
||||
): Promise<TimeSeriesResponse> { // <-- Change here
|
||||
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) {
|
||||
throw new Error(`Failed to fetch data: ${res.status}`);
|
||||
@ -54,7 +54,7 @@ export async function fetchForecast(
|
||||
kwp: kwp.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");
|
||||
|
||||
return res.json();
|
||||
@ -73,7 +73,7 @@ export type MonthlyKPI = {
|
||||
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: {
|
||||
site: string;
|
||||
|
||||
@ -12,7 +12,7 @@ const ComponentsAuthLoginForm = () => {
|
||||
const [password, setPassword] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
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>) => {
|
||||
e.preventDefault();
|
||||
|
||||
@ -21,6 +21,8 @@ const KPI_Table: React.FC<KPI_TableProps> = ({ siteId, month }) => {
|
||||
const [kpiData, setKpiData] = useState<MonthlyKPI | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||
|
||||
useEffect(() => {
|
||||
if (!siteId || !month) return;
|
||||
|
||||
@ -28,7 +30,7 @@ const KPI_Table: React.FC<KPI_TableProps> = ({ siteId, month }) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
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());
|
||||
} catch (err) {
|
||||
|
||||
@ -11,7 +11,7 @@ interface LoggingControlCardProps {
|
||||
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 = {
|
||||
serial: string;
|
||||
|
||||
@ -26,7 +26,7 @@ interface SiteCardProps {
|
||||
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 [project, setProject] = useState<CrmProject | null>(null);
|
||||
|
||||
@ -15,8 +15,7 @@ interface SiteStatusProps {
|
||||
lastSyncTimestamp: string;
|
||||
}
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8000";
|
||||
const WS_URL = process.env.NEXT_PUBLIC_WS_URL ?? "ws://localhost:8000/ws";
|
||||
const API_URL = process.env.NEXT_PUBLIC_FASTAPI_URL;
|
||||
|
||||
const SiteStatus = ({
|
||||
selectedSite,
|
||||
@ -30,7 +29,7 @@ const SiteStatus = ({
|
||||
|
||||
// --- WebSocket to receive MQTT-forwarded messages ---
|
||||
useEffect(() => {
|
||||
const ws = new WebSocket(WS_URL);
|
||||
const ws = new WebSocket(`${API_URL}/ws`);
|
||||
|
||||
ws.onopen = () => console.log("WebSocket connected");
|
||||
ws.onclose = () => console.log("WebSocket disconnected");
|
||||
|
||||
@ -26,7 +26,7 @@ export default function Header() {
|
||||
const [user, setUser] = useState<UserData | null>(null);
|
||||
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
|
||||
useEffect(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user