Skip to content

Commit

Permalink
Include formatting and linting for tsx, jsx and js files
Browse files Browse the repository at this point in the history
  • Loading branch information
kwokieee committed Sep 6, 2023
1 parent 2f17c4d commit 919f16f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 65 deletions.
8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"lint:ci": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"format": "prettier --write \"{src,test}/**/*.ts\"",
"format:ci": "prettier --list-different \"{src,test}/**/*.ts\"",
"lint": "eslint --fix --ext .js,.jsx,.ts,.tsx ./src",
"lint:ci": "eslint --ext .js,.jsx,.ts,.tsx ./src",
"format": "prettier --write \"src/**/*.(js|jsx|json|ts|tsx)\"",
"format:ci": "prettier --list-different \"src/**/*.(js|jsx|json|ts|tsx)\"",
"prepare": "cd .. && husky install frontend/.husky",
"preview": "vite preview",
"test": "vitest run",
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Router from './routes'
import { RouterProvider } from 'react-router-dom'
import Router from './routes';
import { RouterProvider } from 'react-router-dom';

function App() {
return (
<RouterProvider router={Router} />
)
return <RouterProvider router={Router} />;
}

export default App
export default App;
8 changes: 4 additions & 4 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
);
86 changes: 47 additions & 39 deletions frontend/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,64 @@
import { Box, Button, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from "@mui/material";
import {
Box,
Button,
Paper,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Typography,
} from '@mui/material';

// TODO: Replace this with a real table
function createData(
id: number,
title: string,
description: string,
category: string,
complexity: string
complexity: string,
) {
return { id, title, description, category, complexity };
}

const rows = [
createData(1, "Reverse a String", "Description 1", "Strings, Algorithms", "Easy"),
createData(1, "Repeated DNA Sequences", "Description 2", "Data Structures, Algorithms", "Medium"),
createData(1, "Sliding Window Maximum", "Description 3", "Arrays, Algorithms", "Hard")
createData(1, 'Reverse a String', 'Description 1', 'Strings, Algorithms', 'Easy'),
createData(1, 'Repeated DNA Sequences', 'Description 2', 'Data Structures, Algorithms', 'Medium'),
createData(1, 'Sliding Window Maximum', 'Description 3', 'Arrays, Algorithms', 'Hard'),
];

export default function Dashboard() {
return (
<Box>
<Typography variant="h2">PeerPrep Dashboard</Typography>
<Button href={`/login`}>Log out</Button>
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>ID</TableCell>
<TableCell align="left">Title</TableCell>
<TableCell align="left">Category&nbsp;(g)</TableCell>
<TableCell align="left">Complexity&nbsp;(g)</TableCell>
{/* <TableCell align="right">Protein&nbsp;(g)</TableCell> */}
return (
<Box>
<Typography variant="h2">PeerPrep Dashboard</Typography>
<Button href={`/login`}>Log out</Button>
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>ID</TableCell>
<TableCell align="left">Title</TableCell>
<TableCell align="left">Category&nbsp;(g)</TableCell>
<TableCell align="left">Complexity&nbsp;(g)</TableCell>
{/* <TableCell align="right">Protein&nbsp;(g)</TableCell> */}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.id} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell component="th" scope="row">
{row.id}
</TableCell>
<TableCell align="left">{row.title}</TableCell>
<TableCell align="left">{row.category}</TableCell>
<TableCell align="left">{row.complexity}</TableCell>
{/* <TableCell align="right">{row.protein}</TableCell> */}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow
key={row.id}
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
>
<TableCell component="th" scope="row">
{row.id}
</TableCell>
<TableCell align="left">{row.title}</TableCell>
<TableCell align="left">{row.category}</TableCell>
<TableCell align="left">{row.complexity}</TableCell>
{/* <TableCell align="right">{row.protein}</TableCell> */}
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
</Box>
))}
</TableBody>
</Table>
</TableContainer>
</Box>
);
}
}
24 changes: 15 additions & 9 deletions frontend/src/pages/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import { Box, Button, TextField, Typography } from "@mui/material";
import { Box, Button, TextField, Typography } from '@mui/material';

export default function Login() {
return (
<>
<Box sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}>
<Typography variant="h1" gutterBottom>PeerPrep</Typography>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Typography variant="h1" gutterBottom>
PeerPrep
</Typography>
<TextField id="outlined-basic" label="Username" variant="outlined" />
<TextField id="outlined-basic" label="Password" variant="outlined" />
<Button href={`/dashboard`} variant="contained">Log in</Button>
<Button href={`/dashboard`} variant="contained">
Log in
</Button>
</Box>
</>
);
}
}
6 changes: 3 additions & 3 deletions frontend/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import Dashboard from '../pages/Dashboard';
export default createBrowserRouter([

Check warning on line 5 in frontend/src/routes/index.tsx

View workflow job for this annotation

GitHub Actions / Frontend Tests (lint:ci)

Fast refresh can't handle anonymous components. Add a name to your export
{
path: '/login',
element: <Login />
element: <Login />,
},
{
path: '/dashboard',
element: <Dashboard />
element: <Dashboard />,
},
{ path: '*', element: <Navigate to="/login" replace /> },
])
]);

0 comments on commit 919f16f

Please sign in to comment.