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

FIX:Issue# 847 Remove step not working in tutorial creation #849

Merged
merged 3 commits into from
Aug 17, 2023
Merged
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
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;
Loading