diff --git a/src/api/concentrators.ts b/src/api/concentrators.ts index 461fcba..0af1d6f 100644 --- a/src/api/concentrators.ts +++ b/src/api/concentrators.ts @@ -45,7 +45,11 @@ export interface Concentrator { export const fetchConcentrators = async (): Promise => { try { - const response = await fetch(CONCENTRATORS_API_URL, { + const url = new URL(CONCENTRATORS_API_URL); + url.searchParams.set('viewId', 'vw93mj98ylyxratm'); + + + const response = await fetch(url.toString(), { method: "GET", headers: getAuthHeaders(), }); diff --git a/src/api/meters.ts b/src/api/meters.ts index bf1fe1a..3d78d11 100644 --- a/src/api/meters.ts +++ b/src/api/meters.ts @@ -28,7 +28,7 @@ export interface MeterRecord { "Device Name": string; "Device Type": string; "Usage Analysis Type": string; - "Installed Time": string; + "installed Time": string; }; } @@ -66,7 +66,11 @@ export interface Meter { export const fetchMeters = async (): Promise => { const pageSize = 9999; try { - const response = await fetch(`${METERS_API_URL}?pageSize=${pageSize}`, { + const url = new URL(METERS_API_URL); + url.searchParams.set('viewId', 'vwo7tqwu8fi6ie83'); + url.searchParams.set('pageSize', pageSize.toString()); + + const response = await fetch(url.toString(), { method: "GET", headers: getAuthHeaders() }); @@ -96,7 +100,7 @@ export const fetchMeters = async (): Promise => { deviceName: r.fields["Device Name"] || "", deviceType: r.fields["Device Type"] || "", usageAnalysisType: r.fields["Usage Analysis Type"] || "", - installedTime: r.fields["Installed Time"] || "", + installedTime: r.fields["installed Time"] || "", })); return ans; diff --git a/src/api/projects.ts b/src/api/projects.ts index bd0f4ff..a7db656 100644 --- a/src/api/projects.ts +++ b/src/api/projects.ts @@ -11,14 +11,14 @@ export const getAuthHeaders = () => ({ export interface ProjectRecord { id: number; fields: { - "Area name"?: string; + "Area Name"?: string; "Device S/N"?: string; "Device Name"?: string; "Device Type"?: string; "Device Status"?: string; Operator?: string; "Installed Time"?: string; - "Communication Time"?: string; + "Communication time"?: string; "Instruction Manual"?: string | null; }; } @@ -41,7 +41,6 @@ export interface Project { operator: string; installedTime: string; communicationTime: string; - instructionManual: string; } export const fetchProjectNames = async (): Promise => { @@ -65,7 +64,7 @@ export const fetchProjectNames = async (): Promise => { const projectNames = [ ...new Set( data.records - .map((record) => record.fields["Area name"] || "") + .map((record) => record.fields["Area Name"] || "") .filter((name) => name) ), ]; @@ -79,7 +78,10 @@ export const fetchProjectNames = async (): Promise => { export const fetchProjects = async (): Promise => { try { - const response = await fetch(PROJECTS_API_URL, { + const url = new URL(PROJECTS_API_URL); + url.searchParams.set('viewId', 'vwrrxvlzlxi7jfe7'); + + const response = await fetch(url.toString(), { method: "GET", headers: getAuthHeaders(), }); @@ -92,7 +94,7 @@ export const fetchProjects = async (): Promise => { return data.records.map((r: ProjectRecord) => ({ id: r.id.toString(), - areaName: r.fields["Area name"] ?? "", + areaName: r.fields["Area Name"] ?? "", deviceSN: r.fields["Device S/N"] ?? "", deviceName: r.fields["Device Name"] ?? "", deviceType: r.fields["Device Type"] ?? "", @@ -100,8 +102,8 @@ export const fetchProjects = async (): Promise => { r.fields["Device Status"] === "Installed" ? "ACTIVE" : "INACTIVE", operator: r.fields["Operator"] ?? "", installedTime: r.fields["Installed Time"] ?? "", - communicationTime: r.fields["Communication Time"] ?? "", - instructionManual: r.fields["Instruction Manual"] ?? "", + communicationTime: r.fields["Communication time"] ?? "", + instructionManual: "", })); } catch (error) { console.error("Error fetching projects:", error); @@ -117,7 +119,7 @@ export const createProject = async ( headers: getAuthHeaders(), body: JSON.stringify({ fields: { - "Area name": projectData.areaName, + "Area Name": projectData.areaName, "Device S/N": projectData.deviceSN, "Device Name": projectData.deviceName, "Device Type": projectData.deviceType, @@ -125,7 +127,7 @@ export const createProject = async ( projectData.deviceStatus === "ACTIVE" ? "Installed" : "Inactive", Operator: projectData.operator, "Installed Time": projectData.installedTime, - "Communication Time": projectData.communicationTime, + "Communication time": projectData.communicationTime, }, }), }); @@ -145,7 +147,7 @@ export const createProject = async ( return { id: createdRecord.id.toString(), - areaName: createdRecord.fields["Area name"] ?? projectData.areaName, + areaName: createdRecord.fields["Area Name"] ?? projectData.areaName, deviceSN: createdRecord.fields["Device S/N"] ?? projectData.deviceSN, deviceName: createdRecord.fields["Device Name"] ?? projectData.deviceName, deviceType: createdRecord.fields["Device Type"] ?? projectData.deviceType, @@ -157,11 +159,8 @@ export const createProject = async ( installedTime: createdRecord.fields["Installed Time"] ?? projectData.installedTime, communicationTime: - createdRecord.fields["Communication Time"] ?? + createdRecord.fields["Communication time"] ?? projectData.communicationTime, - instructionManual: - createdRecord.fields["Instruction Manual"] ?? - projectData.instructionManual, }; }; @@ -175,7 +174,7 @@ export const updateProject = async ( body: JSON.stringify({ id: parseInt(id), fields: { - "Area name": projectData.areaName, + "Area Name": projectData.areaName, "Device S/N": projectData.deviceSN, "Device Name": projectData.deviceName, "Device Type": projectData.deviceType, @@ -183,7 +182,7 @@ export const updateProject = async ( projectData.deviceStatus === "ACTIVE" ? "Installed" : "Inactive", Operator: projectData.operator, "Installed Time": projectData.installedTime, - "Communication Time": projectData.communicationTime, + "Communication time": projectData.communicationTime, }, }), }); @@ -209,7 +208,7 @@ export const updateProject = async ( return { id: updatedRecord.id.toString(), - areaName: updatedRecord.fields["Area name"] ?? projectData.areaName, + areaName: updatedRecord.fields["Area Name"] ?? projectData.areaName, deviceSN: updatedRecord.fields["Device S/N"] ?? projectData.deviceSN, deviceName: updatedRecord.fields["Device Name"] ?? projectData.deviceName, deviceType: updatedRecord.fields["Device Type"] ?? projectData.deviceType, @@ -221,11 +220,8 @@ export const updateProject = async ( installedTime: updatedRecord.fields["Installed Time"] ?? projectData.installedTime, communicationTime: - updatedRecord.fields["Communication Time"] ?? + updatedRecord.fields["Communication time"] ?? projectData.communicationTime, - instructionManual: - updatedRecord.fields["Instruction Manual"] ?? - projectData.instructionManual, }; }; diff --git a/src/pages/meters/MeterPage.tsx b/src/pages/meters/MeterPage.tsx index daef8f9..0ba31ed 100644 --- a/src/pages/meters/MeterPage.tsx +++ b/src/pages/meters/MeterPage.tsx @@ -533,7 +533,7 @@ export default function MeterManagement({ {/* SEARCH */} setSearch(e.target.value)} disabled={!selectedProject} diff --git a/src/pages/projects/ProjectsPage.tsx b/src/pages/projects/ProjectsPage.tsx index c366004..87e5c9b 100644 --- a/src/pages/projects/ProjectsPage.tsx +++ b/src/pages/projects/ProjectsPage.tsx @@ -28,7 +28,6 @@ export default function ProjectsPage() { operator: "", installedTime: "", communicationTime: "", - instructionManual: "", }; const [form, setForm] = useState>(emptyProject); @@ -149,7 +148,6 @@ export default function ProjectsPage() { operator: activeProject.operator, installedTime: activeProject.installedTime, communicationTime: activeProject.communicationTime, - instructionManual: activeProject.instructionManual, }); setShowModal(true); }} @@ -210,8 +208,7 @@ export default function ProjectsPage() { }, { title: "Operator", field: "operator" }, { title: "Installed Time", field: "installedTime" }, - { title: "Communication Time", field: "communicationTime" }, - { title: "Instruction Manual", field: "instructionManual" }, + { title: "Communication Name", field: "communicationTime" }, ]} data={filtered} onRowClick={(_, rowData) => setActiveProject(rowData as Project)} @@ -297,15 +294,6 @@ export default function ProjectsPage() { } /> - - setForm({ ...form, instructionManual: e.target.value }) - } - /> -