generated from WildCodeSchool/create-js-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from WildCodeSchool-2023-09/S06_US14
S06 us14 - DO NOT DELETE BRANCH
- Loading branch information
Showing
12 changed files
with
263 additions
and
137 deletions.
There are no files selected for viewing
Binary file added
BIN
+9.09 MB
...ssets/usersAvatars/70d17f873622ca1984a2feadd78f0c67-Pokemon arene wireframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.09 MB
...ssets/usersAvatars/999aea744a3b44829461cfcb7637dc12-Pokemon arene wireframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,71 @@ | ||
import React from "react"; | ||
import TextField from "@mui/material/TextField"; | ||
import Button from "@mui/material/Button"; | ||
import { useInstructionCreation } from "../contexts/InstructionCreationContext"; | ||
|
||
function Step3() { | ||
const { instructionCreation, handleChangeCreation } = | ||
useInstructionCreation(); | ||
console.info(instructionCreation); | ||
export default function Step3() { | ||
const { setInstructionList, instructionList } = useInstructionCreation(); | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const [addInstruction, setAddInstruction] = React.useState([]); | ||
const [description, setDescription] = React.useState(""); | ||
const handleAddingInstruction = () => { | ||
const instructionToAdd = { | ||
id: instructionList.length, | ||
name: description, | ||
}; | ||
setAddInstruction((prev) => [...prev, instructionToAdd]); | ||
setInstructionList((prev) => [...prev, instructionToAdd]); | ||
}; | ||
const handleReset = () => { | ||
setDescription(""); | ||
}; | ||
|
||
const handleDeleteInstruction = (id) => { | ||
setInstructionList( | ||
instructionList.filter((instruction) => instruction.id !== id) | ||
); | ||
}; | ||
|
||
const combineHandler = async () => { | ||
handleReset(); | ||
await handleAddingInstruction(); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1>Step 3</h1> | ||
<h2>Instructions</h2> | ||
<form> | ||
<input | ||
id="instructtionInput" | ||
type="text" | ||
name="description" | ||
placeholder="instructions" | ||
value={instructionCreation.description} | ||
onChange={handleChangeCreation} | ||
/> | ||
</form> | ||
<TextField | ||
className="instruction" | ||
id="instruction" | ||
maxRows={4} | ||
label="instruction" | ||
helperText="Instruction" | ||
variant="filled" | ||
value={description} | ||
onChange={(e) => setDescription(e.target.value)} | ||
name="quantity" | ||
/> | ||
<Button | ||
onClick={() => { | ||
combineHandler(); | ||
}} | ||
> | ||
Ajouter une instruction | ||
</Button> | ||
<div className="instruction-list"> | ||
{instructionList.map((item) => ( | ||
<div key={item.id}> | ||
<span>{item.name}</span> | ||
<button | ||
type="button" | ||
onClick={() => handleDeleteInstruction(item.id)} | ||
> | ||
❌ | ||
</button> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Step3; |
Oops, something went wrong.