Skip to content

Commit

Permalink
Merge pull request #139 from Program-AR/agregar-escenario
Browse files Browse the repository at this point in the history
Eliminar "agregar escenario"
  • Loading branch information
dlopezalvas authored Nov 15, 2023
2 parents 88f3685 + 0817e22 commit 5ef0e67
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
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

0 comments on commit 5ef0e67

Please sign in to comment.