| @@ -1,6 +1,7 @@ | |||||
| // material-ui | // material-ui | ||||
| import { | import { | ||||
| Grid, Button, Typography | |||||
| Grid, Button, Typography, | |||||
| Dialog, DialogTitle, DialogContent, DialogActions, | |||||
| } from '@mui/material'; | } from '@mui/material'; | ||||
| import MainCard from "../../components/MainCard"; | import MainCard from "../../components/MainCard"; | ||||
| import * as React from "react"; | import * as React from "react"; | ||||
| @@ -25,6 +26,8 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { | |||||
| const [currentUserData, setCurrentUserData] = useState(userData); | const [currentUserData, setCurrentUserData] = useState(userData); | ||||
| const navigate = useNavigate(); | const navigate = useNavigate(); | ||||
| const [onReady, setOnReady] = useState(false); | const [onReady, setOnReady] = useState(false); | ||||
| const [isFailPopUp, setIsFailPopUp] = useState(false); | |||||
| const [failText, setFailText] = useState(""); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| //if state data are ready and assign to different field | //if state data are ready and assign to different field | ||||
| @@ -94,6 +97,11 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { | |||||
| } | } | ||||
| }, | }, | ||||
| onSuccess: function (responseData) { | onSuccess: function (responseData) { | ||||
| if(responseData.msg){ | |||||
| setFailText(responseData.msg); | |||||
| setIsFailPopUp(true); | |||||
| return; | |||||
| } | |||||
| navigate('/org/' + responseData.id); | navigate('/org/' + responseData.id); | ||||
| notifyCreateSuccess() | notifyCreateSuccess() | ||||
| } | } | ||||
| @@ -242,6 +250,18 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { | |||||
| } | } | ||||
| </form> | </form> | ||||
| </div> | </div> | ||||
| <div> | |||||
| <Dialog open={isFailPopUp} onClose={() => setIsFailPopUp(false)} > | |||||
| <DialogTitle><Typography variant="h3">Action Fail</Typography></DialogTitle> | |||||
| <DialogContent style={{ display: 'flex', }}> | |||||
| <Typography variant="h4" style={{ padding: '16px' }}>{failText}</Typography> | |||||
| </DialogContent> | |||||
| <DialogActions> | |||||
| <Button onClick={() => setIsFailPopUp(false)}><Typography variant="h5">OK</Typography></Button> | |||||
| </DialogActions> | |||||
| </Dialog> | |||||
| </div> | |||||
| </MainCard> | </MainCard> | ||||
| ); | ); | ||||
| }; | }; | ||||