Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React from 'react';
import RouteGuard from './ui/components/RouteGuard/RouteGuard';
import Person from '@material-ui/icons/Person';
import OpenPushRequests from './ui/views/OpenPushRequests/OpenPushRequests';
import PushRequests from './ui/views/PushRequests/PushRequests';
import PushDetails from './ui/views/PushDetails/PushDetails';
import User from './ui/views/User/UserProfile';
import UserList from './ui/views/UserList/UserList';
Expand Down Expand Up @@ -55,9 +55,7 @@ const dashboardRoutes: Route[] = [
path: '/push',
name: 'Dashboard',
icon: Dashboard,
component: (props) => (
<RouteGuard component={OpenPushRequests} fullRoutePath={`/dashboard/push`} />
),
component: (props) => <RouteGuard component={PushRequests} fullRoutePath={`/dashboard/push`} />,
layout: '/dashboard',
visible: true,
},
Expand Down
4 changes: 3 additions & 1 deletion src/ui/components/CustomTabs/CustomTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface CustomTabsProps {
tabs: TabItem[];
rtlActive?: boolean;
plainTabs?: boolean;
defaultTab?: number;
}

const CustomTabs: React.FC<CustomTabsProps> = ({
Expand All @@ -33,8 +34,9 @@ const CustomTabs: React.FC<CustomTabsProps> = ({
tabs,
title,
rtlActive = false,
defaultTab = 0,
}) => {
const [value, setValue] = useState(0);
const [value, setValue] = useState(defaultTab);
const classes = useStyles();

const handleChange = (event: React.ChangeEvent<unknown>, newValue: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import GridContainer from '../../components/Grid/GridContainer';
import PushesTable from './components/PushesTable';
import CustomTabs from '../../components/CustomTabs/CustomTabs';
import Danger from '../../components/Typography/Danger';
import { Visibility, CheckCircle, Cancel, Block } from '@material-ui/icons';
import { Visibility, CheckCircle, Cancel, Block, Error, List } from '@material-ui/icons';
import { TabItem } from '../../components/CustomTabs/CustomTabs';

const Dashboard: React.FC = () => {
Expand All @@ -15,6 +15,11 @@ const Dashboard: React.FC = () => {
};

const tabs: TabItem[] = [
{
tabName: 'All',
tabIcon: List,
tabContent: <PushesTable handleError={handlePushTableError} />,
},
{
tabName: 'Pending',
tabIcon: Visibility,
Expand Down Expand Up @@ -51,6 +56,11 @@ const Dashboard: React.FC = () => {
/>
),
},
{
tabName: 'Error',
tabIcon: Error,
tabContent: <PushesTable error={true} handleError={handlePushTableError} />,
},
];

return (
Expand All @@ -59,7 +69,7 @@ const Dashboard: React.FC = () => {
{!errorMessage && (
<GridContainer>
<GridItem xs={12} sm={12} md={12}>
<CustomTabs headerColor='primary' tabs={tabs} />
<CustomTabs headerColor='primary' tabs={tabs} defaultTab={1} />
</GridItem>
</GridContainer>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ const PushesTable: React.FC<PushesTableProps> = (props) => {
const openPush = (pushId: string) => navigate(`/dashboard/push/${pushId}`, { replace: true });

useEffect(() => {
const query = {
blocked: props.blocked ?? false,
canceled: props.canceled ?? false,
authorised: props.authorised ?? false,
rejected: props.rejected ?? false,
};
const query: any = {};

// Only include filters that are explicitly set (not undefined)
if (props.blocked !== undefined) query.blocked = props.blocked;
if (props.canceled !== undefined) query.canceled = props.canceled;
if (props.authorised !== undefined) query.authorised = props.authorised;
if (props.rejected !== undefined) query.rejected = props.rejected;
if (props.error !== undefined) query.error = props.error;

getPushes(setIsLoading, setPushes, setAuth, setIsError, props.handleError, query);
}, [props]);

Expand Down
Loading