2023-12-07 17:08:22 +08:00
|
|
|
import React from 'react';
|
2023-12-11 17:05:35 +08:00
|
|
|
import {useShopStore} from "./shop_store";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that displays crate modes
|
|
|
|
*/
|
2023-12-11 17:05:35 +08:00
|
|
|
export function CrateMode({crate_index}) {
|
|
|
|
const {modes_order, crate_modes, crate, setMode} = useShopStore(state => ({
|
|
|
|
modes_order: state.modes_order,
|
|
|
|
crate_modes: state.crate_modes,
|
2023-12-12 16:09:29 +08:00
|
|
|
crate: state.crates[crate_index],
|
2023-12-11 17:05:35 +08:00
|
|
|
setMode: state.setCrateMode
|
|
|
|
}))
|
2023-12-07 17:08:22 +08:00
|
|
|
return (
|
|
|
|
<div className="crate-mode">
|
2023-12-11 17:05:35 +08:00
|
|
|
{modes_order.map((mode_name, _) => (
|
2023-12-07 17:08:22 +08:00
|
|
|
<a
|
2023-12-11 17:05:35 +08:00
|
|
|
key={mode_name}
|
|
|
|
className={crate.crate_mode === mode_name ? 'active' : ''}
|
|
|
|
onClick={() => setMode(crate.id, mode_name)}
|
2023-12-07 17:08:22 +08:00
|
|
|
href="#"
|
2023-12-11 17:05:35 +08:00
|
|
|
role="button">{crate_modes[mode_name].name}</a>
|
2023-12-07 17:08:22 +08:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|