@optifye/dashboard-core 6.10.51 → 6.10.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -7
- package/dist/index.mjs +31 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -62452,6 +62452,21 @@ var ShiftsView = ({
|
|
|
62452
62452
|
}
|
|
62453
62453
|
const factoryId = existingLineThreshold?.factory_id || lineFactoryId;
|
|
62454
62454
|
if (factoryId) {
|
|
62455
|
+
let resolvedLineThresholdSkuId = existingLineThreshold?.sku_id || null;
|
|
62456
|
+
if (!resolvedLineThresholdSkuId) {
|
|
62457
|
+
const { data: dummySkuRows, error: dummySkuError } = await supabase.from("skus").select("id").eq("line_id", lineId).eq("sku_definition", "dummy_definition").eq("is_active", true).limit(1);
|
|
62458
|
+
if (dummySkuError) {
|
|
62459
|
+
throw new Error(
|
|
62460
|
+
`Failed to resolve dummy SKU for line ${lineId}, shift ${shift.shiftId}: ${dummySkuError.message}`
|
|
62461
|
+
);
|
|
62462
|
+
}
|
|
62463
|
+
resolvedLineThresholdSkuId = dummySkuRows?.[0]?.id || null;
|
|
62464
|
+
}
|
|
62465
|
+
if (!resolvedLineThresholdSkuId) {
|
|
62466
|
+
throw new Error(
|
|
62467
|
+
`No active SKU found for line ${lineId}, shift ${shift.shiftId} while updating line thresholds`
|
|
62468
|
+
);
|
|
62469
|
+
}
|
|
62455
62470
|
const lineThresholdPayload = {
|
|
62456
62471
|
factory_id: factoryId,
|
|
62457
62472
|
line_id: lineId,
|
|
@@ -62459,12 +62474,10 @@ var ShiftsView = ({
|
|
|
62459
62474
|
shift_id: shift.shiftId,
|
|
62460
62475
|
product_code: existingLineThreshold?.product_code || "",
|
|
62461
62476
|
threshold_day_output: thresholdDayOutput,
|
|
62462
|
-
threshold_pph: thresholdPPH
|
|
62477
|
+
threshold_pph: thresholdPPH,
|
|
62478
|
+
sku_id: resolvedLineThresholdSkuId
|
|
62463
62479
|
};
|
|
62464
|
-
|
|
62465
|
-
lineThresholdPayload.sku_id = existingLineThreshold.sku_id;
|
|
62466
|
-
}
|
|
62467
|
-
const { error: lineThresholdUpsertError } = await supabase.from("line_thresholds").upsert(lineThresholdPayload, { onConflict: "factory_id,line_id,date,shift_id" });
|
|
62480
|
+
const { error: lineThresholdUpsertError } = await supabase.from("line_thresholds").upsert(lineThresholdPayload, { onConflict: "factory_id,line_id,date,shift_id,sku_id" });
|
|
62468
62481
|
if (lineThresholdUpsertError) {
|
|
62469
62482
|
throw new Error(
|
|
62470
62483
|
`Failed to update line thresholds for line ${lineId}, shift ${shift.shiftId}: ${lineThresholdUpsertError.message}`
|
|
@@ -64252,6 +64265,17 @@ var TargetsView = ({
|
|
|
64252
64265
|
await workspaceService.updateActionThresholds(workspaceThresholdUpdates);
|
|
64253
64266
|
console.log(`[handleSaveLine] Successfully updated action thresholds for ${lineId}`);
|
|
64254
64267
|
const packagingWorkspaces = lineDataToSave.workspaces.filter((ws) => ws.actionType === "packaging");
|
|
64268
|
+
let resolvedLineThresholdSkuId = lineDataToSave.selectedSKU?.id || null;
|
|
64269
|
+
if (!resolvedLineThresholdSkuId) {
|
|
64270
|
+
const { data: dummySkuRows, error: dummySkuError } = await supabase.from("skus").select("id").eq("line_id", lineId).eq("sku_definition", "dummy_definition").eq("is_active", true).limit(1);
|
|
64271
|
+
if (dummySkuError) {
|
|
64272
|
+
throw dummySkuError;
|
|
64273
|
+
}
|
|
64274
|
+
resolvedLineThresholdSkuId = dummySkuRows?.[0]?.id || null;
|
|
64275
|
+
}
|
|
64276
|
+
if (!resolvedLineThresholdSkuId) {
|
|
64277
|
+
throw new Error(`No active SKU found for line ${lineId} while saving line thresholds`);
|
|
64278
|
+
}
|
|
64255
64279
|
const lineThresholdData = {
|
|
64256
64280
|
factory_id: currentFactoryId,
|
|
64257
64281
|
line_id: lineId,
|
|
@@ -64261,10 +64285,10 @@ var TargetsView = ({
|
|
|
64261
64285
|
threshold_day_output: packagingWorkspaces.reduce((acc, ws) => acc + (Number(ws.targetDayOutput) || 0), 0),
|
|
64262
64286
|
threshold_pph: packagingWorkspaces.reduce((acc, ws) => acc + (ws.targetPPH ? Math.round(Number(ws.targetPPH)) : 0), 0),
|
|
64263
64287
|
// Round each PPH value
|
|
64264
|
-
|
|
64288
|
+
sku_id: resolvedLineThresholdSkuId
|
|
64265
64289
|
};
|
|
64266
64290
|
console.log(`[handleSaveLine] lineThresholdData for upsert on ${lineId}:`, lineThresholdData);
|
|
64267
|
-
const { error: lineUpsertError } = await supabase.from("line_thresholds").upsert(lineThresholdData, { onConflict: "factory_id,line_id,date,shift_id" });
|
|
64291
|
+
const { error: lineUpsertError } = await supabase.from("line_thresholds").upsert(lineThresholdData, { onConflict: "factory_id,line_id,date,shift_id,sku_id" });
|
|
64268
64292
|
if (lineUpsertError) {
|
|
64269
64293
|
console.error(`[handleSaveLine] Error upserting line_thresholds for ${lineId}:`, lineUpsertError);
|
|
64270
64294
|
sonner.toast.error(`Failed to save line thresholds for ${mergedLineNames[lineId] || lineId}`);
|
package/dist/index.mjs
CHANGED
|
@@ -62423,6 +62423,21 @@ var ShiftsView = ({
|
|
|
62423
62423
|
}
|
|
62424
62424
|
const factoryId = existingLineThreshold?.factory_id || lineFactoryId;
|
|
62425
62425
|
if (factoryId) {
|
|
62426
|
+
let resolvedLineThresholdSkuId = existingLineThreshold?.sku_id || null;
|
|
62427
|
+
if (!resolvedLineThresholdSkuId) {
|
|
62428
|
+
const { data: dummySkuRows, error: dummySkuError } = await supabase.from("skus").select("id").eq("line_id", lineId).eq("sku_definition", "dummy_definition").eq("is_active", true).limit(1);
|
|
62429
|
+
if (dummySkuError) {
|
|
62430
|
+
throw new Error(
|
|
62431
|
+
`Failed to resolve dummy SKU for line ${lineId}, shift ${shift.shiftId}: ${dummySkuError.message}`
|
|
62432
|
+
);
|
|
62433
|
+
}
|
|
62434
|
+
resolvedLineThresholdSkuId = dummySkuRows?.[0]?.id || null;
|
|
62435
|
+
}
|
|
62436
|
+
if (!resolvedLineThresholdSkuId) {
|
|
62437
|
+
throw new Error(
|
|
62438
|
+
`No active SKU found for line ${lineId}, shift ${shift.shiftId} while updating line thresholds`
|
|
62439
|
+
);
|
|
62440
|
+
}
|
|
62426
62441
|
const lineThresholdPayload = {
|
|
62427
62442
|
factory_id: factoryId,
|
|
62428
62443
|
line_id: lineId,
|
|
@@ -62430,12 +62445,10 @@ var ShiftsView = ({
|
|
|
62430
62445
|
shift_id: shift.shiftId,
|
|
62431
62446
|
product_code: existingLineThreshold?.product_code || "",
|
|
62432
62447
|
threshold_day_output: thresholdDayOutput,
|
|
62433
|
-
threshold_pph: thresholdPPH
|
|
62448
|
+
threshold_pph: thresholdPPH,
|
|
62449
|
+
sku_id: resolvedLineThresholdSkuId
|
|
62434
62450
|
};
|
|
62435
|
-
|
|
62436
|
-
lineThresholdPayload.sku_id = existingLineThreshold.sku_id;
|
|
62437
|
-
}
|
|
62438
|
-
const { error: lineThresholdUpsertError } = await supabase.from("line_thresholds").upsert(lineThresholdPayload, { onConflict: "factory_id,line_id,date,shift_id" });
|
|
62451
|
+
const { error: lineThresholdUpsertError } = await supabase.from("line_thresholds").upsert(lineThresholdPayload, { onConflict: "factory_id,line_id,date,shift_id,sku_id" });
|
|
62439
62452
|
if (lineThresholdUpsertError) {
|
|
62440
62453
|
throw new Error(
|
|
62441
62454
|
`Failed to update line thresholds for line ${lineId}, shift ${shift.shiftId}: ${lineThresholdUpsertError.message}`
|
|
@@ -64223,6 +64236,17 @@ var TargetsView = ({
|
|
|
64223
64236
|
await workspaceService.updateActionThresholds(workspaceThresholdUpdates);
|
|
64224
64237
|
console.log(`[handleSaveLine] Successfully updated action thresholds for ${lineId}`);
|
|
64225
64238
|
const packagingWorkspaces = lineDataToSave.workspaces.filter((ws) => ws.actionType === "packaging");
|
|
64239
|
+
let resolvedLineThresholdSkuId = lineDataToSave.selectedSKU?.id || null;
|
|
64240
|
+
if (!resolvedLineThresholdSkuId) {
|
|
64241
|
+
const { data: dummySkuRows, error: dummySkuError } = await supabase.from("skus").select("id").eq("line_id", lineId).eq("sku_definition", "dummy_definition").eq("is_active", true).limit(1);
|
|
64242
|
+
if (dummySkuError) {
|
|
64243
|
+
throw dummySkuError;
|
|
64244
|
+
}
|
|
64245
|
+
resolvedLineThresholdSkuId = dummySkuRows?.[0]?.id || null;
|
|
64246
|
+
}
|
|
64247
|
+
if (!resolvedLineThresholdSkuId) {
|
|
64248
|
+
throw new Error(`No active SKU found for line ${lineId} while saving line thresholds`);
|
|
64249
|
+
}
|
|
64226
64250
|
const lineThresholdData = {
|
|
64227
64251
|
factory_id: currentFactoryId,
|
|
64228
64252
|
line_id: lineId,
|
|
@@ -64232,10 +64256,10 @@ var TargetsView = ({
|
|
|
64232
64256
|
threshold_day_output: packagingWorkspaces.reduce((acc, ws) => acc + (Number(ws.targetDayOutput) || 0), 0),
|
|
64233
64257
|
threshold_pph: packagingWorkspaces.reduce((acc, ws) => acc + (ws.targetPPH ? Math.round(Number(ws.targetPPH)) : 0), 0),
|
|
64234
64258
|
// Round each PPH value
|
|
64235
|
-
|
|
64259
|
+
sku_id: resolvedLineThresholdSkuId
|
|
64236
64260
|
};
|
|
64237
64261
|
console.log(`[handleSaveLine] lineThresholdData for upsert on ${lineId}:`, lineThresholdData);
|
|
64238
|
-
const { error: lineUpsertError } = await supabase.from("line_thresholds").upsert(lineThresholdData, { onConflict: "factory_id,line_id,date,shift_id" });
|
|
64262
|
+
const { error: lineUpsertError } = await supabase.from("line_thresholds").upsert(lineThresholdData, { onConflict: "factory_id,line_id,date,shift_id,sku_id" });
|
|
64239
64263
|
if (lineUpsertError) {
|
|
64240
64264
|
console.error(`[handleSaveLine] Error upserting line_thresholds for ${lineId}:`, lineUpsertError);
|
|
64241
64265
|
toast.error(`Failed to save line thresholds for ${mergedLineNames[lineId] || lineId}`);
|