mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
feat(alerts): useSnackbar for twitter
This commit is contained in:
1 parent
7d7c893800
commit
767402a6b2
2 files changed
-68
No files matched your search
@@ -12,7 +12,6 @@ import TweetButton from './buttons/TweetButton';
|
|||||||
import TwitterTitle from './TwitterTitle';
|
import TwitterTitle from './TwitterTitle';
|
||||||
import BottomNavigation from './BottomNavigation';
|
import BottomNavigation from './BottomNavigation';
|
||||||
import TwitterProfile from './profile/Profile';
|
import TwitterProfile from './profile/Profile';
|
||||||
import AlertBar from './alerts/AlertBar';
|
|
||||||
import TwitterSearch from './TwitterSearch';
|
import TwitterSearch from './TwitterSearch';
|
||||||
|
|
||||||
import './twitter.css';
|
import './twitter.css';
|
||||||
@@ -178,7 +177,6 @@ export const TwitterApp = () => {
|
|||||||
)}
|
)}
|
||||||
</AppContent>
|
</AppContent>
|
||||||
{showTweetButton && <TweetButton openModal={openModal} />}
|
{showTweetButton && <TweetButton openModal={openModal} />}
|
||||||
<AlertBar />
|
|
||||||
{!promptProfileName && (
|
{!promptProfileName && (
|
||||||
<BottomNavigation
|
<BottomNavigation
|
||||||
activePage={activePage}
|
activePage={activePage}
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { Snackbar } from '@material-ui/core';
|
|
||||||
import { makeStyles } from '@material-ui/core/styles';
|
|
||||||
|
|
||||||
import { useProfile } from '../../hooks/useProfile';
|
|
||||||
import { useTweetStatus } from '../../hooks/useTweetStatus';
|
|
||||||
import Alert from '../../../../ui/components/Alert';
|
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
root: {
|
|
||||||
width: '100%',
|
|
||||||
bottom: '60px',
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const ALERT_TIMEOUT = 4000;
|
|
||||||
|
|
||||||
export default function AlertBar() {
|
|
||||||
const classes = useStyles();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { updateProfileSuccessful, setUpdateProfileSuccessful } = useProfile();
|
|
||||||
const { createTweetSuccessful, setCreateTweetSuccessful } = useTweetStatus();
|
|
||||||
const [severity, setSeverity] = useState<string | null>(null);
|
|
||||||
const [open, setOpen] = useState(false);
|
|
||||||
const [message, setMessage] = useState(null);
|
|
||||||
|
|
||||||
const handleClose = () => {
|
|
||||||
setOpen(false);
|
|
||||||
setUpdateProfileSuccessful(null);
|
|
||||||
setCreateTweetSuccessful(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (createTweetSuccessful === true) {
|
|
||||||
setOpen(true);
|
|
||||||
setSeverity('success');
|
|
||||||
setMessage(t('APPS_TWITTER_CREATE_SUCCESS'));
|
|
||||||
} else if (createTweetSuccessful === false) {
|
|
||||||
setOpen(true);
|
|
||||||
setSeverity('error');
|
|
||||||
setMessage(t('APPS_TWITTER_CREATE_FAILED'));
|
|
||||||
} else if (updateProfileSuccessful === true) {
|
|
||||||
setOpen(true);
|
|
||||||
setSeverity('success');
|
|
||||||
setMessage(t('APPS_TWITTER_EDIT_PROFILE_SUCCESS'));
|
|
||||||
} else if (updateProfileSuccessful === false) {
|
|
||||||
setOpen(true);
|
|
||||||
setSeverity('error');
|
|
||||||
setMessage(t('APPS_TWITTER_EDIT_PROFILE_FAILURE'));
|
|
||||||
}
|
|
||||||
}, [updateProfileSuccessful, createTweetSuccessful, t]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Snackbar
|
|
||||||
autoHideDuration={ALERT_TIMEOUT}
|
|
||||||
className={classes.root}
|
|
||||||
open={open}
|
|
||||||
onClose={handleClose}
|
|
||||||
>
|
|
||||||
<Alert onClose={handleClose} severity={severity}>
|
|
||||||
{message}
|
|
||||||
</Alert>
|
|
||||||
</Snackbar>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user