Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-hak committed Jun 21, 2024
1 parent 0a7525d commit d00e0fc
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 165 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"prettier": "^3.2.5",
Expand Down
20 changes: 9 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import './App.css';
import Home from './pages/Home';
import { useEffect } from 'react';
// import { login } from './api/login';
import LoginAPi from './pages/Login';
import Main from './pages/Main';
import NoticeDetail from './pages/NoticeDetail';
Expand All @@ -12,15 +10,15 @@ import { AuthorizationProvider } from './providers/Authentication.tsx';
const App = () => {
return (
<BrowserRouter>
<AuthorizationProvider>
<Routes>
<Route path="/" element={<LoginAPi />} />
<Route path="/Main" element={<Main />} />
<Route path="/Home" element={<Home />} />
<Route path="/NoticeDetail" element={<NoticeDetail />} />
<Route path="/Update" element={<NoticeUpdate />} />
<Route path="/Write" element={<NoticeWrite />} />
</Routes>
<AuthorizationProvider>
<Routes>
<Route path="/" element={<LoginAPi />} />
<Route path="/Main" element={<Main />} />
<Route path="/Home" element={<Home />} />
<Route path="/NoticeDetail" element={<NoticeDetail />} />
<Route path="/Update" element={<NoticeUpdate />} />
<Route path="/Write" element={<NoticeWrite />} />
</Routes>
</AuthorizationProvider>
</BrowserRouter>
);
Expand Down
18 changes: 7 additions & 11 deletions src/api/apiAxios.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from 'axios';
import {getCookie } from '../utils/Cookies';
import { getCookie } from '../utils/Cookies';

const token = getCookie('Accesstoken');
/* eslint-disable @typescript-eslint/no-explicit-any */

const apiAxios = axios.create({
baseURL: import.meta.env.VITE_APP_SERVER_HOST,
Expand All @@ -13,25 +14,20 @@ const apiAxios = axios.create({
});

apiAxios.interceptors.request.use(config => {
const { headers } = config;
const { headers } = config;
if (token) {
headers.Authorization = `Bearer ${token}`;
}



// else {
// window.location.href = '/';
// }
}

(error: any) => Promise.reject(error);

return config;
});

apiAxios.interceptors.response.use(config => {
const { headers } = config;
const a = config;

return config;
return a;
});

export default apiAxios;
17 changes: 8 additions & 9 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ import './index.css';
// import { BrowserRouter } from 'react-router-dom'
import { CookiesProvider } from 'react-cookie';

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

let queryClient = new QueryClient(); //캐시와 훅을 쓸수있게 정의
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

const queryClient = new QueryClient(); //캐시와 훅을 쓸수있게 정의

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<CookiesProvider>
<App />
<ReactQueryDevtools />
</CookiesProvider>
<CookiesProvider>
<App />
<ReactQueryDevtools />
</CookiesProvider>
</QueryClientProvider>
</React.StrictMode>
</React.StrictMode>,
);
8 changes: 2 additions & 6 deletions src/pages/Dashbord/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Container from '@mui/material/Container';
import Grid from '@mui/material/Grid';
import Paper from '@mui/material/Paper';
import MenuIcon from '@mui/icons-material/Menu';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import NotificationsIcon from '@mui/icons-material/Notifications';
import { mainListItems, secondaryListItems } from './ListItem';
import Chart from './Chart';
Expand All @@ -32,7 +31,7 @@ interface AppBarProps extends MuiAppBarProps {

const AppBar = styled(MuiAppBar, {
shouldForwardProp: prop => prop !== 'open',
})<AppBarProps>(({ theme, open }) => ({
})<AppBarProps>(({ theme }) => ({
zIndex: theme.zIndex.drawer + 1,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
Expand Down Expand Up @@ -92,10 +91,7 @@ const Drawer = styled(MuiDrawer, {
const defaultTheme = createTheme();

export default function Dashboard() {
const [open, setOpen] = React.useState(true);
const toggleDrawer = () => {
setOpen(!open);
};
const [open] = React.useState(true);

return (
<ThemeProvider theme={defaultTheme}>
Expand Down
1 change: 0 additions & 1 deletion src/pages/Dashbord/Deposits.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import Link from '@mui/material/Link';
import Typography from '@mui/material/Typography';
import Title from './Title';
import { getCookie } from '../../utils/Cookies';
Expand Down
5 changes: 1 addition & 4 deletions src/pages/Dashbord/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import ListSubheader from '@mui/material/ListSubheader';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import PeopleIcon from '@mui/icons-material/People';
import BarChartIcon from '@mui/icons-material/BarChart';
import LayersIcon from '@mui/icons-material/Layers';
import AssignmentIcon from '@mui/icons-material/Assignment';

export const mainListItems = (
Expand All @@ -30,14 +28,13 @@ export const mainListItems = (
</ListItemIcon>
<ListItemText primary="이용현황" />
</ListItemButton>

</React.Fragment>
);

export const secondaryListItems = (
<React.Fragment>
<ListSubheader component="div" inset>
admin
admin
</ListSubheader>
<ListItemButton>
<ListItemIcon>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Dashbord/Notice.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { useQuery } from '@tanstack/react-query';
import { getAllNotice, getNoticeDetail } from '../../api/notice/get';
import { getAllNotice } from '../../api/notice/get';
import {
Box,
Typography,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Link,
Button,
} from '@mui/material';
import Title from './Title';
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

/* eslint-disable @typescript-eslint/no-explicit-any */
export default function Notice() {
const navigate = useNavigate();
const [Array, setArray] = useState();
const { data: noticeAllData, isLoading } = useQuery({
queryKey: ['noticeAllData'],
queryFn: () => getAllNotice(1),
});

/*eslint-disable react-hooks/exhaustive-deps */
useEffect(() => {
if (!isLoading) {
setArray(noticeAllData?.data);
Expand Down
23 changes: 11 additions & 12 deletions src/pages/Dashbord/Reports.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import Link from '@mui/material/Link';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
Expand All @@ -8,21 +7,21 @@ import TableRow from '@mui/material/TableRow';
import Title from './Title';
import { useQuery } from '@tanstack/react-query';
import { getAllReport } from '../../api/getAllReport';
import { getAllNotice, getNoticeDetail } from '../../api/notice/get';
import { useState, useEffect } from 'react';
import { getCookie } from '../../utils/Cookies';
// Generate Order Data
function createData(
id: number,
date: string,
name: string,
shipTo: string,
paymentMethod: string,
amount: number
) {
return { id, date, name, shipTo, paymentMethod, amount };
}

// function createData(
// id: number,
// date: string,
// name: string,
// shipTo: string,
// paymentMethod: string,
// amount: number
// ) {
// return { id, date, name, shipTo, paymentMethod, amount };
// }
/* eslint-disable @typescript-eslint/no-explicit-any */
export default function Reoports() {
const token = getCookie('Accesstoken');
const { data: reportData, isLoading } = useQuery({
Expand Down
5 changes: 2 additions & 3 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useEffect, useState } from 'react';
import { useState } from 'react';
// import { login } from '../api/login';
import { getAllReport } from '../api/getAllReport';

const Home = () => {
const [A, SetA] = useState();
const [A] = useState();

return (
<div>
Expand Down
6 changes: 0 additions & 6 deletions src/pages/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
Expand All @@ -8,18 +7,13 @@ import Container from '@mui/material/Container';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { LoginDataType } from '../api/login';
import LoginApi from '../api/login';
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { getCookie, setCookie } from '../utils/Cookies';
import { useMutation } from '@tanstack/react-query';

// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();

const Login = () => {
const { login } = LoginApi();
const navigate = useNavigate();
const [loading, setLoading] = useState(false);

const LoginMutation = useMutation({
mutationFn: (data: LoginDataType) => login(data) as Promise<void>,
Expand Down
6 changes: 3 additions & 3 deletions src/pages/NoticeDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import { useState } from 'react';
import { useLocation, useSearchParams } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { Box, Button, Container, Typography } from '@mui/material';
Expand All @@ -8,14 +8,14 @@ import { useQuery } from '@tanstack/react-query';
const NoticeDetail = () => {
const navigate = useNavigate();
const location = useLocation();
const [searchParams, setSearchParams] = useSearchParams();
const [searchParams] = useSearchParams();
// console.log(location);
// const location = useLocation();
// const { id } = window.location.
// const { props } = location.state;
console.log(location);
const id = Number(searchParams.get('noticeId'));
const [db, setData] = useState({ data: {} });
const [db] = useState({ data: {} });
const onDelete = () => {
if (window.confirm('강의평가를 삭제하시겠습니까?')) {
deleteNotice(id);
Expand Down
3 changes: 1 addition & 2 deletions src/pages/NoticeUpdate.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState, useEffect } from 'react';
import { useLocation } from 'react-router';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { Box, Container, Typography, TextField, Button } from '@mui/material';

Expand All @@ -9,7 +8,7 @@ import { getNoticeDetail } from '../api/notice/get';

const NoticeUpdate = () => {
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
const [searchParams] = useSearchParams();
const id = Number(searchParams.get('noticeId'));
const [title, setTitle] = useState<string>('');
const [content, setContent] = useState<string>('');
Expand Down
8 changes: 2 additions & 6 deletions src/pages/NoticeWrite.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React, { useState, useEffect } from 'react';
import { useLocation } from 'react-router';
import { useNavigate, useSearchParams } from 'react-router-dom';
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Box, Container, Typography, TextField, Button } from '@mui/material';

import { postNotice } from '../api/notice/post';
import { useQuery } from '@tanstack/react-query';
import { getNoticeDetail } from '../api/notice/get';

const NoticeWrite = () => {
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
// const id = Number(searchParams.get('noticeId'));
const [title, setTitle] = useState<string>();
const [content, setContent] = useState<string>();
Expand Down
6 changes: 3 additions & 3 deletions src/providers/Authentication.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCookie } from '../utils/Cookies';
import { useNavigate, useLocation } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { ReactNode, useEffect } from 'react';

interface AuthenticationProviderProps {
Expand All @@ -11,8 +11,8 @@ export const AuthorizationProvider = ({
}: AuthenticationProviderProps) => {
const navigate = useNavigate();
const token = getCookie('Accesstoken');


/* eslint-disable react-hooks/exhaustive-deps */
useEffect(() => {
if (!token) {
navigate('/');
Expand Down
21 changes: 8 additions & 13 deletions src/utils/Routers.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
// import { useNavigate } from 'react-router-dom';

function CustomRouter() {
const navigation = () => {
// const navigate = useNavigate();
// navigate('/home');
};

return navigation;
}

const navigation = () =>{
const navigate = useNavigate();
navigate('/home');
}


return navigation
}


export default CustomRouter;
export default CustomRouter;
Loading

0 comments on commit d00e0fc

Please sign in to comment.