-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathAccessDeniedWithAuthModal.jsx
More file actions
77 lines (70 loc) · 2.03 KB
/
Copy pathAccessDeniedWithAuthModal.jsx
File metadata and controls
77 lines (70 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { useTranslation } from "react-i18next";
import Button from "../Button/Button";
import "../../assets/stylesheets/Modal.scss";
import {
closeAccessDeniedWithAuthModal,
syncProject,
} from "../../redux/EditorSlice";
import { defaultPythonProject } from "../../utils/defaultProjects";
import GeneralModal from "./GeneralModal";
const AccessDeniedWithAuthModal = (props) => {
const {
buttons = null,
text = null,
withCloseButton = true,
withClickToClose = true,
} = props;
const dispatch = useDispatch();
const { t } = useTranslation();
const user = useSelector((state) => state.auth.user);
const isModalOpen = useSelector(
(state) => state.editor.accessDeniedWithAuthModalShowing,
);
const closeModal = () => dispatch(closeAccessDeniedWithAuthModal());
const createNewProject = async () => {
dispatch(
syncProject("save")({
project: defaultPythonProject,
accessToken: user.access_token,
autosave: false,
}),
);
};
return (
<GeneralModal
isOpen={isModalOpen}
closeModal={withClickToClose ? closeModal : null}
withCloseButton={withCloseButton}
heading={t("project.accessDeniedWithAuthModal.heading")}
text={
text || [
{
type: "paragraph",
content: t("project.accessDeniedWithAuthModal.text"),
},
]
}
buttons={
buttons || [
<Button
key="new"
className="btn--primary"
buttonText={t("project.accessDeniedWithAuthModal.newProject")}
onClickHandler={createNewProject}
/>,
<a
key="link"
className="btn btn--secondary"
href="https://projects.raspberrypi.org"
>
{t("project.accessDeniedWithAuthModal.projectsSiteLinkText")}
</a>,
]
}
defaultCallback={createNewProject}
/>
);
};
export default AccessDeniedWithAuthModal;