({
part,
isLoading,
updatePartQuantity,
deletePart,
}: {
part: PartState;
isLoading: boolean;
updatePartQuantity: (partId: number, quantity: number) => Promise<void>;
deletePart: (partId: number) => Promise<void>;
})
| 591 | } |
| 592 | |
| 593 | function PartItem({ |
| 594 | part, |
| 595 | isLoading, |
| 596 | updatePartQuantity, |
| 597 | deletePart, |
| 598 | }: { |
| 599 | part: PartState; |
| 600 | isLoading: boolean; |
| 601 | updatePartQuantity: (partId: number, quantity: number) => Promise<void>; |
| 602 | deletePart: (partId: number) => Promise<void>; |
| 603 | }) { |
| 604 | const addQuantityRef = useRef<HTMLInputElement>(null); |
| 605 | const removeQuantityRef = useRef<HTMLInputElement>(null); |
| 606 | return ( |
| 607 | <Table.Tr key={part.id}> |
| 608 | <Table.Td> |
| 609 | <img |
| 610 | src={part.productImages[0]} |
| 611 | // alt={part.title} |
| 612 | width="100" |
| 613 | height="100" |
| 614 | /> |
| 615 | </Table.Td> |
| 616 | <Table.Td> |
| 617 | <Stack gap={"sm"}> |
| 618 | {part.title} |
| 619 | <NavLink |
| 620 | href={"/part/" + part.id} |
| 621 | label="Details" |
| 622 | active |
| 623 | leftSection={ |
| 624 | <ThemeIcon> |
| 625 | <IconArrowLeftFromArc /> |
| 626 | </ThemeIcon> |
| 627 | } |
| 628 | /> |
| 629 | </Stack> |
| 630 | </Table.Td> |
| 631 | <Table.Td>{part.productCode}</Table.Td> |
| 632 | <Table.Td>{part.quantity}</Table.Td> |
| 633 | <Table.Td> |
| 634 | <Tabs variant="outline" defaultValue={"add"} w={200}> |
| 635 | <Tabs.List justify="center"> |
| 636 | <Tabs.Tab value={"add"}>Add</Tabs.Tab> |
| 637 | <Tabs.Tab value={"remove"}>Remove</Tabs.Tab> |
| 638 | </Tabs.List> |
| 639 | <Tabs.Panel value="add"> |
| 640 | <Stack gap={"sm"} pt={3}> |
| 641 | <NumberInput |
| 642 | placeholder="Quantity" |
| 643 | label="Quantity" |
| 644 | min={1} |
| 645 | clampBehavior="strict" |
| 646 | defaultValue={1} |
| 647 | ref={addQuantityRef} |
| 648 | /> |
| 649 | <Button |
| 650 | disabled={isLoading} |
nothing calls this directly
no test coverage detected