Skip to content

Commit

Permalink
Merge pull request #849 from Matrx123/fix/Issue#847_Remove-step-not-w…
Browse files Browse the repository at this point in the history
…orking-in-tutorial-creation

FIX:Issue# 847 Remove step not working in tutorial creation
  • Loading branch information
shivareddy6 authored Aug 17, 2023
2 parents ec86094 + f93636e commit cd67173
Showing 1 changed file with 78 additions and 76 deletions.
154 changes: 78 additions & 76 deletions src/components/Tutorials/subComps/RemoveStepModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,88 @@ import Snackbar from "@mui/material/Snackbar";
import Typography from "@mui/material/Typography";

const RemoveStepModal = ({
owner,
tutorial_id,
step_id,
viewModal,
currentStep,
step_length,
owner,
tutorial_id,
step_id,
viewModal,
currentStep,
step_length
}) => {
const firebase = useFirebase();
const firestore = useFirestore();
const dispatch = useDispatch();
const [visible, setVisible] = useState(false);
const firebase = useFirebase();
const firestore = useFirestore();
const dispatch = useDispatch();
const [visible, setVisible] = useState(false);

useEffect(() => {
setVisible(viewModal);
}, [viewModal]);
useEffect(() => {
setVisible(viewModal);
}, [viewModal]);

const handleOnOk = () => {
<Snackbar
anchorOrigin={{
vertical: "bottom",
horizontal: "left",
}}
open={true}
autoHideDuration={6000}
message="Updating...."
/>;
if (step_length > 1) {
removeStep(
owner,
tutorial_id,
step_id,
currentStep
)(firebase, firestore, dispatch).then(() => {
setVisible(false);
<Snackbar
anchorOrigin={{
vertical: "bottom",
horizontal: "left",
}}
open={true}
autoHideDuration={6000}
message="removed...."
/>;
});
}
};
const handleOnCancel = () => setVisible(false);
const handleOnOk = event => {
<Snackbar
anchorOrigin={{
vertical: "bottom",
horizontal: "left"
}}
open={true}
autoHideDuration={6000}
message="Updating...."
/>;
if (step_length > 1) {
event.preventDefault();
removeStep(
owner,
tutorial_id,
step_id,
currentStep
)(firebase, firestore, dispatch).then(() => {
setVisible(false);
<Snackbar
anchorOrigin={{
vertical: "bottom",
horizontal: "left"
}}
open={true}
autoHideDuration={6000}
message="removed...."
/>;
});
}
};
const handleOnCancel = () => setVisible(false);

return (
<Modal
open={visible}
onClose={handleOnCancel}
aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description"
style={{
border: "2px solid #000",
background: "whitesmoke",
boxShadow: "2rem gray",
display: "flex",
alignItems: "center",
justifyContent: "center",
height: "10rem",
width: "20rem",
position: "absolute",
top: "40%",
left: "40%",
}}>
<div>
<Typography>This action is can not be undone!</Typography>
<form onSubmit={handleOnOk}>
<Button key="back" onClick={handleOnCancel}>
<Typography>Cancel</Typography>
</Button>
<Button key="submit" type="primary" htmlType="submit">
<Typography> Remove</Typography>
</Button>
</form>
</div>
</Modal>
);
return (
<Modal
open={visible}
onClose={handleOnCancel}
aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description"
style={{
border: "2px solid #000",
background: "whitesmoke",
boxShadow: "2rem gray",
display: "flex",
alignItems: "center",
justifyContent: "center",
height: "10rem",
width: "20rem",
position: "absolute",
top: "40%",
left: "40%"
}}
>
<div>
<Typography>This action is can not be undone!</Typography>
<form onSubmit={handleOnOk}>
<Button key="back" onClick={handleOnCancel}>
<Typography>Cancel</Typography>
</Button>
<Button key="remove" type="submit">
<Typography> Remove</Typography>
</Button>
</form>
</div>
</Modal>
);
};

export default RemoveStepModal;

0 comments on commit cd67173

Please sign in to comment.