Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminar "agregar escenario" #139

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const GridOptions = (props: StyleGridProps) => {
return <>
<Stack>
<PBCard sx={{justifyContent: "center"}}>
<Stack sx={{padding: theme.spacing(1), maxWidth: "200px"}}>
<Stack sx={{padding: theme.spacing(1), maxWidth: "200px", paddingBottom: 5, paddingTop: 4}}>
<SizeEditor setStyleGrid={props.setStyleGrid} />
<ScenarioEditionButtons/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Add, ContentCopy, Delete } from "@mui/icons-material";
import { ContentCopy, Delete } from "@mui/icons-material";
import { Button, ButtonProps, Stack, Typography, useMediaQuery } from "@mui/material";
import { GenericModalDialog } from "../../../../modalDialog/GenericModalDialog";
import { useContext, useState } from "react";
import { useTranslation } from "react-i18next";
import { LocalStorage } from "../../../../../localStorage";
import { SceneMap, defaultScene } from "../../../../serializedChallenge";
import { SceneMap } from "../../../../serializedChallenge";
import { CreatorContext } from "../../CreatorContext";
import { DialogSnackbar } from "../../../../dialogSnackbar/DialogSnackbar";
import { IconButtonTooltip } from "../IconButtonTooltip";
Expand Down Expand Up @@ -44,21 +43,14 @@ export const ScenarioEditionButtons = () => {
addMap(map)
}

const handleAdd = () => {
const type = LocalStorage.getCreatorChallenge()!.scene.type
addMap(defaultScene(type).maps[0])
}

const addMap = (map: SceneMap) => {
setMaps(maps.concat([[...map]]))
setIndex(maps.length)
}

return <>
<Stack sx={{ alignItems: 'center', gap: theme.spacing(1) }}>
<GridOptionButton startIcon={<Add />} onClick={handleAdd} tooltip={t("scenarios.add")} testid="add" />
<GridOptionButton startIcon={<ContentCopy />} onClick={handleDuplicate} tooltip={t("scenarios.duplicate")} testid="duplicate" />

<GridOptionButton startIcon={<Delete />} onClick={handleDelete} tooltip={t("scenarios.delete")} testid="delete" />
<GenericModalDialog isOpen={showDeleteDialog} onConfirm={deleteMap} onCancel={() => setShowDeleteDialog(false)} title={t("scenarios.delete")}>
<Typography>{t("scenarios.areYouSure")}</Typography>
Expand Down
7 changes: 0 additions & 7 deletions src/test/Creator/GridOptions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ describe('Scene grid', () => {
expect(maps[0]).toEqual([[EMPTY, EMPTY]])
})

test('Should add default map', async () =>{
const defaultMap = defaultScene('Duba').maps[0]
await clickButtonAtIndex('add', 0)
expect(LocalStorage.getCreatorChallenge()?.scene.maps[1]).toEqual(defaultMap)
})


test('Should duplicate map at index', async () =>{
const map = [[ACTOR, EMPTY, OBSTACLE], [OBSTACLE, EMPTY, OBSTACLE]]
saveChallange([map])
Expand Down