Advertisement
Shell_Casing

requestDetailsPage

Jul 20th, 2020
1,473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useEffect, useState } from 'react';
  2. import { useParams } from 'react-router-dom';
  3. import { useDispatch, useSelector } from "react-redux";
  4. import classes from './request-details.module.css';
  5. import Paper from "@material-ui/core/Paper";
  6. import Table from "@material-ui/core/Table";
  7. import TableHead from "@material-ui/core/TableHead";
  8. import TableRow from "@material-ui/core/TableRow";
  9. import TableCell from "@material-ui/core/TableCell";
  10. import TableBody from "@material-ui/core/TableBody";
  11. import TableContainer from "@material-ui/core/TableContainer";
  12. import { fetchPendingRequestsAction } from "../../state/actions/request-actions";
  13. import Loading from "../../loading/loading";
  14.  
  15. export const RequestDetails = props => {
  16.  
  17.     // state data
  18.     const loading = useSelector(state => state.requests.loading);
  19.     const pendingRequests = useSelector(state => state.requests.pendingRequests);
  20.     const dispatch = useDispatch();
  21.  
  22.     useEffect(() => {
  23.         dispatch(fetchPendingRequestsAction());
  24.         console.log(pendingRequests);
  25.         // eslint-disable-next-line
  26.     }, []);
  27.  
  28.     const { id } = useParams();
  29.     const [request, setRequest] = useState([]);
  30.  
  31.     const requestDetails = (
  32.  
  33.         <TableContainer component={Paper} className={`shadow-md`}>
  34.             <Table>
  35.                 <TableHead className={`bg-gray-200`}>
  36.                     <TableRow>
  37.                         <TableCell><span className={`font-bold`}>worker</span></TableCell>
  38.                         <TableCell><span className={`font-bold`}>action</span></TableCell>
  39.                         <TableCell><span className={`font-bold`}>admin</span></TableCell>
  40.                         <TableCell><span className={`font-bold`}>requestor</span></TableCell>
  41.                         <TableCell><span className={`font-bold`}>name</span></TableCell>
  42.                         <TableCell><span className={`font-bold`}>task_id</span></TableCell>
  43.                         <TableCell><span className={`font-bold`}>path</span></TableCell>
  44.                         <TableCell><span className={`font-bold`}>table_name</span></TableCell>
  45.                     </TableRow>
  46.                 </TableHead>
  47.  
  48.                 {/*<TableBody>*/}
  49.                 {/*    <TableRow className={`hover:bg-gray-200`}>*/}
  50.                 {/*        <TableCell>{ request.worker }</TableCell>*/}
  51.                 {/*        <TableCell>{ request.action }</TableCell>*/}
  52.                 {/*        <TableCell>{ request.admin }</TableCell>*/}
  53.                 {/*        <TableCell>{ request.requestor }</TableCell>*/}
  54.                 {/*        <TableCell>{ request.name }</TableCell>*/}
  55.                 {/*        <TableCell>{ request.task_id }</TableCell>*/}
  56.                 {/*        <TableCell>{ request.path }</TableCell>*/}
  57.                 {/*        <TableCell>{ request.table_name }</TableCell>*/}
  58.                 {/*    </TableRow>*/}
  59.                 {/*</TableBody>*/}
  60.  
  61.             </Table>
  62.         </TableContainer>
  63.     );
  64.  
  65.  
  66.     if(loading) return (<Loading />);
  67.  
  68.     return (
  69.         <div className={`${classes.adminPageContainer} mt-4`}>
  70.             <h2 className={`my-2`}>Hi, Kwaku</h2>
  71.             <h6 className={`my-2`}>Below are the request parameters</h6>
  72.             <h3 className={`my-2`}>
  73.                 {/*{ request.admin }*/}
  74.             </h3>
  75.             <div className={`${classes.buttons} my-2`}>
  76.                 <button className={`mr-2 bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-full`}>
  77.                     APPROVE
  78.                 </button>
  79.                 <button className={`ml-2 bg-red-700 hover:bg-red-900 text-white font-bold py-2 px-8 rounded-full`}>
  80.                     DENY
  81.                 </button>
  82.             </div>
  83.         </div>
  84.     );
  85.  
  86. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement