implemented pr (worth fixing) feedback

update commit
This commit is contained in:
behrinml
2026-08-06 20:27:25 +02:00
parent 9a397f46e9
commit dd1d40b0d4
56 changed files with 1601 additions and 278 deletions
@@ -15,6 +15,7 @@ export function CostCenterSelect({
const { t } = useTranslation();
if (costCenters.length === 0) return null;
const selectedCostCenter = costCenters.find((center) => center.id === selectedCostCenterId);
return (
<div className="space-y-1">
@@ -33,6 +34,11 @@ export function CostCenterSelect({
</option>
))}
</select>
{selectedCostCenter?.budget_mode === 'none' && (
<p className="text-xs text-bambu-gray">
{t('printModal.unlimitedNoBudget', 'Unlimited – no budget limit is set.')}
</p>
)}
</div>
);
}
+23 -1
View File
@@ -315,7 +315,7 @@ export function PrintModal({
queryFn: api.getPrinters,
});
const { data: myCostCenters } = useQuery({
const { data: myCostCenters, isLoading: loadingCostCenters } = useQuery({
queryKey: ['finance', 'cost-centers', 'mine'],
queryFn: api.getMyCostCenters,
enabled: !!user && billingEnabled,
@@ -824,6 +824,11 @@ export function PrintModal({
const handleSubmit = async (e?: React.FormEvent, options?: { skipFilamentCheck?: boolean }) => {
e?.preventDefault();
if (billingEnabled && selectedCostCenter == null) {
showToast(t('printModal.noPrintableCostCenters'), 'error');
return;
}
if (
!options?.skipFilamentCheck &&
!settings?.disable_filament_warnings &&
@@ -1277,6 +1282,11 @@ export function PrintModal({
const canSubmit = useMemo(() => {
if (isPending) return false;
// Billing requires a server-authorized cost center. Wait for the query and
// keep submission disabled when the user has no printable center, rather
// than letting the API fail with an unexplained 400.
if (billingEnabled && (loadingCostCenters || selectedCostCenter == null)) return false;
// Need valid printer/model selection
if (assignmentMode === 'printer' && selectedPrinters.length === 0) return false;
// Both are about the single-model case. A cross-model job has no one target
@@ -1313,6 +1323,9 @@ export function PrintModal({
perPlateReqsFailed,
printerStatusLoading,
isCrossModel,
billingEnabled,
loadingCostCenters,
selectedCostCenter,
]);
// Quantity only applies for single-printer or model-based assignment (not multi-printer)
@@ -1714,6 +1727,15 @@ export function PrintModal({
onChange={setSelectedCostCenterId}
/>
)}
{billingEnabled && !loadingCostCenters && printableCostCenters.length === 0 && (
<div
role="alert"
className="p-3 bg-yellow-100 dark:bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-800 dark:text-yellow-300 flex items-start gap-2"
>
<AlertTriangle className="w-4 h-4 mt-0.5 shrink-0" />
{t('printModal.noPrintableCostCenters')}
</div>
)}
{/* Quantity — create multiple copies (batch). Hidden for multi-printer
selection, and for multi-plate files where the per-plate steppers