2023-12-07 17:08:22 +08:00
|
|
|
import React from 'react'
|
|
|
|
import {Accordion} from "react-bootstrap";
|
|
|
|
import {Crate} from "./Crate.jsx";
|
|
|
|
|
2023-12-07 17:50:33 +08:00
|
|
|
export function CrateList({crates, isMobile, isTouch, onAddCrate, onDeleteCrate}) {
|
|
|
|
const onClickAdd = (_) => {
|
|
|
|
onAddCrate("crate" + Object.entries(crates).length);
|
|
|
|
}
|
|
|
|
|
2023-12-07 17:08:22 +08:00
|
|
|
return (
|
|
|
|
<Accordion defaultActiveKey="0">
|
|
|
|
{Object.entries(crates).map(([crate_id, crate], index) =>
|
|
|
|
<Accordion.Item eventKey={`${index}`} key={`crate${index}`}>
|
|
|
|
<Accordion.Header>Crate #{`${index}`}</Accordion.Header>
|
|
|
|
<Accordion.Body>
|
2023-12-07 17:50:33 +08:00
|
|
|
<Crate data={{id: crate_id, ...crate}} isTouch={isTouch} isMobile={isMobile} onDelete={onDeleteCrate}/>
|
2023-12-07 17:08:22 +08:00
|
|
|
</Accordion.Body>
|
|
|
|
</Accordion.Item>
|
|
|
|
)}
|
2023-12-07 17:50:33 +08:00
|
|
|
<Accordion.Item eventKey="last">
|
|
|
|
<Accordion.Header>
|
|
|
|
Add new crate
|
|
|
|
<button style={{width: "32px"}} onClick={onClickAdd}>
|
|
|
|
<img src="/images/shop/icon-add.svg" alt="add" />
|
|
|
|
</button>
|
|
|
|
</Accordion.Header>
|
|
|
|
</Accordion.Item>
|
2023-12-07 17:08:22 +08:00
|
|
|
</Accordion>)
|
|
|
|
}
|