Compare commits
No commits in common. "a75fae22335553fd5db2f90da860c68795483706" and "72ac9fe2fb3c39f07962fc98282a77b96cbdfd30" have entirely different histories.
a75fae2233
...
72ac9fe2fb
@ -149,6 +149,8 @@ public function run(): void
|
||||
'expenses.update',
|
||||
'expenses.delete',
|
||||
|
||||
'activity_logs.view',
|
||||
|
||||
'employee_advances.view',
|
||||
'employee_advances.create',
|
||||
'employee_advances.update',
|
||||
@ -259,6 +261,8 @@ public function run(): void
|
||||
'purchases.create',
|
||||
'purchases.update',
|
||||
'purchases.delete',
|
||||
|
||||
'activity_logs.view',
|
||||
], true);
|
||||
})),
|
||||
|
||||
@ -389,6 +393,8 @@ public function run(): void
|
||||
|
||||
'expenses.view',
|
||||
|
||||
'activity_logs.view',
|
||||
|
||||
'employee_advances.view',
|
||||
'employee_advances.create',
|
||||
'employee_advances.update',
|
||||
|
||||
@ -51,15 +51,6 @@ function createEmptyPrices(): Array<{ type: string; price: number }> {
|
||||
return PRICE_TYPES.map((pt) => ({ type: pt.key, price: 0 }));
|
||||
}
|
||||
|
||||
function normalizePrices(
|
||||
prices: Array<{ type: string; price: number }>,
|
||||
): Array<{ type: string; price: number }> {
|
||||
return PRICE_TYPES.map((pt) => {
|
||||
const existing = prices.find((p) => p.type === pt.key);
|
||||
return { type: pt.key, price: existing?.price ?? 0 };
|
||||
});
|
||||
}
|
||||
|
||||
type VariantState = {
|
||||
name: string;
|
||||
stock: number;
|
||||
@ -87,11 +78,7 @@ export default function ProductCreate({ categories }: Props) {
|
||||
);
|
||||
const [sharedPrices, setSharedPrices] = useState<
|
||||
Array<{ type: string; price: number }>
|
||||
>(
|
||||
draft?.sharedPrices
|
||||
? normalizePrices(draft.sharedPrices)
|
||||
: createEmptyPrices(),
|
||||
);
|
||||
>(draft?.sharedPrices ?? createEmptyPrices());
|
||||
const [variants, setVariants] = useState<VariantState[]>(() => {
|
||||
if (draft?.variants && draft.variants.length > 0) {
|
||||
return draft.variants.map((v) => {
|
||||
@ -105,7 +92,6 @@ export default function ProductCreate({ categories }: Props) {
|
||||
...v,
|
||||
photos,
|
||||
uploading: false,
|
||||
prices: normalizePrices(v.prices),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@ -47,38 +47,11 @@ function renderValue(value: unknown): React.ReactNode {
|
||||
return <span className="text-muted-foreground">-</span>;
|
||||
}
|
||||
|
||||
if (value.every((item) => typeof item !== 'object' || item === null)) {
|
||||
return value.join(', ');
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{value.map((item, index) => (
|
||||
<div key={index} className="rounded border border-border/50 px-2 py-1">
|
||||
{renderValue(item)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
return value.join(', ');
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
const entries = Object.entries(value as Record<string, unknown>);
|
||||
|
||||
if (entries.length === 0) {
|
||||
return <span className="text-muted-foreground">-</span>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-0.5">
|
||||
{entries.map(([key, val]) => (
|
||||
<div key={key}>
|
||||
<span className="text-muted-foreground">{key}:</span>{' '}
|
||||
{renderValue(val)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
return String(value);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user