diff options
-rw-r--r-- | src/components/Header/Header.tsx | 11 | ||||
-rw-r--r-- | src/components/Header/SearchBar.tsx | 4 | ||||
-rw-r--r-- | src/components/UserStrip/UserStrip.tsx | 3 | ||||
-rw-r--r-- | src/pages/Page.tsx | 13 | ||||
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 5 | ||||
-rw-r--r-- | src/pages/urls.ts | 8 |
6 files changed, 15 insertions, 29 deletions
diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index ef5f9fb..9c42c31 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -15,7 +15,6 @@ import HomeIcon from '@material-ui/icons/Home'; import { useAuth } from '../../hooks/useAuth'; import SearchBar from './SearchBar'; -import urls from '../../pages/urls'; const useStyles = makeStyles(theme => ({ @@ -51,20 +50,20 @@ const Header: React.FC = () => { const isMobile = useMediaQuery(theme.breakpoints.down('sm')); const handleHome = (): void => { - history.push(urls.home); + history.push('/'); }; const handleFeed = (): void => { - history.push(urls.feed) + history.push('/feed') }; const handleProfile = (): void => { - if (user) history.push(urls.profile(user.username)); - else history.push(urls.login); + if (user) history.push(`/profile/${user.username}`); + else history.push('/login'); }; const handleNotifications = (): void => { - history.push(urls.notifications); + history.push('/notifications'); }; const FeedButton = ( diff --git a/src/components/Header/SearchBar.tsx b/src/components/Header/SearchBar.tsx index f54cf25..f541589 100644 --- a/src/components/Header/SearchBar.tsx +++ b/src/components/Header/SearchBar.tsx @@ -14,8 +14,6 @@ import { User } from 'which-types'; import { get } from '../../requests'; import UserStrip from '../UserStrip/UserStrip'; -import urls from '../../pages/urls'; - const INTERVAL = 300; const LIMIT = 7; @@ -72,7 +70,7 @@ const SearchBar: React.FC = () => { const handleNavigate = (index: number) => () => { const { username } = results[index]; - history.push(urls.profile(username)); + history.push(`/profile/${username}`); handleClose(); }; diff --git a/src/components/UserStrip/UserStrip.tsx b/src/components/UserStrip/UserStrip.tsx index a2d2700..73d9363 100644 --- a/src/components/UserStrip/UserStrip.tsx +++ b/src/components/UserStrip/UserStrip.tsx @@ -5,7 +5,6 @@ import VerifiedIcon from '@material-ui/icons/CheckCircleOutline'; import { Avatar, CardHeader } from '@material-ui/core/'; import { User } from 'which-types'; -import urls from '../../pages/urls'; interface PropTypes { user: User; @@ -35,7 +34,7 @@ const UserStrip: React.FC<PropTypes> = ({ user, info }) => { const { username, avatarUrl, verified } = user; const handleNavigate = () => { - history.push(urls.profile(user.username)); + history.push(`/profile/${username}`); }; const avatar = ( diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index dd413bf..34a1046 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -11,7 +11,6 @@ import RegistrationPage from './RegistrationPage/RegistrationPage'; import HomePage from './HomePage/HomePage'; import NotificationsPage from './NotificationsPage/NotificationsPage'; import Route from './Route'; -import urls from './urls'; const useStyles = makeStyles(theme => ({ @@ -41,12 +40,12 @@ const Page: React.FC = () => { > <div className={classes.root}> <Switch> - <Route exact path={urls.home} component={HomePage} /> - <Route exact path={urls.login} component={LoginPage} /> - <Route exact path={urls.registration} component={RegistrationPage} /> - <Route exact path={urls.feed} component={FeedPage} /> - <Route exact path={urls.notifications} component={NotificationsPage} /> - <Route path={urls.profile(':username')} component={ProfilePage} /> + <Route exact path="/" component={HomePage} /> + <Route exact path="/login" component={LoginPage} /> + <Route exact path="/registration" component={RegistrationPage} /> + <Route exact path="/feed" component={FeedPage} /> + <Route exact path="/notifications" component={NotificationsPage} /> + <Route path="/profile/:username" component={ProfilePage} /> </Switch> </div> </SnackbarProvider> diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index ec917fd..b81c70f 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -7,7 +7,6 @@ import ProfileInfo from './ProfileInfo'; import Feed from '../../components/Feed/Feed'; import { get } from '../../requests'; import { useAuth } from '../../hooks/useAuth'; -import urls from '../urls'; const ProfilePage: React.FC = () => { @@ -24,8 +23,8 @@ const ProfilePage: React.FC = () => { setIsInfoLoading(true); const redirect = () => { - if (user) history.push(urls.profile(user.username)); - else history.push(urls.login); + if (user) history.push(`/profile/${user.username}`); + else history.push('/login'); }; if (username) { diff --git a/src/pages/urls.ts b/src/pages/urls.ts deleted file mode 100644 index e10edac..0000000 --- a/src/pages/urls.ts +++ /dev/null @@ -1,8 +0,0 @@ -export default { - home: '/', - login: '/login', - registration: '/registration', - profile: (username: string = '') => `/profile/${username.toLowerCase()}`, - feed: '/feed', - notifications: '/notifications' -}; |