2023-12-07 17:08:22 +08:00
|
|
|
import React from 'react';
|
|
|
|
import {Cart} from "./Cart.jsx";
|
|
|
|
import {CrateMode} from "./CrateMode.jsx";
|
|
|
|
import {CrateWarnings} from "./CrateWarnings.jsx";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that displays the main crate with reminder rules.
|
|
|
|
* It includes <Cart> and rules
|
|
|
|
*/
|
2023-12-08 16:39:28 +08:00
|
|
|
export function Crate({
|
|
|
|
data,
|
|
|
|
handleToggleOverlayRemove,
|
|
|
|
handleDeleteItem,
|
|
|
|
handleShowOverlayRemove,
|
|
|
|
handleCardsUpdated,
|
|
|
|
isMobile,
|
|
|
|
isTouch,
|
|
|
|
onDelete,
|
|
|
|
onModeChange
|
|
|
|
}) {
|
2023-12-07 17:08:22 +08:00
|
|
|
return (
|
|
|
|
<div className="crate">
|
|
|
|
|
2023-12-08 16:39:28 +08:00
|
|
|
<CrateMode current={data.mode} onChange={onModeChange}/>
|
2023-12-07 17:08:22 +08:00
|
|
|
|
2023-12-07 17:50:33 +08:00
|
|
|
<div>
|
|
|
|
Delete crate
|
|
|
|
<button style={{width: "32px"}} onClick={() => onDelete(data.id)}>
|
2023-12-08 16:39:28 +08:00
|
|
|
<img src="/images/shop/icon-remove.svg" alt="remove"/>
|
2023-12-07 17:50:33 +08:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2023-12-07 17:08:22 +08:00
|
|
|
<div className="crate-products">
|
|
|
|
|
|
|
|
<Cart
|
|
|
|
data={data}
|
|
|
|
isMobile={isMobile}
|
|
|
|
isTouch={isTouch}
|
|
|
|
onToggleOverlayRemove={handleToggleOverlayRemove}
|
|
|
|
onClickRemoveItem={handleDeleteItem}
|
|
|
|
onClickItem={handleShowOverlayRemove}
|
|
|
|
onCardUpdate={handleCardsUpdated}>
|
|
|
|
</Cart>
|
|
|
|
|
2023-12-08 16:39:28 +08:00
|
|
|
{1 || (rules && rules.length > 0) && (
|
2023-12-07 17:08:22 +08:00
|
|
|
<CrateWarnings/>
|
|
|
|
)}
|
|
|
|
</div>
|
2023-11-30 17:26:17 +08:00
|
|
|
|
2023-12-07 17:08:22 +08:00
|
|
|
</div>
|
|
|
|
);
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
}
|