New changes conflicts

This commit is contained in:
2026-01-08 13:27:15 -06:00
parent 90c7b3a1c8
commit dd65f48a75
6 changed files with 33 additions and 41 deletions

View File

@@ -45,7 +45,11 @@ export interface Concentrator {
export const fetchConcentrators = async (): Promise<Concentrator[]> => { export const fetchConcentrators = async (): Promise<Concentrator[]> => {
try { 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", method: "GET",
headers: getAuthHeaders(), headers: getAuthHeaders(),
}); });

View File

@@ -28,7 +28,7 @@ export interface MeterRecord {
"Device Name": string; "Device Name": string;
"Device Type": string; "Device Type": string;
"Usage Analysis Type": string; "Usage Analysis Type": string;
"Installed Time": string; "installed Time": string;
}; };
} }
@@ -66,7 +66,11 @@ export interface Meter {
export const fetchMeters = async (): Promise<Meter[]> => { export const fetchMeters = async (): Promise<Meter[]> => {
const pageSize = 9999; const pageSize = 9999;
try { 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", method: "GET",
headers: getAuthHeaders() headers: getAuthHeaders()
}); });
@@ -96,7 +100,7 @@ export const fetchMeters = async (): Promise<Meter[]> => {
deviceName: r.fields["Device Name"] || "", deviceName: r.fields["Device Name"] || "",
deviceType: r.fields["Device Type"] || "", deviceType: r.fields["Device Type"] || "",
usageAnalysisType: r.fields["Usage Analysis Type"] || "", usageAnalysisType: r.fields["Usage Analysis Type"] || "",
installedTime: r.fields["Installed Time"] || "", installedTime: r.fields["installed Time"] || "",
})); }));
return ans; return ans;

View File

