2023-12-07 17:08:22 +08:00
|
|
|
import React from 'react';
|
2023-12-12 18:21:09 +08:00
|
|
|
import {Cart} from "./Cart";
|
|
|
|
import {CrateMode} from "./CrateMode";
|
|
|
|
import {CrateWarnings} from "./CrateWarnings";
|
2023-12-11 17:05:35 +08:00
|
|
|
import {useShopStore} from "./shop_store";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that displays the main crate with reminder rules.
|
|
|
|
* It includes <Cart> and rules
|
|
|
|
*/
|
2023-12-11 17:05:35 +08:00
|
|
|
export function Crate({crate_index}) {
|
|
|
|
const {
|
|
|
|
onDeleteCrate,
|
|
|
|
crate
|
|
|
|
} = useShopStore(state => ({
|
|
|
|
onDeleteCrate: state.delCrate,
|
|
|
|
crate: state.crates[crate_index]
|
|
|
|
}))
|
|
|
|
|
2023-12-07 17:08:22 +08:00
|
|
|
return (
|
|
|
|
<div className="crate">
|
|
|
|
|
2023-12-13 17:35:17 +08:00
|
|
|
<div className="crate-bar d-inline-flex">
|
|
|
|
<CrateMode crate_index={crate_index}/>
|
2023-12-07 17:08:22 +08:00
|
|
|
|
2023-12-13 17:35:17 +08:00
|
|
|
<div className="delete-crate align-self-end align-content-end justify-content-end" onClick={() => onDeleteCrate(crate.id)}>
|
|
|
|
Delete crate <img src="/images/shop/icon-remove.svg" alt="remove"/>
|
|
|
|
</div>
|
2023-12-07 17:50:33 +08:00
|
|
|
</div>
|
|
|
|
|
2023-12-07 17:08:22 +08:00
|
|
|
<div className="crate-products">
|
|
|
|
|
2023-12-11 17:05:35 +08:00
|
|
|
<Cart crate_index={crate_index}/>
|
2023-12-07 17:08:22 +08:00
|
|
|
|
2023-12-12 16:09:29 +08:00
|
|
|
<CrateWarnings crate_index={crate_index} />
|
2023-12-07 17:08:22 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
}
|