Dwayne Harris
4 years ago
38 changed files with 399 additions and 95 deletions
-
59src/actions/apps.ts
-
6src/actions/authentication.ts
-
40src/actions/groups.ts
-
18src/components/app.tsx
-
12src/components/composer.tsx
-
5src/components/create-group-step.tsx
-
4src/components/create-user-step.tsx
-
4src/components/group-invitations.tsx
-
3src/components/group-logs.tsx
-
4src/components/navigation-menu.tsx
-
3src/components/notification-container.tsx
-
22src/components/pages/about.tsx
-
67src/components/pages/admin-apps.tsx
-
71src/components/pages/admin-groups.tsx
-
43src/components/pages/admin.tsx
-
4src/components/pages/apps.tsx
-
4src/components/pages/create-app.tsx
-
4src/components/pages/developers.tsx
-
6src/components/pages/edit-app.tsx
-
3src/components/pages/group-admin.tsx
-
4src/components/pages/groups.tsx
-
4src/components/pages/home.tsx
-
6src/components/pages/login.tsx
-
4src/components/pages/register-group.tsx
-
6src/components/pages/register.tsx
-
5src/components/pages/self.tsx
-
6src/components/pages/view-app.tsx
-
6src/components/pages/view-group.tsx
-
4src/components/pages/view-post.tsx
-
8src/components/pages/view-user.tsx
-
3src/components/self-info.tsx
-
6src/components/timeline.tsx
-
11src/hooks/index.ts
-
7src/selectors/apps.ts
-
8src/selectors/groups.ts
-
6src/styles/app.css
-
8src/types/store.ts
-
10src/utils/index.ts
@ -0,0 +1,67 @@ |
|||
import React, { FC, useEffect } from 'react' |
|||
import { useSelector, useDispatch } from 'react-redux' |
|||
import { useHistory } from 'react-router-dom' |
|||
import { useAuthenticationCheck, useTheme } from 'src/hooks' |
|||
import { fetchPendingApps } from 'src/actions/apps' |
|||
import { getAuthenticatedUser, getChecked } from 'src/selectors/authentication' |
|||
import { getPendingApps } from 'src/selectors/apps' |
|||
import { handleApiError } from 'src/api/errors' |
|||
import { setTitle } from 'src/utils' |
|||
import { AppThunkDispatch } from 'src/types' |
|||
|
|||
import Section from 'src/components/section' |
|||
import Title from 'src/components/title' |
|||
import Loading from 'src/components/pages/loading' |
|||
import AppListItem from 'src/components/app-list-item' |
|||
import HorizontalRule from 'src/components/horizontal-rule' |
|||
import PrimaryButton from 'src/components/controls/primary-button' |
|||
import SecondaryButton from 'src/components/controls/secondary-button' |
|||
|
|||
const AdminApps: FC = () => { |
|||
useAuthenticationCheck() |
|||
const theme = useTheme() |
|||
const checked = useSelector(getChecked) |
|||
const user = useSelector(getAuthenticatedUser) |
|||
const apps = useSelector(getPendingApps) |
|||
const dispatch = useDispatch<AppThunkDispatch>() |
|||
const history = useHistory() |
|||
|
|||
useEffect(() => { |
|||
setTitle('Admin \\ Apps') |
|||
|
|||
const init = async () => { |
|||
try { |
|||
await dispatch(fetchPendingApps()) |
|||
} catch (err) { |
|||
handleApiError(err, dispatch, history) |
|||
} |
|||
} |
|||
|
|||
if (checked) init() |
|||
}, [checked]) |
|||
|
|||
if (!user) return <Loading /> |
|||
if (checked && !user.admin) history.push('/') |
|||
|
|||
return ( |
|||
<div> |
|||
<Section> |
|||
<Title>Pending Apps</Title> |
|||
<HorizontalRule /> |
|||
</Section> |
|||
|
|||
{apps.map(app => ( |
|||
<div className="list-item" style={{ borderColor: theme.backgroundSecondary }} key={app.id}> |
|||
<AppListItem app={app} /> |
|||
|
|||
<div className="buttons"> |
|||
<PrimaryButton text="Activate" /> |
|||
<SecondaryButton text="Set Preinstall" /> |
|||
</div> |
|||
</div> |
|||
))} |
|||
</div> |
|||
) |
|||
} |
|||
|
|||
export default AdminApps |
@ -0,0 +1,71 @@ |
|||
import React, { FC, useEffect } from 'react' |
|||
import { useSelector, useDispatch } from 'react-redux' |
|||
import { useHistory } from 'react-router-dom' |
|||
import { useAuthenticationCheck, useTheme } from 'src/hooks' |
|||
import { fetchPendingGroups, activateGroup } from 'src/actions/groups' |
|||
import { getAuthenticatedUser, getChecked } from 'src/selectors/authentication' |
|||
import { getPendingGroups } from 'src/selectors/groups' |
|||
import { handleApiError } from 'src/api/errors' |
|||
import { setTitle } from 'src/utils' |
|||
import { AppThunkDispatch } from 'src/types' |
|||
|
|||
import Section from 'src/components/section' |
|||
import Title from 'src/components/title' |
|||
import Loading from 'src/components/pages/loading' |
|||
import GroupListItem from 'src/components/group-list-item' |
|||
import HorizontalRule from 'src/components//horizontal-rule' |
|||
import PrimaryButton from 'src/components/controls/primary-button' |
|||
|
|||
const AdminGroups: FC = () => { |
|||
useAuthenticationCheck() |
|||
const theme = useTheme() |
|||
const checked = useSelector(getChecked) |
|||
const user = useSelector(getAuthenticatedUser) |
|||
const groups = useSelector(getPendingGroups) |
|||
const dispatch = useDispatch<AppThunkDispatch>() |
|||
const history = useHistory() |
|||
|
|||
const handleClick = async (id: string) => { |
|||
try { |
|||
await dispatch(activateGroup(id)) |
|||
await dispatch(fetchPendingGroups()) |
|||
} catch (err) { |
|||
handleApiError(err, dispatch, history) |
|||
} |
|||
} |
|||
|
|||
useEffect(() => { |
|||
setTitle('Admin \\ Groups') |
|||
|
|||
const init = async () => { |
|||
try { |
|||
await dispatch(fetchPendingGroups()) |
|||
} catch (err) { |
|||
handleApiError(err, dispatch, history) |
|||
} |
|||
} |
|||
|
|||
if (checked) init() |
|||
}, [checked]) |
|||
|
|||
if (!user) return <Loading /> |
|||
if (checked && !user.admin) history.push('/') |
|||
|
|||
return ( |
|||
<div> |
|||
<Section> |
|||
<Title>Pending Groups</Title> |
|||
<HorizontalRule /> |
|||
</Section> |
|||
|
|||
{groups.map(group => ( |
|||
<div className="list-item" style={{ borderColor: theme.backgroundSecondary }} key={group.id}> |
|||
<GroupListItem group={group} /> |
|||
<PrimaryButton text="Activate" onClick={() => handleClick(group.id)} /> |
|||
</div> |
|||
))} |
|||
</div> |
|||
) |
|||
} |
|||
|
|||
export default AdminGroups |
@ -0,0 +1,43 @@ |
|||
import React, { FC, useEffect } from 'react' |
|||
import { useSelector } from 'react-redux' |
|||
import { Link, useHistory } from 'react-router-dom' |
|||
import { useTheme, useAuthenticationCheck } from 'src/hooks' |
|||
import { getAuthenticatedUser, getChecked } from 'src/selectors/authentication' |
|||
import { setTitle } from 'src/utils' |
|||
|
|||
import Section from 'src/components/section' |
|||
import Title from 'src/components/title' |
|||
import HorizontalRule from 'src/components/horizontal-rule' |
|||
import Loading from 'src/components/pages/loading' |
|||
|
|||
const Admin: FC = () => { |
|||
useAuthenticationCheck() |
|||
const checked = useSelector(getChecked) |
|||
const theme = useTheme() |
|||
const user = useSelector(getAuthenticatedUser) |
|||
const history = useHistory() |
|||
|
|||
useEffect(() => { |
|||
setTitle('Admin') |
|||
}) |
|||
|
|||
if (!user) return <Loading /> |
|||
if (checked && !user.admin) history.push('/') |
|||
|
|||
return ( |
|||
<Section> |
|||
<Title>Admin</Title> |
|||
|
|||
<HorizontalRule /> |
|||
<br /><br /> |
|||
|
|||
<Link style={{ color: theme.secondary }} to="/admin/groups">Approve Pending Groups</Link> |
|||
<br /> |
|||
|
|||
<Link style={{ color: theme.secondary }} to="/admin/apps">Approve Pending Apps</Link> |
|||
<br /> |
|||
</Section> |
|||
) |
|||
} |
|||
|
|||
export default Admin |
Write
Preview
Loading…
Cancel
Save
Reference in new issue