mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-19 21:00:40 +08:00
init
This commit is contained in:
parent
74c888fed7
commit
22d2eb6d90
@ -1155,7 +1155,8 @@ function productLineTypeKeyToString(key: ProductLineTypeKey): string {
|
||||
}
|
||||
|
||||
function ProductLineView({ groupedProducts, groups, existingItems, onSaveProduct, onDeleteProduct, onCreateNewItem, onOpenProductDetails, onSaveProductWithGroup, onCreateProductLine, onUpdateProductLine, onDeleteProductLine, createDraftRequestId, draftCustomerType, onDraftHandled, paymentsConfig, onMoveProduct }: ProductLineViewProps) {
|
||||
const projectId = useProjectId();
|
||||
const hexclaveAdminApp = useAdminApp();
|
||||
const projectId = hexclaveAdminApp.projectId;
|
||||
const [drafts, setDrafts] = useState<Array<{ key: string, productLineId: string | undefined, product: Product }>>([]);
|
||||
const [creatingGroupKey, setCreatingGroupKey] = useState<string | undefined>(undefined);
|
||||
const [newProductLineDisplayName, setNewProductLineDisplayName] = useState("");
|
||||
@ -1203,6 +1204,12 @@ function ProductLineView({ groupedProducts, groups, existingItems, onSaveProduct
|
||||
return new Set(all);
|
||||
}, [groupedProducts, drafts]);
|
||||
const lastHandledDraftRequestRef = useRef<string | undefined>(undefined);
|
||||
const getCreateProductHref = (productLineId: string | undefined, customerType: 'user' | 'team' | 'custom' | undefined) => {
|
||||
if (productLineId == null || customerType == null) {
|
||||
return urlString`/projects/${projectId}/payments/products/new`;
|
||||
}
|
||||
return urlString`/projects/${projectId}/payments/products/new?productLineId=${productLineId}&customerType=${customerType}`;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!createDraftRequestId) return;
|
||||
@ -1478,7 +1485,7 @@ function ProductLineView({ groupedProducts, groups, existingItems, onSaveProduct
|
||||
))}
|
||||
|
||||
{/* Add product button */}
|
||||
<Link href={productLineId && customerType ? urlString`/projects/${projectId}/payments/products/new?productLineId=${productLineId}&customerType=${customerType}` : urlString`/projects/${projectId}/payments/products/new`}>
|
||||
<Link href={getCreateProductHref(productLineId, customerType)}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="plain"
|
||||
@ -1533,7 +1540,7 @@ function ProductLineView({ groupedProducts, groups, existingItems, onSaveProduct
|
||||
onOpenDetails={(o) => onOpenProductDetails(o)}
|
||||
/>
|
||||
))}
|
||||
<Link href={`/projects/${projectId}/payments/products/new`}>
|
||||
<Link href={getCreateProductHref(undefined, undefined)}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="plain"
|
||||
|
||||
@ -45,30 +45,32 @@ export function PurchaseQuantitySelector({
|
||||
type="button"
|
||||
size="icon"
|
||||
variant="outline"
|
||||
className="size-8 border-border/40 bg-foreground/[0.01] hover:bg-foreground/[0.03]"
|
||||
className="size-8 shrink-0 border-border/40 bg-foreground/[0.01] hover:bg-foreground/[0.03]"
|
||||
disabled={quantityNumber <= 1}
|
||||
aria-label="Decrease quantity"
|
||||
onClick={() => onQuantityChange(String(Math.max(1, quantityNumber - 1)))}
|
||||
>
|
||||
<MinusIcon className="size-3.5 text-foreground" />
|
||||
</DesignButton>
|
||||
<DesignInput
|
||||
className="h-8 w-20 text-center text-sm font-semibold tabular-nums border-border/40 bg-foreground/[0.01] text-foreground focus-visible:ring-blue-500/20"
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
type="text"
|
||||
value={quantityInput}
|
||||
aria-label="Quantity"
|
||||
onChange={(event) => {
|
||||
const digitsOnly = event.target.value.replace(/[^0-9]/g, "");
|
||||
onQuantityChange(digitsOnly);
|
||||
}}
|
||||
/>
|
||||
<div className="w-20 shrink-0">
|
||||
<DesignInput
|
||||
className="h-8 text-center text-sm font-semibold tabular-nums border-border/40 bg-foreground/[0.01] text-foreground focus-visible:ring-blue-500/20"
|
||||
inputMode="numeric"
|
||||
pattern="[0-9]*"
|
||||
type="text"
|
||||
value={quantityInput}
|
||||
aria-label="Quantity"
|
||||
onChange={(event) => {
|
||||
const digitsOnly = event.target.value.replace(/[^0-9]/g, "");
|
||||
onQuantityChange(digitsOnly);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<DesignButton
|
||||
type="button"
|
||||
size="icon"
|
||||
variant="outline"
|
||||
className="size-8 border-border/40 bg-foreground/[0.01] hover:bg-foreground/[0.03]"
|
||||
className="size-8 shrink-0 border-border/40 bg-foreground/[0.01] hover:bg-foreground/[0.03]"
|
||||
aria-label="Increase quantity"
|
||||
onClick={() => onQuantityChange(String(quantityNumber + 1))}
|
||||
>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user