web2019/static/js/shop/Crate.jsx

40 lines
1.1 KiB
React
Raw Normal View History

import React from 'react';
2023-12-12 18:21:09 +08:00
import {Cart} from "./Cart";
import {CrateMode} from "./CrateMode";
import {CrateWarnings} from "./CrateWarnings";
import {useShopStore} from "./shop_store";
/**
* Component that displays the main crate with reminder rules.
* It includes <Cart> and rules
*/
export function Crate({crate_index}) {
const {
onDeleteCrate,
crate
} = useShopStore(state => ({
onDeleteCrate: state.delCrate,
crate: state.crates[crate_index]
}))
return (
<div className="crate">
<div className="crate-bar d-inline-flex">
<CrateMode crate_index={crate_index}/>
<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>
</div>
<div className="crate-products">
<Cart crate_index={crate_index}/>
<CrateWarnings crate_index={crate_index} />
</div>
</div>
);
}