fix: rozdílné jednotky u receptů
feat: vazby a trvání receptů
This commit is contained in:
1 parent
caffb6d8b4
commit
865c2c3b22
18 files changed
+952
-78
No files matched your search
@@ -93,6 +93,8 @@ const SpinWheelModal = ({ isOpen, onClose }: Readonly<Props>) => {
|
||||
const [excludedKeys, setExcludedKeys] = useState<Set<string>>(new Set());
|
||||
const [picked, setPicked] = useState<WheelItem | undefined>();
|
||||
const [recipeShown, setRecipeShown] = useState(false);
|
||||
// Recept otevřený z vazby padlého receptu (příloha, podobný)
|
||||
const [linkedKey, setLinkedKey] = useState<string | undefined>();
|
||||
const [rotation, setRotation] = useState(0);
|
||||
const [spinning, setSpinning] = useState(false);
|
||||
const [respinRequested, setRespinRequested] = useState(false);
|
||||
@@ -134,9 +136,14 @@ const SpinWheelModal = ({ isOpen, onClose }: Readonly<Props>) => {
|
||||
const excludedCount = candidateList.length - wheelList.length;
|
||||
const onlyOne = wheelList.length === 1;
|
||||
|
||||
const showRecipe = (shown: boolean) => {
|
||||
setRecipeShown(shown);
|
||||
setLinkedKey(undefined);
|
||||
};
|
||||
|
||||
const clearResult = () => {
|
||||
setPicked(undefined);
|
||||
setRecipeShown(false);
|
||||
showRecipe(false);
|
||||
};
|
||||
|
||||
const changePool = (value: WheelPool) => {
|
||||
@@ -215,6 +222,10 @@ const SpinWheelModal = ({ isOpen, onClose }: Readonly<Props>) => {
|
||||
};
|
||||
|
||||
const pickedRecipe = picked?.group && hasRecipe(picked.group) ? picked.group : undefined;
|
||||
const recipeGroupList = (groupList ?? []).filter(hasRecipe);
|
||||
const shownRecipe = recipeShown
|
||||
? recipeGroupList.find(group => getMealKey(group) === linkedKey) ?? pickedRecipe
|
||||
: undefined;
|
||||
const pickedSource = sourceStage ? picked : undefined;
|
||||
|
||||
const renderWheel = () => {
|
||||
@@ -235,12 +246,18 @@ const SpinWheelModal = ({ isOpen, onClose }: Readonly<Props>) => {
|
||||
<Modal show={isOpen} onHide={onClose} size="lg" className="spin-wheel-modal">
|
||||
<Modal.Header closeButton>
|
||||
<Modal.Title>
|
||||
{recipeShown && pickedRecipe ? pickedRecipe.name : 'Kolo štěstí: co dnes?'}
|
||||
{shownRecipe ? shownRecipe.name : 'Kolo štěstí: co dnes?'}
|
||||
</Modal.Title>
|
||||
</Modal.Header>
|
||||
<WheelConfetti theme={theme} burstKey={confettiKey} />
|
||||
<Modal.Body>
|
||||
{recipeShown && pickedRecipe ? <WheelRecipe group={pickedRecipe} /> : (
|
||||
{shownRecipe ? (
|
||||
<WheelRecipe
|
||||
group={shownRecipe}
|
||||
recipeList={recipeGroupList.map(group => group.recipe)}
|
||||
onOpenRecipe={recipe => setLinkedKey(getMealKey(recipe))}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div className="spin-filters">
|
||||
<ButtonGroup className="spin-source" aria-label="Z čeho losovat">
|
||||
@@ -372,10 +389,10 @@ const SpinWheelModal = ({ isOpen, onClose }: Readonly<Props>) => {
|
||||
</Modal.Body>
|
||||
<Modal.Footer>
|
||||
{recipeShown && (
|
||||
<Button variant="outline-secondary" onClick={() => setRecipeShown(false)}>Zpět na kolo</Button>
|
||||
<Button variant="outline-secondary" onClick={() => showRecipe(false)}>Zpět na kolo</Button>
|
||||
)}
|
||||
{!recipeShown && pickedRecipe && !spinning && (
|
||||
<Button onClick={() => setRecipeShown(true)}>
|
||||
<Button onClick={() => showRecipe(true)}>
|
||||
<FontAwesomeIcon icon={faBookOpen} /> Zobrazit recept
|
||||
</Button>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user