- Remove KpiCarousel/RecentActivity from pop main pages (7 companies) - Empty banner default; rename settings key home -> main - Strip API fetch/cache from usePopSettings, return hardcoded defaults - Drop screen_layouts_pop auto-clone/fallback for regular users - Add SUPER_ADMIN direct-entry branch in AppLayout pop handler Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
116 lines
2.8 KiB
TypeScript
116 lines
2.8 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
|
|
export interface PopSettings {
|
|
version: string;
|
|
screens: {
|
|
processExecution: {
|
|
materialInput: boolean;
|
|
photoUpload: boolean;
|
|
plcEnabled: boolean;
|
|
bomFlexible: boolean;
|
|
packagingOptions: string[];
|
|
defectTypes: string[];
|
|
reworkTargetSelection: boolean;
|
|
groupPhotoEnabled: boolean;
|
|
dateFilter: boolean;
|
|
lastProcessInventory: "auto" | "manual" | "button";
|
|
defaultWarehouse: boolean;
|
|
inspectionAutoJudge: "off" | "warn" | "fail";
|
|
standardTimeDisplay: boolean;
|
|
progressDisplay: boolean;
|
|
};
|
|
inbound: {
|
|
inspectionRequired: boolean;
|
|
photoUpload: boolean;
|
|
barcodeEnabled: boolean;
|
|
packagingRecord: boolean;
|
|
defectSeparation: boolean;
|
|
};
|
|
outbound: {
|
|
photoUpload: boolean;
|
|
barcodeEnabled: boolean;
|
|
};
|
|
main: {
|
|
kpiCarousel: boolean;
|
|
recentActivity: boolean;
|
|
bannerEnabled: boolean;
|
|
bannerText: string;
|
|
iconThemeColor: string;
|
|
iconCustomImages: boolean;
|
|
dashboardLayout: "default" | "compact" | "detailed";
|
|
};
|
|
plc: {
|
|
connectionType: "db" | "opcua" | "rest";
|
|
refreshInterval: number;
|
|
tagMappings: Array<{
|
|
tagName: string;
|
|
processCode: string;
|
|
checklistItemId: string;
|
|
unit: string;
|
|
}>;
|
|
alarmThresholds: Array<{
|
|
tagName: string;
|
|
lowerLimit: number;
|
|
upperLimit: number;
|
|
action: "warn" | "stop";
|
|
}>;
|
|
};
|
|
};
|
|
}
|
|
|
|
const DEFAULT_SETTINGS: PopSettings = {
|
|
version: "hardcoded-1.0",
|
|
screens: {
|
|
processExecution: {
|
|
materialInput: false,
|
|
photoUpload: false,
|
|
plcEnabled: false,
|
|
bomFlexible: false,
|
|
packagingOptions: [],
|
|
defectTypes: [],
|
|
reworkTargetSelection: false,
|
|
groupPhotoEnabled: false,
|
|
dateFilter: false,
|
|
lastProcessInventory: "manual",
|
|
defaultWarehouse: false,
|
|
inspectionAutoJudge: "off",
|
|
standardTimeDisplay: false,
|
|
progressDisplay: false,
|
|
},
|
|
inbound: {
|
|
inspectionRequired: false,
|
|
photoUpload: false,
|
|
barcodeEnabled: false,
|
|
packagingRecord: false,
|
|
defectSeparation: false,
|
|
},
|
|
outbound: {
|
|
photoUpload: false,
|
|
barcodeEnabled: false,
|
|
},
|
|
main: {
|
|
kpiCarousel: false,
|
|
recentActivity: false,
|
|
bannerEnabled: false,
|
|
bannerText: "",
|
|
iconThemeColor: "",
|
|
iconCustomImages: false,
|
|
dashboardLayout: "default",
|
|
},
|
|
plc: {
|
|
connectionType: "db",
|
|
refreshInterval: 5,
|
|
tagMappings: [],
|
|
alarmThresholds: [],
|
|
},
|
|
},
|
|
};
|
|
|
|
export function usePopSettings(_screenPath?: string) {
|
|
const [settings] = useState<PopSettings>(DEFAULT_SETTINGS);
|
|
const [loading] = useState(false);
|
|
return { settings, loading };
|
|
}
|