@@ -11,14 +11,14 @@ export const getAuthHeaders = () => ({
export interface ProjectRecord { export interface ProjectRecord {
id: number; id: number;
fields: { fields: {
"Area name"?: string; "Area Name"?: string;
"Device S/N"?: string; "Device S/N"?: string;
"Device Name"?: string; "Device Name"?: string;
"Device Type"?: string; "Device Type"?: string;
"Device Status"?: string; "Device Status"?: string;
Operator?: string; Operator?: string;
"Installed Time"?: string; "Installed Time"?: string;
"Communication Time"?: string; "Communication time"?: string;
"Instruction Manual"?: string | null; "Instruction Manual"?: string | null;
}; };
} }
@@ -41,7 +41,6 @@ export interface Project {
operator: string; operator: string;
installedTime: string; installedTime: string;
communicationTime: string; communicationTime: string;
instructionManual: string;
} }
export const fetchProjectNames = async (): Promise<string[]> => { export const fetchProjectNames = async (): Promise<string[]> => {
@@ -65,7 +64,7 @@ export const fetchProjectNames = async (): Promise<string[]> => {
const projectNames = [ const projectNames = [
...new Set( ...new Set(
data.records data.records
.map((record) => record.fields["Area name"] || "") .map((record) => record.fields["Area Name"] || "")
.filter((name) => name) .filter((name) => name)
), ),
]; ];
@@ -79,7 +78,10 @@ export const fetchProjectNames = async (): Promise<string[]> => {
export const fetchProjects = async (): Promise<Project[]> => { export const fetchProjects = async (): Promise<Project[]> => {
try { 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", method: "GET",
headers: getAuthHeaders(), headers: getAuthHeaders(),
}); });
@@ -92,7 +94,7 @@ export const fetchProjects = async (): Promise<Project[]> => {
return data.records.map((r: ProjectRecord) => ({ return data.records.map((r: ProjectRecord) => ({
id: r.id.toString(), id: r.id.toString(),
areaName: r.fields["Area name"] ?? "", areaName: r.fields["Area Name"] ?? "",
deviceSN: r.fields["Device S/N"] ?? "", deviceSN: r.fields["Device S/N"] ?? "",
deviceName: r.fields["Device Name"] ?? "", deviceName: r.fields["Device Name"] ?? "",
deviceType: r.fields["Device Type"] ?? "", deviceType: r.fields["Device Type"] ?? "",
@@ -100,8 +102,8 @@ export const fetchProjects = async (): Promise<Project[]> => {
r.fields["Device Status"] === "Installed" ? "ACTIVE" : "INACTIVE", r.fields["Device Status"] === "Installed" ? "ACTIVE" : "INACTIVE",
operator: r.fields["Operator"] ?? "", operator: r.fields["Operator"] ?? "",
installedTime: r.fields["Installed Time"] ?? "", installedTime: r.fields["Installed Time"] ?? "",
communicationTime: r.fields["Communication Time"] ?? "", communicationTime: r.fields["Communication time"] ?? "",
instructionManual: r.fields["Instruction Manual"] ?? "", instructionManual: "",
})); }));
} catch (error) { } catch (error) {
console.error("Error fetching projects:", error); console.error("Error fetching projects:", error);
@@ -117,7 +119,7 @@ export const createProject = async (
headers: getAuthHeaders(), headers: getAuthHeaders(),
body: JSON.stringify({ body: JSON.stringify({
fields: { fields: {
"Area name": projectData.areaName, "Area Name": projectData.areaName,
"Device S/N": projectData.deviceSN, "Device S/N": projectData.deviceSN,
"Device Name": projectData.deviceName, "Device Name": projectData.deviceName,
"Device Type": projectData.deviceType, "Device Type": projectData.deviceType,
@@ -125,7 +127,7 @@ export const createProject = async (
projectData.deviceStatus === "ACTIVE" ? "Installed" : "Inactive", projectData.deviceStatus === "ACTIVE" ? "Installed" : "Inactive",
Operator: projectData.operator, Operator: projectData.operator,
"Installed Time": projectData.installedTime, "Installed Time": projectData.installedTime,
"Communication Time": projectData.communicationTime, "Communication time": projectData.communicationTime,
}, },
}), }),
}); });
@@ -145,7 +147,7 @@ export const createProject = async (
return { return {
id: createdRecord.id.toString(), 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, deviceSN: createdRecord.fields["Device S/N"] ?? projectData.deviceSN,
deviceName: createdRecord.fields["Device Name"] ?? projectData.deviceName, deviceName: createdRecord.fields["Device Name"] ?? projectData.deviceName,
deviceType: createdRecord.fields["Device Type"] ?? projectData.deviceType, deviceType: createdRecord.fields["Device Type"] ?? projectData.deviceType,
@@ -157,11 +159,8 @@ export const createProject = async (
installedTime: installedTime:
createdRecord.fields["Installed Time"] ?? projectData.installedTime, createdRecord.fields["Installed Time"] ?? projectData.installedTime,
communicationTime: communicationTime:
createdRecord.fields["Communication Time"] ?? createdRecord.fields["Communication time"] ??
projectData.communicationTime, projectData.communicationTime,
instructionManual:
createdRecord.fields["Instruction Manual"] ??
projectData.instructionManual,
}; };
}; };
@@ -175,7 +174,7 @@ export const updateProject = async (
body: JSON.stringify({ body: JSON.stringify({
id: parseInt(id), id: parseInt(id),
fields: { fields: {
"Area name": projectData.areaName, "Area Name": projectData.areaName,
"Device S/N": projectData.deviceSN, "Device S/N": projectData.deviceSN,
"Device Name": projectData.deviceName, "Device Name": projectData.deviceName,
"Device Type": projectData.deviceType, "Device Type": projectData.deviceType,
@@ -183,7 +182,7 @@ export const updateProject = async (
projectData.deviceStatus === "ACTIVE" ? "Installed" : "Inactive", projectData.deviceStatus === "ACTIVE" ? "Installed" : "Inactive",
Operator: projectData.operator, Operator: projectData.operator,
"Installed Time": projectData.installedTime, "Installed Time": projectData.installedTime,
"Communication Time": projectData.communicationTime, "Communication time": projectData.communicationTime,
}, },
}), }),
}); });
@@ -209,7 +208,7 @@ export const updateProject = async (
return { return {
id: updatedRecord.id.toString(), 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, deviceSN: updatedRecord.fields["Device S/N"] ?? projectData.deviceSN,
deviceName: updatedRecord.fields["Device Name"] ?? projectData.deviceName, deviceName: updatedRecord.fields["Device Name"] ?? projectData.deviceName,
deviceType: updatedRecord.fields["Device Type"] ?? projectData.deviceType, deviceType: updatedRecord.fields["Device Type"] ?? projectData.deviceType,
@@ -221,11 +220,8 @@ export const updateProject = async (
installedTime: installedTime:
updatedRecord.fields["Installed Time"] ?? projectData.installedTime, updatedRecord.fields["Installed Time"] ?? projectData.installedTime,
communicationTime: communicationTime:
updatedRecord.fields["Communication Time"] ?? updatedRecord.fields["Communication time"] ??
projectData.communicationTime, projectData.communicationTime,
instructionManual:
updatedRecord.fields["Instruction Manual"] ??
projectData.instructionManual,
}; };
}; };

View File

@@ -533,7 +533,7 @@ export default function MeterManagement({
{/* SEARCH */} {/* SEARCH */}
<input <input
className="bg-white rounded-lg shadow px-4 py-2 text-sm" className="bg-white rounded-lg shadow px-4 py-2 text-sm"
placeholder="Search by meter name, serial number, device ID, or area..." placeholder="Search by meter name, serial number, device ID, area, or device type..."
value={search} value={search}
onChange={(e) => setSearch(e.target.value)} onChange={(e) => setSearch(e.target.value)}
disabled={!selectedProject} disabled={!selectedProject}

View File

@@ -28,7 +28,6 @@ export default function ProjectsPage() {
operator: "", operator: "",
installedTime: "", installedTime: "",
communicationTime: "", communicationTime: "",
instructionManual: "",
}; };
const [form, setForm] = useState<Omit<Project, "id">>(emptyProject); const [form, setForm] = useState<Omit<Project, "id">>(emptyProject);
@@ -149,7 +148,6 @@ export default function ProjectsPage() {
operator: activeProject.operator, operator: activeProject.operator,
installedTime: activeProject.installedTime, installedTime: activeProject.installedTime,
communicationTime: activeProject.communicationTime, communicationTime: activeProject.communicationTime,
instructionManual: activeProject.instructionManual,
}); });
setShowModal(true); setShowModal(true);
}} }}
@@ -210,8 +208,7 @@ export default function ProjectsPage() {
}, },
{ title: "Operator", field: "operator" }, { title: "Operator", field: "operator" },
{ title: "Installed Time", field: "installedTime" }, { title: "Installed Time", field: "installedTime" },
{ title: "Communication Time", field: "communicationTime" }, { title: "Communication Name", field: "communicationTime" },
{ title: "Instruction Manual", field: "instructionManual" },
]} ]}
data={filtered} data={filtered}
onRowClick={(_, rowData) => setActiveProject(rowData as Project)} onRowClick={(_, rowData) => setActiveProject(rowData as Project)}
@@ -297,15 +294,6 @@ export default function ProjectsPage() {
} }
/> />
<input
className="w-full border px-3 py-2 rounded"
placeholder="Instruction Manual"
value={form.instructionManual}
onChange={(e) =>
setForm({ ...form, instructionManual: e.target.value })
}
/>
<button <button
onClick={() => onClick={() =>
setForm({ setForm({

View File

@@ -30,4 +30,4 @@ export default defineConfig({
optimizeDeps: { optimizeDeps: {
include: ['react', 'react-dom', 'react-router-dom'], include: ['react', 'react-dom', 'react-router-dom'],
}, },
}) })