forked from Yara724/api
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user