switched to yarn:

This commit is contained in:
Maciek Głowacki 2020-11-22 18:22:07 +01:00
parent 9ae0ba509d
commit f75dcb668a
11 changed files with 11750 additions and 14217 deletions

15
.vscode/launch.json vendored
View File

@ -1,15 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}
]
}

14123
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,16 +17,27 @@
"@types/react": "^16.9.46",
"@types/react-dom": "^16.9.8",
"@types/styled-components": "^5.1.2",
"prettier": "^2.0.5",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint-config-prettier": "^6.15.0",
"eslint-config-react-app": "^6.0.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"prettier": "^2.2.0",
"typescript": "^3.9.7"
},
"optionalDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint src/*.{js,ts,tsx} --quiet --fix"
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [

View File

@ -1,24 +1,42 @@
<!DOCTYPE html>
<html lang="pl">
<head>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/logo.svg" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.svg" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<title>PlanNaPlan</title>
</head>
<body>
<noscript>Potrzebujesz włączyć JavaScript, żeby otworzyć tę aplikację</br>You need to enable JavaScript to run this
app.</noscript>
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View File

@ -1,13 +0,0 @@
{
"short_name": "PlanNaPlan",
"name": "PlanNaPlan",
"icons": [
{
"src": "logo.svg"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@ -1,6 +1,5 @@
import React, { useState, useContext } from 'react';
import React, { useState } from 'react';
import Topbar from './Topbar';
import {Admin} from './Admin';
import { Transfer } from './Transfer';
import { Scheduler } from './Scheduler';
import { Rightbar } from './Rightbar';
@ -9,9 +8,9 @@ import styled from 'styled-components';
const Wrapper = styled.div`
display: flex;
height: calc(100vh - 80px);
background-color: #ECEEF4;
padding-top:20px;
padding-bottom:20px;
background-color: #eceef4;
padding-top: 20px;
padding-bottom: 20px;
`;
export const App = () => {

View File

@ -1,4 +1,4 @@
import React, { useState, useContext, useEffect, MouseEvent } from 'react';
import React, { useState, useContext, useEffect, MouseEvent, useMemo } from 'react';
import { coursesContext } from '../contexts/CoursesProvider';
import { Course } from '../types';
import styled from 'styled-components';
@ -47,9 +47,8 @@ interface DropdownProps {
}
export const Dropdown = ({ open, input, handleCloseDropdown }: DropdownProps) => {
const { courses, basket, addCourseToBasket } = useContext(coursesContext)!;
const basketNames = basket.map(({ name }) => name.trim());
const { courses, selectBasketNames, addCourseToBasket } = useContext(coursesContext)!;
const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]);
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
const onCourseClick = (event: MouseEvent) => {
@ -79,7 +78,7 @@ export const Dropdown = ({ open, input, handleCloseDropdown }: DropdownProps) =>
setFilteredCourses(filteredCourses);
};
filterCourses(input);
}, [open, input, basket]);
}, [basketNames, courses, input]);
return (
<DropdownContainer>

View File

@ -1,4 +1,4 @@
import React, { useState, MouseEvent, ChangeEvent, useEffect, useRef } from 'react';
import React, { useState, MouseEvent, ChangeEvent, useEffect, useCallback } from 'react';
import { ReactComponent as Close } from '../assets/close.svg';
import ProfileIcon from '../assets/account.svg';
import { Profile } from './Profile';
@ -119,14 +119,11 @@ export default function ({ handleTransfer }: TopbarProps) {
const handleCloseProfile = () => setAnchorEl(null);
const handleClearInput = () => setClearInput(!clearInput);
const handleClearInput = useCallback(() => setClearInput((clearInput) => !clearInput), []);
const handleChange = (event: ChangeEvent<HTMLInputElement>) => setInput(event.target.value);
const handleShowDropdown = () => {
console.log('show dropdown');
setOpen(true);
};
const handleShowDropdown = () => setOpen(true);
const handleCloseDropdown = () => setOpen(false);
@ -135,14 +132,7 @@ export default function ({ handleTransfer }: TopbarProps) {
setInput('');
handleClearInput();
}
}, [clearInput]);
// useEffect(() => {
// console.log('input changed');
// if (!open) {
// setOpen(true);
// }
// }, [input]);
}, [clearInput, handleClearInput]);
return (
<Topbar>

View File

@ -18,27 +18,26 @@ export const CASProvider = ({ children }: CASProviderProps) => {
const [user, setUser] = useState<User | undefined>(undefined);
const [token, setToken] = useState<string | null>(null);
useEffect(() => {
const login = async () => {
const urlParams = new URLSearchParams(window.location.search);
const ticket = urlParams.get('ticket');
if (!ticket) {
redirectToCASLoginService();
}
try {
if (!sessionStorage.getItem('userToken')) {
const { data: token } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/token?ticket=${ticket}`);
sessionStorage.setItem('userToken', token);
}
const token = sessionStorage.getItem('userToken');
setToken(token);
} catch (e) {
console.log(e);
}
};
login();
}, []);
const login = async () => {
const urlParams = new URLSearchParams(window.location.search);
const ticket = urlParams.get('ticket');
if (!ticket) {
redirectToCASLoginService();
}
try {
if (!sessionStorage.getItem('userToken')) {
const { data: token } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/token?ticket=${ticket}`);
sessionStorage.setItem('userToken', token);
}
const token = sessionStorage.getItem('userToken');
setToken(token);
} catch (e) {
console.log(e);
}
};
function logout() {
redirectToCASLogoutService();
}

View File

@ -1,4 +1,4 @@
import React, { useState, createContext, useEffect, ReactNode, useContext } from 'react';
import React, { useState, createContext, useEffect, ReactNode } from 'react';
import { Course, Group, Basket, GroupType, SchedulerEvent } from '../types';
import { useSnackbar } from 'notistack';
import { createClassTime } from '../utils';
@ -120,7 +120,6 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
);
const basket = data === '' ? [] : data;
setBasket(basket);
console.log('newest timetable: ', basket);
} catch (e) {
console.log(e);
}
@ -132,7 +131,6 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
`${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`,
);
const sortedCourses = courses.sort((a, b) => (a.name > b.name ? 1 : -1));
console.log('courses: ', courses);
setCourses(sortedCourses);
} catch (e) {
console.log(e);

11670
yarn.lock Normal file

File diff suppressed because it is too large Load Diff