feat(flow-ui): load branch staff from parsian seeds

Load seeded staff and product-specific codes, preserve intentional missing-code markers, and disable options without codes.
This commit is contained in:
2026-11-21 10:34:07 +03:30
parent 5242a22c6c
commit 5818f7f881
5 changed files with 135 additions and 58 deletions
+27 -1
View File
@@ -1018,12 +1018,38 @@ function runStage(stage, options = {}) {
});
}
function parsianBranchSeeds() {
const dir = path.join(__dirname, "data", "parsian-tehran");
const read = (file) => JSON.parse(fs.readFileSync(path.join(dir, file), "utf8"));
const branches = Object.fromEntries(read("branches.json").branches.map((b) => [
b.code, { name: `${b.name} (${b.code})`, makers: [], reviewers: [] },
]));
for (const [file, key, role, thirdParty, body] of [
["file-makers.json", "fileMakers", "makers", "ThirdPartyClaimExpertId", "CarBodyClaimExpertId"],
["file-reviewers.json", "fileReviewers", "reviewers", "ThirdPartyExpertiseClaim", "CarBodyExpertiseClaim"],
]) {
for (const expert of read(file)[key]) {
for (const location of expert.locations || []) {
if (!branches[location.id]) continue;
branches[location.id][role].push({
name: `${expert.firstName} ${expert.lastName}`,
[role === "makers" ? "claim" : "tp"]: expert[thirdParty] || "",
body: expert[body] || "",
});
}
}
}
return branches;
}
const server = http.createServer(async (req, res) => {
const url = new URL(req.url, `http://${HOST}:${PORT}`);
try {
if (req.method === "GET" && (url.pathname === "/" || url.pathname === "/index.html")) {
send(res, 200, fs.readFileSync(UI_HTML, "utf8"), "text/html; charset=utf-8");
const seeds = JSON.stringify(parsianBranchSeeds()).replace(/</g, "\\u003c");
const html = fs.readFileSync(UI_HTML, "utf8").replace("/* PARSIAN_BRANCH_SEEDS */ {}", () => seeds);
send(res, 200, html, "text/html; charset=utf-8");
return;
}