From f3e012fbe6b17eebad99778d5751b5c0d3025771 Mon Sep 17 00:00:00 2001 From: mniegrzybowska Date: Sun, 23 Jun 2024 17:02:26 +0200 Subject: [PATCH 1/2] organizing-imports --- .eslintrc.json | 21 ++------------- src/App.test.tsx | 6 ++--- src/Head.tsx | 3 +-- src/api/useAwards.ts | 5 ++-- src/api/useStudentById.ts | 18 ++++++------- src/api/useStudents.ts | 17 ++++++------ src/api/useTasks.ts | 15 ++++++----- src/api/useUser.ts | 12 ++++----- src/components/atoms/Buttons/Button.ts | 2 +- .../atoms/Buttons/CloseBarButton.tsx | 2 +- src/components/atoms/Lists/Lists.tsx | 3 +-- src/components/atoms/Sections/Article.ts | 1 - .../modules/ButtonBar/ButtonBar.tsx | 4 +-- .../modules/CustomSelect/CustomSelect.tsx | 16 +++++------- src/components/modules/From/Form.ts | 2 +- .../modules/StudentCard/StudentCard.tsx | 6 ++--- .../structures/Awards/AwardsBar.tsx | 3 +-- .../structures/Awards/AwardsList.tsx | 8 +++--- .../structures/Awards/EditPrizeForm.tsx | 3 +-- src/components/structures/Navbar/Navbar.tsx | 2 +- .../StudentHeader/StudentHeader.tsx | 9 +++---- .../structures/Tasks/EditPointsForm.tsx | 3 +-- .../structures/Tasks/PointsList.tsx | 3 +-- src/components/structures/Tasks/TasksBar.tsx | 3 +-- .../structures/Topbar/ProfileTopbar.tsx | 3 +-- src/components/templates/StudentTemplate.tsx | 3 +-- src/customRender.jsx | 2 +- src/providers/AuthProvider.tsx | 17 ++++++------ src/theme/appTheme.ts | 2 -- src/views/AwardsView.tsx | 26 +++++++++---------- src/views/ConsequencesView.tsx | 2 +- src/views/Login.tsx | 16 ++++++------ src/views/StudentView.tsx | 3 +-- src/views/TasksView.tsx | 3 +-- tsconfig.json | 8 ------ 35 files changed, 104 insertions(+), 148 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index dcd1db7..01223d6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,25 +17,17 @@ "plugin:import/typescript" //"airbnb-base" ], - "settings": { - "import/resolver": { - "alias": { - "map": [ - ["@", "./src"] - ] - } - } - }, + "rules": { // sort imports "import/order": "error", + "import/no-named-as-default": 0, // no let exports "import/no-mutable-exports": "error", "import/no-cycle": "error", - "import/no-default-export": "error", // allow {} even though it's unsafe but comes handy "@typescript-eslint/ban-types": [ @@ -47,15 +39,6 @@ } ], - "@typescript-eslint/consistent-type-imports": [ - "error", - { - "prefer": "type-imports", - "fixStyle": "inline-type-imports", - "disallowTypeAnnotations": false - } - ], - "import/no-duplicates": ["error", { "prefer-inline": true }], // false negatives diff --git a/src/App.test.tsx b/src/App.test.tsx index bf9479e..fbe95bc 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -1,8 +1,8 @@ -import { describe, it, expect, test, vi } from 'vitest'; // vi have a mock feature -import { render } from '@testing-library/react'; -import App from './App'; import React from 'react'; +import { describe, it, expect, test } from 'vitest'; // vi have a mock feature +import { render } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; +import App from './App'; test('demo', () => { expect(true).toBe(true); diff --git a/src/Head.tsx b/src/Head.tsx index d027b4e..1facb0f 100644 --- a/src/Head.tsx +++ b/src/Head.tsx @@ -1,7 +1,6 @@ -import React, { Fragment } from 'react'; +import React from 'react'; import { Helmet } from 'react-helmet'; import ZetonFaviconBlue from './images/icons/zeton-favicon-blue.png'; -import HelmetDispatcher from 'react-helmet-async/lib/Dispatcher'; const Head = (): JSX.Element => ( diff --git a/src/api/useAwards.ts b/src/api/useAwards.ts index c1a3df9..5ddc6fc 100644 --- a/src/api/useAwards.ts +++ b/src/api/useAwards.ts @@ -1,5 +1,5 @@ -import { ENDPOINT } from '../const/endpoints.const'; import useSWR from 'swr'; +import { ENDPOINT } from '../const/endpoints.const'; type AwardObject = { id: number; @@ -22,7 +22,8 @@ const fetcher = (...args: any[]) => fetch(...(args as [any])).then((res) => res.json()); const useAwards = (id: any): UseAwardsObjectDataResponse => { - const URL = process.env.VITE_REACT_APP_API_URL + ENDPOINT.prizesId.replace("{:id}", id) + const URL = + process.env.VITE_REACT_APP_API_URL + ENDPOINT.prizesId.replace('{:id}', id); const { data, error } = useSWR(URL, fetcher); return { diff --git a/src/api/useStudentById.ts b/src/api/useStudentById.ts index a22a78b..0fe65b6 100644 --- a/src/api/useStudentById.ts +++ b/src/api/useStudentById.ts @@ -1,7 +1,7 @@ -import useSWR from "swr"; -import { ENDPOINT } from "../const/endpoints.const"; -import type {AxiosResponse} from "axios"; -import axiosInstance from "./axios.ts"; +import useSWR from 'swr'; +import type { AxiosResponse } from 'axios'; +import { ENDPOINT } from '../const/endpoints.const'; +import axiosInstance from './axios.ts'; type StudentByIdObject = { pk: number; @@ -20,15 +20,13 @@ type GetStudentsByFetcher = { }; // adding SWR -const fetcher = async ( - url: string, -): Promise> => +const fetcher = async (url: string): Promise> => axiosInstance().get(url); - + const useStudentById = (id: any): UseStudentByIdObjectDataResponse => { const { data, error } = useSWR( - ENDPOINT.studentId.replace("{:id}", id), - fetcher, + ENDPOINT.studentId.replace('{:id}', id), + fetcher ); return { diff --git a/src/api/useStudents.ts b/src/api/useStudents.ts index dd82dd5..062a7f9 100644 --- a/src/api/useStudents.ts +++ b/src/api/useStudents.ts @@ -1,7 +1,7 @@ -import { ENDPOINT } from "../const/endpoints.const"; -import useSWR from "swr"; -import type {AxiosResponse} from "axios"; -import axiosInstance from "./axios.ts"; +import useSWR from 'swr'; +import type { AxiosResponse } from 'axios'; +import { ENDPOINT } from '../const/endpoints.const'; +import axiosInstance from './axios.ts'; type StudentObject = { pk: number; @@ -21,12 +21,13 @@ type GetStudentsByFetcher = { // adding SWR // const fetcher = (...args: any) => fetch(...args as [any]).then((res) => res.json()); -const fetcher = async ( - url: string, -): Promise> => +const fetcher = async (url: string): Promise> => axiosInstance().get(url); const useStudents = (): UseStudentObjectDataResponse => { - const { data, error } = useSWR(ENDPOINT.studentsList, fetcher); + const { data, error } = useSWR( + ENDPOINT.studentsList, + fetcher + ); return { students: data?.data, diff --git a/src/api/useTasks.ts b/src/api/useTasks.ts index bdbda94..7440942 100644 --- a/src/api/useTasks.ts +++ b/src/api/useTasks.ts @@ -1,7 +1,7 @@ -import { ENDPOINT } from '../const/endpoints.const'; import useSWR from 'swr'; -import axiosInstance from './axios'; import { AxiosResponse } from 'axios'; +import { ENDPOINT } from '../const/endpoints.const'; +import axiosInstance from './axios'; type TaskObject = { id: number; @@ -20,14 +20,15 @@ type GetTasksByFetcher = { data: TaskObject[]; }; -const fetcher = async ( - url: string, -): Promise> => +const fetcher = async (url: string): Promise> => axiosInstance().get(url); const useTasks = (id: any): UseTasksObjectDataResponse => { - const { data, error } = useSWR(ENDPOINT.tasksList.replace('{:id}', id), fetcher); - + const { data, error } = useSWR( + ENDPOINT.tasksList.replace('{:id}', id), + fetcher + ); + return { tasks: data?.data, isTasksLoading: !error && (!data || !data.data), diff --git a/src/api/useUser.ts b/src/api/useUser.ts index d3953dd..bd31a88 100644 --- a/src/api/useUser.ts +++ b/src/api/useUser.ts @@ -1,7 +1,7 @@ -import useSWR, { type SWRResponse } from "swr"; -import { ENDPOINT } from "../const/endpoints.const"; -import type {AxiosResponse} from "axios"; -import axiosInstance from "./axios.ts"; +import useSWR, { type SWRResponse } from 'swr'; +import type { AxiosResponse } from 'axios'; +import { ENDPOINT } from '../const/endpoints.const'; +import axiosInstance from './axios.ts'; type UserObject = { id: number; @@ -21,9 +21,7 @@ type GetUserByFetcher = { // adding SWR // const fetcher = (...args: [string]) => // fetch(...(args as unknown as [string])).then((res) => res.json()); -const fetcher = async ( - url: string, -): Promise> => +const fetcher = async (url: string): Promise> => axiosInstance().get(url); const useUser = (): UseUserObjectDataResponse => { const { data, error }: SWRResponse = useSWR( diff --git a/src/components/atoms/Buttons/Button.ts b/src/components/atoms/Buttons/Button.ts index ba8d7b9..c09c4a6 100644 --- a/src/components/atoms/Buttons/Button.ts +++ b/src/components/atoms/Buttons/Button.ts @@ -1,4 +1,4 @@ -import styled, { IStyledComponent } from 'styled-components'; +import styled from 'styled-components'; import type { ThemeTypes } from '../../../theme/appTheme'; interface ButtonInterface { diff --git a/src/components/atoms/Buttons/CloseBarButton.tsx b/src/components/atoms/Buttons/CloseBarButton.tsx index b7f73c6..1ced8d1 100644 --- a/src/components/atoms/Buttons/CloseBarButton.tsx +++ b/src/components/atoms/Buttons/CloseBarButton.tsx @@ -1,7 +1,7 @@ +import React from 'react'; import styled from 'styled-components'; import ARROW_ICON_SVG from '/arrow_back-24px.svg'; import EXIT_ICON_SVG from '/exit.svg'; -import React from 'react'; import type { ThemeTypes } from '../../../theme/appTheme'; interface StyledCloseBarButtonInterface { diff --git a/src/components/atoms/Lists/Lists.tsx b/src/components/atoms/Lists/Lists.tsx index 489ce22..ebeb1fb 100644 --- a/src/components/atoms/Lists/Lists.tsx +++ b/src/components/atoms/Lists/Lists.tsx @@ -1,8 +1,7 @@ +import React, { ReactNode } from 'react'; import styled from 'styled-components'; import { DeleteButton, EditButton } from '../Buttons/LightButtons'; -import type { ReactNode } from 'react'; import type { ThemeTypes } from '../../../theme/appTheme'; -import React from 'react'; interface ListsStyledInterface { theme?: ThemeTypes; } diff --git a/src/components/atoms/Sections/Article.ts b/src/components/atoms/Sections/Article.ts index 681c64a..263983c 100644 --- a/src/components/atoms/Sections/Article.ts +++ b/src/components/atoms/Sections/Article.ts @@ -1,5 +1,4 @@ import styled from 'styled-components'; -import { StyleSheet } from 'styled-components/dist/types'; interface StyledArticleInterface {} diff --git a/src/components/modules/ButtonBar/ButtonBar.tsx b/src/components/modules/ButtonBar/ButtonBar.tsx index 6ef31d2..b21f085 100644 --- a/src/components/modules/ButtonBar/ButtonBar.tsx +++ b/src/components/modules/ButtonBar/ButtonBar.tsx @@ -1,7 +1,7 @@ import React from 'react'; import styled from 'styled-components'; -import Button from '@/components/atoms/Buttons/Button'; -import CustomArrow from '@/components/atoms/Buttons/CustomArrow'; +import Button from '../../atoms/Buttons/Button.ts'; +import CustomArrow from '../../atoms/Buttons/CustomArrow.ts'; const StyledBlueArrow = styled(CustomArrow)` &::before { diff --git a/src/components/modules/CustomSelect/CustomSelect.tsx b/src/components/modules/CustomSelect/CustomSelect.tsx index cc0d129..ddc4e8d 100644 --- a/src/components/modules/CustomSelect/CustomSelect.tsx +++ b/src/components/modules/CustomSelect/CustomSelect.tsx @@ -1,13 +1,11 @@ -import { SetStateAction, useState } from 'react'; +import React, { SetStateAction, useState } from 'react'; import styled from 'styled-components'; -import Button from '@/components/atoms/Buttons/Button'; -import SelectHeader from '@/components/atoms/Heading/SelectHeader'; -import CustomArrow from '@/components/atoms/Buttons/CustomArrow'; -import MainBox from '@/components/atoms/Sections/MainBox'; -import { Subheading } from '@/components/atoms/Heading/Heading'; -//import {dataa, dataa as datamock} from '@/../mockyClient'; -import React from 'react'; -import { ThemeTypes } from '@/theme/appTheme'; +import Button from '../../atoms/Buttons/Button.ts'; +import SelectHeader from '../../atoms/Heading/SelectHeader.tsx'; +import CustomArrow from '../../atoms/Buttons/CustomArrow.ts'; +import { ThemeTypes } from '../../../theme/appTheme.ts'; +import { Subheading } from '../../atoms/Heading/Heading.ts'; +import MainBox from '../../atoms/Sections/MainBox.ts'; interface ListItemInterface { theme: ThemeTypes; diff --git a/src/components/modules/From/Form.ts b/src/components/modules/From/Form.ts index fb67c5d..47d26df 100644 --- a/src/components/modules/From/Form.ts +++ b/src/components/modules/From/Form.ts @@ -1,5 +1,5 @@ import styled from 'styled-components'; -import type { ThemeTypes } from '@/theme/appTheme'; +import { ThemeTypes } from '../../../theme/appTheme.ts'; interface StyledInputInterface { theme: ThemeTypes; diff --git a/src/components/modules/StudentCard/StudentCard.tsx b/src/components/modules/StudentCard/StudentCard.tsx index be9914b..3bbf5ad 100644 --- a/src/components/modules/StudentCard/StudentCard.tsx +++ b/src/components/modules/StudentCard/StudentCard.tsx @@ -1,9 +1,9 @@ import { Link } from 'react-router-dom'; +import React from 'react'; +import styled from 'styled-components'; import Paragraph from '../../atoms/Paragraph/Paragraph'; import ProfileImage from '../../atoms/ProfileImage/ProfileImage'; import ProfileDefaultImage_SVG from '/profile-user.svg'; -import styled from 'styled-components'; -import React from 'react'; import { ThemeTypes } from '../../../theme/appTheme'; interface StyledStudentCardInterface { @@ -39,7 +39,7 @@ type PropTypesStudentCard = { const StudentCard = ({ name, studentId, image }: PropTypesStudentCard) => { return ( - + {name} ); diff --git a/src/components/structures/Awards/AwardsBar.tsx b/src/components/structures/Awards/AwardsBar.tsx index f19d0ab..2623e54 100644 --- a/src/components/structures/Awards/AwardsBar.tsx +++ b/src/components/structures/Awards/AwardsBar.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import ReturnButton from '../../atoms/Buttons/ReturnButton'; import { Subheading, @@ -9,7 +9,6 @@ import ActionsTemplate from '../../templates/ActionsTemplate'; import { StyledContainer } from '../../atoms/Sections/Containers'; import CustomSelect from '../../modules/CustomSelect/CustomSelect'; import { dataa as datamock } from '../../../mockyClient'; -import React from 'react'; type AwardsBarPropTypes = { points: any; diff --git a/src/components/structures/Awards/AwardsList.tsx b/src/components/structures/Awards/AwardsList.tsx index 8cba48a..95a49ce 100644 --- a/src/components/structures/Awards/AwardsList.tsx +++ b/src/components/structures/Awards/AwardsList.tsx @@ -1,12 +1,14 @@ import React, { useEffect, useState } from 'react'; import { Heading, Subheading } from '../../atoms/Heading/Heading'; import MainBox from '../../atoms/Sections/MainBox'; -import LiElement from '../../atoms/Lists/Lists'; -import { LiDateElem } from '../../atoms/Lists/Lists'; import { StyledArticle } from '../../atoms/Sections/Article'; +import LiElement, { + StyledUl, + StyledDate, + LiDateElem, +} from '../../atoms/Lists/Lists'; import AddPrizeForm from './AddPrizeForm'; import EditPrizeForm from './EditPrizeForm'; -import { StyledUl, StyledDate } from '../../atoms/Lists/Lists'; const AwardsList = ({ awards, studentId }: any) => { const [prizes, setPrizes] = useState(awards); diff --git a/src/components/structures/Awards/EditPrizeForm.tsx b/src/components/structures/Awards/EditPrizeForm.tsx index 1dc4224..f7b3f57 100644 --- a/src/components/structures/Awards/EditPrizeForm.tsx +++ b/src/components/structures/Awards/EditPrizeForm.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import { AddButton, DeleteButtonText } from '../../atoms/Buttons/LightButtons'; import { StyledForm, @@ -6,7 +6,6 @@ import { StyledLabel, StyledRow, } from '../../atoms/Form/Form'; -import React from 'react'; type PrizeTypes = { value: string | number | readonly string[] | undefined; diff --git a/src/components/structures/Navbar/Navbar.tsx b/src/components/structures/Navbar/Navbar.tsx index 6377d4f..9193fb7 100644 --- a/src/components/structures/Navbar/Navbar.tsx +++ b/src/components/structures/Navbar/Navbar.tsx @@ -3,7 +3,6 @@ //import Home24PxSVG from "../../../images/icons/home-24px.svg"; import styled from 'styled-components'; import { useParams } from 'react-router-dom'; -import NavButton from '../../modules/NavButton/NavButton'; // import Home24PxSVG from "/home-24px.svg"; // import TrophySVG from "/trophy.svg"; // import SentimentVeryDissatisfied24PxSVG from "/sentiment_very_dissatisfied-24px.svg"; @@ -11,6 +10,7 @@ import NavButton from '../../modules/NavButton/NavButton'; // import Settings24PxSVG from "/settings-24px.svg"; import React from 'react'; import { JSX } from 'react/jsx-runtime'; +import NavButton from '../../modules/NavButton/NavButton'; import { ThemeTypes } from '../../../theme/appTheme'; import SvgHome from '../../../images/icons/dist_/Home24Px'; import SvgTrophy from '../../../images/icons/dist_/Trophy'; diff --git a/src/components/structures/StudentHeader/StudentHeader.tsx b/src/components/structures/StudentHeader/StudentHeader.tsx index efa1038..b4994b7 100644 --- a/src/components/structures/StudentHeader/StudentHeader.tsx +++ b/src/components/structures/StudentHeader/StudentHeader.tsx @@ -1,13 +1,10 @@ -//import {PropTypes} from "react/prop-types"' -//import DEFAULT_IMAGE from "../../../images/icons/dist_/ProfileUser"; -//import STAR_ICON from "../../../images/icons/dist_/Star"; -import styled, { IStyledComponent } from 'styled-components'; +import styled from 'styled-components'; +import { NavLink } from 'react-router-dom'; +import React from 'react'; import Paragraph from '../../atoms/Paragraph/Paragraph'; import ProfileImage from '../../atoms/ProfileImage/ProfileImage'; import STAR_ICON_SVG from '/star.svg'; import ReturnButton from '../../atoms/Buttons/ReturnButton'; -import { NavLink } from 'react-router-dom'; -import React from 'react'; import ProfileImageSVG from '/profile-user.svg'; import { ThemeTypes } from '../../../theme/appTheme'; diff --git a/src/components/structures/Tasks/EditPointsForm.tsx b/src/components/structures/Tasks/EditPointsForm.tsx index 011791d..ed8e9b2 100644 --- a/src/components/structures/Tasks/EditPointsForm.tsx +++ b/src/components/structures/Tasks/EditPointsForm.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import { AddButton, DeleteButtonText } from '../../atoms/Buttons/LightButtons'; import { StyledInput, @@ -6,7 +6,6 @@ import { StyledLabel, StyledRow, } from '../../atoms/Form/Form'; -import React from 'react'; type PropsType = { setEditing: (e: boolean) => void; diff --git a/src/components/structures/Tasks/PointsList.tsx b/src/components/structures/Tasks/PointsList.tsx index af49a9e..dc8c155 100644 --- a/src/components/structures/Tasks/PointsList.tsx +++ b/src/components/structures/Tasks/PointsList.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import { Heading, Subheading } from '../../atoms/Heading/Heading'; import { StyledArticle } from '../../atoms/Sections/Article'; import MainBox from '../../atoms/Sections/MainBox'; @@ -6,7 +6,6 @@ import MainBox from '../../atoms/Sections/MainBox'; import LiElement, { StyledUl } from '../../atoms/Lists/Lists'; import AddPointsForm from './AddPointsForm'; import EditPointsForm from './EditPointsForm'; -import React from 'react'; const PointsList = ({ tasksList, studentId }: any) => { const [tasks, setTasks] = useState(tasksList); diff --git a/src/components/structures/Tasks/TasksBar.tsx b/src/components/structures/Tasks/TasksBar.tsx index 690aa0d..46ab92e 100644 --- a/src/components/structures/Tasks/TasksBar.tsx +++ b/src/components/structures/Tasks/TasksBar.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import { useParams } from 'react-router-dom'; import CloseBarButton from '../../atoms/Buttons/CloseBarButton'; import { @@ -12,7 +12,6 @@ import CustomSelect from '../../modules/CustomSelect/CustomSelect'; import ProfileTopbar from '../Topbar/ProfileTopbar'; import { StyledContainer } from '../../atoms/Sections/Containers'; import { useTasks } from '../../../api/useTasks'; -import React from 'react'; const TasksBar = ({ handlePanel, panel, studentData }: any) => { let { id } = useParams(); diff --git a/src/components/structures/Topbar/ProfileTopbar.tsx b/src/components/structures/Topbar/ProfileTopbar.tsx index 1bd0d9d..5e7cfa7 100644 --- a/src/components/structures/Topbar/ProfileTopbar.tsx +++ b/src/components/structures/Topbar/ProfileTopbar.tsx @@ -1,8 +1,8 @@ +import React from 'react'; import styled from 'styled-components'; import DEFAULT_IMAGE_SVG from '/profile-user.svg'; import ProfileImage from '../../atoms/ProfileImage/ProfileImage'; import STAR_ICON_SVG from '/star.svg'; -import React from 'react'; const StyledProfileTopbar = styled.header` position: fixed; @@ -61,7 +61,6 @@ const ProfileTopbar = ({ }: { studentData: StudentDataTypes; }): JSX.Element => { - let { image, name, points }: StudentDataTypes = studentData; // diff --git a/src/components/templates/StudentTemplate.tsx b/src/components/templates/StudentTemplate.tsx index 97f8eea..782e366 100644 --- a/src/components/templates/StudentTemplate.tsx +++ b/src/components/templates/StudentTemplate.tsx @@ -1,11 +1,10 @@ -import { useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; import styled from 'styled-components'; import Button from '../atoms/Buttons/Button'; import StudentHeader from '../structures/StudentHeader/StudentHeader'; import { ROUTE_NAME } from '../../const/routing.const'; import TasksBar from '../structures/Tasks/TasksBar'; -import React from 'react'; const StyledButtonsGroup = styled.div` display: flex; diff --git a/src/customRender.jsx b/src/customRender.jsx index 56a6741..f6509d4 100644 --- a/src/customRender.jsx +++ b/src/customRender.jsx @@ -1,9 +1,9 @@ +import React from 'react'; import { render } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; import store from './api/store'; import { HelmetProvider } from 'react-helmet-async'; -import React from 'react'; const Wrapper = (children) => { return ( diff --git a/src/providers/AuthProvider.tsx b/src/providers/AuthProvider.tsx index b9bcbb4..e3afdeb 100644 --- a/src/providers/AuthProvider.tsx +++ b/src/providers/AuthProvider.tsx @@ -1,11 +1,11 @@ import React, { createContext, useContext, useEffect, useReducer } from 'react'; import axios from 'axios'; +import { useNavigate } from 'react-router-dom'; import { type TokenAction, type Authentication } from './types.ts'; import { authenticationReducer, type AuthenticationReducer, } from './authenticationReducer.ts'; -import {useNavigate} from "react-router-dom"; export const AuthenticationContext = createContext({ token: null, @@ -30,15 +30,14 @@ const AuthProvider = ({ children }: { children: React.ReactNode }) => { useEffect(() => { if (authentication.token) { - axios.defaults.headers.common["Authorization"] = - "Bearer " + authentication.token; + axios.defaults.headers.common['Authorization'] = + 'Bearer ' + authentication.token; localStorage.setItem(localStorageKey, authentication.token); - } else if(localStorage.getItem(localStorageKey)) { - axios.defaults.headers.common["Authorization"] = - "Bearer " + localStorage.getItem(localStorageKey); - } - else { - navigate("/login"); + } else if (localStorage.getItem(localStorageKey)) { + axios.defaults.headers.common['Authorization'] = + 'Bearer ' + localStorage.getItem(localStorageKey); + } else { + navigate('/login'); } }, [authentication, localStorageKey]); diff --git a/src/theme/appTheme.ts b/src/theme/appTheme.ts index 8bec6db..8dae9c5 100644 --- a/src/theme/appTheme.ts +++ b/src/theme/appTheme.ts @@ -1,5 +1,3 @@ -//import type CSS from 'styled-components'; - export type ThemeTypes = { background?: string; grey: string; diff --git a/src/views/AwardsView.tsx b/src/views/AwardsView.tsx index ff0b4de..bc359bd 100644 --- a/src/views/AwardsView.tsx +++ b/src/views/AwardsView.tsx @@ -1,20 +1,20 @@ +import React from 'react'; import { useParams } from 'react-router-dom'; -import HomeTemplate from '@/components/templates/HomeTemplate'; -import MainBox from '@/components/atoms/Sections/MainBox'; -import Navbar from '@/components/structures/Navbar/Navbar'; -import CustomSelect from '@/components/modules/CustomSelect/CustomSelect'; -import Loading from '@/components/atoms/Loading/Loading'; -import StudentHeader from '@/components/structures/StudentHeader/StudentHeader'; -import { StyledContainer } from '@/components/atoms/Sections/Containers'; +import HomeTemplate, { + StyledContainer, +} from '../components/templates/HomeTemplate.tsx'; +import StudentHeader from '../components/structures/StudentHeader/StudentHeader.tsx'; +import Loading from '../components/atoms/Loading/Loading.tsx'; +import MainBox from '../components/atoms/Sections/MainBox.ts'; +import Navbar from '../components/structures/Navbar/Navbar.tsx'; +import CustomSelect from '../components/modules/CustomSelect/CustomSelect.tsx'; +import { useStudentById } from '../api/useStudentById.ts'; +import { useAwards } from '../api/useAwards.ts'; import { - Subheading, StyledHeader, StyledHeading, -} from '@/components/atoms/Heading/Heading'; -// funkcje-hooki swr -import { useAwards } from '@/api/useAwards'; -import { useStudentById } from '@/api/useStudentById'; -import React from 'react'; + Subheading, +} from '../components/atoms/Heading/Heading.ts'; const AwardsView = () => { const { id } = useParams(); diff --git a/src/views/ConsequencesView.tsx b/src/views/ConsequencesView.tsx index 47f0838..4643c16 100644 --- a/src/views/ConsequencesView.tsx +++ b/src/views/ConsequencesView.tsx @@ -1,10 +1,10 @@ import { useParams } from 'react-router-dom'; +import React from 'react'; import HomeTemplate from '../components/templates/HomeTemplate'; import Navbar from '../components/structures/Navbar/Navbar'; import StudentHeader from '../components/structures/StudentHeader/StudentHeader'; import Loading from '../components/atoms/Loading/Loading'; import { useStudentById } from '../api/useStudentById'; -import React from 'react'; const ConsequencesView = () => { let { id } = useParams(); diff --git a/src/views/Login.tsx b/src/views/Login.tsx index 4f9c1cc..cb83c90 100644 --- a/src/views/Login.tsx +++ b/src/views/Login.tsx @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import { Heading } from '../components/atoms/Heading/Heading.ts'; import MainBox from '../components/atoms/Sections/MainBox.ts'; import { StyledArticle } from '../components/atoms/Sections/Article.ts'; @@ -6,13 +7,12 @@ import { StyledForm, StyledInput, StyledLabel, -} from "../components/atoms/Form/Form.ts"; -import { type User } from "../api/Authentication/userTypes.ts"; -import Button from "../components/atoms/Buttons/Button.ts"; -import useAuthenticateUser from "../api/Authentication/authenticateUser.ts"; -import { useTokenDispatch } from "../providers/AuthProvider.tsx"; -import { setToken } from "../providers/authenticationActions.ts"; -import { useNavigate } from "react-router-dom"; +} from '../components/atoms/Form/Form.ts'; +import { type User } from '../api/Authentication/userTypes.ts'; +import Button from '../components/atoms/Buttons/Button.ts'; +import useAuthenticateUser from '../api/Authentication/authenticateUser.ts'; +import { useTokenDispatch } from '../providers/AuthProvider.tsx'; +import { setToken } from '../providers/authenticationActions.ts'; const Login = () => { const [formData, setFormData] = useState({ @@ -35,7 +35,7 @@ const Login = () => { }); setToken(response.data.access, dispatch); - navigate("/") + navigate('/'); }; return ( diff --git a/src/views/StudentView.tsx b/src/views/StudentView.tsx index 17e8ca4..f3e4036 100644 --- a/src/views/StudentView.tsx +++ b/src/views/StudentView.tsx @@ -1,10 +1,9 @@ +import React from 'react'; import StudentTemplate from '../components/templates/StudentTemplate'; import HomeTemplate from '../components/templates/HomeTemplate'; import Navbar from '../components/structures/Navbar/Navbar'; import Loading from '../components/atoms/Loading/Loading'; -// funkcje-hooki swr import { useStudentById } from '../api/useStudentById'; -import React from 'react'; const StudentView = () => { const pathId = window.location.pathname.replace('/', ''); diff --git a/src/views/TasksView.tsx b/src/views/TasksView.tsx index a6a83ef..fc8f1eb 100644 --- a/src/views/TasksView.tsx +++ b/src/views/TasksView.tsx @@ -1,4 +1,5 @@ import { useParams } from 'react-router-dom'; +import React from 'react'; import HomeTemplate from '../components/templates/HomeTemplate'; import MainBox from '../components/atoms/Sections/MainBox'; import Navbar from '../components/structures/Navbar/Navbar'; @@ -11,10 +12,8 @@ import { StyledHeader, StyledHeading, } from '../components/atoms/Heading/Heading'; -// funkcje-hooki swr import { useTasks } from '../api/useTasks'; import { useStudentById } from '../api/useStudentById'; -import React from 'react'; const TasksView = () => { let { id } = useParams(); diff --git a/tsconfig.json b/tsconfig.json index 907e5ea..9570741 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,14 +5,6 @@ "lib": ["DOM", "DOM.Iterable", "ESNext"], "allowJs": true, "baseUrl": "./src", - "paths": { - "@/api/*": ["api/*"], - "@/components/*": ["components/*"], - "@/const/*": ["const/*"], - "@/images/*": ["images/*"], - "@/theme/*": ["theme/*"], - "@/views/*": ["views/*"] - }, "skipLibCheck": true, "esModuleInterop": false, "allowSyntheticDefaultImports": true, From 68422f2e58232b0ffa55c8b5df4a5ab942b82b61 Mon Sep 17 00:00:00 2001 From: mniegrzybowska Date: Sun, 23 Jun 2024 17:12:44 +0200 Subject: [PATCH 2/2] removing console.logs --- src/components/atoms/Lists/Lists.tsx | 1 - src/components/structures/Awards/AwardsList.tsx | 1 - src/components/structures/Navbar/Navbar.tsx | 1 - src/components/templates/StudentTemplate.tsx | 1 - src/images/icons/dist_/Edit.tsx | 1 - src/images/icons/dist_/Logo.tsx | 1 - 6 files changed, 6 deletions(-) diff --git a/src/components/atoms/Lists/Lists.tsx b/src/components/atoms/Lists/Lists.tsx index ebeb1fb..3387567 100644 --- a/src/components/atoms/Lists/Lists.tsx +++ b/src/components/atoms/Lists/Lists.tsx @@ -62,7 +62,6 @@ type PropsTypeLiElement = { }; const LiElement = (props: PropsTypeLiElement) => { - console.log(props); return ( diff --git a/src/components/structures/Awards/AwardsList.tsx b/src/components/structures/Awards/AwardsList.tsx index 95a49ce..c5a4212 100644 --- a/src/components/structures/Awards/AwardsList.tsx +++ b/src/components/structures/Awards/AwardsList.tsx @@ -43,7 +43,6 @@ const AwardsList = ({ awards, studentId }: any) => { }; const editPrize = (prize: any) => { - // console.log(prize); setEditing(true); setCurrentPrize({ id: prize.id, name: prize.text, value: prize.points }); }; diff --git a/src/components/structures/Navbar/Navbar.tsx b/src/components/structures/Navbar/Navbar.tsx index 9193fb7..90778a4 100644 --- a/src/components/structures/Navbar/Navbar.tsx +++ b/src/components/structures/Navbar/Navbar.tsx @@ -66,7 +66,6 @@ const StyledNavbar = styled.div` const Navbar = (): JSX.Element => { let { id } = useParams(); - //console.log(`${id}`); //Example of usage another option to implement image below: //import FromJSXElementToDataUri from "../../utils/FromSVGToDataUri"; diff --git a/src/components/templates/StudentTemplate.tsx b/src/components/templates/StudentTemplate.tsx index 782e366..5930ab7 100644 --- a/src/components/templates/StudentTemplate.tsx +++ b/src/components/templates/StudentTemplate.tsx @@ -40,7 +40,6 @@ const StudentTemplate = ({ name, points, image, studentId }: any) => { image: image || null, }; Object.assign(obj, newObj); - console.log(newObj); setStudentData(obj); }, [name, points, image]); diff --git a/src/images/icons/dist_/Edit.tsx b/src/images/icons/dist_/Edit.tsx index e592bcf..fc2c4af 100644 --- a/src/images/icons/dist_/Edit.tsx +++ b/src/images/icons/dist_/Edit.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { ReactSVG } from 'react-svg'; const SvgEdit: any = (props: any) => { - console.log('hugooooooo'); return ; }; //export default SvgEdit; diff --git a/src/images/icons/dist_/Logo.tsx b/src/images/icons/dist_/Logo.tsx index 1149385..8ecbd5a 100644 --- a/src/images/icons/dist_/Logo.tsx +++ b/src/images/icons/dist_/Logo.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { ReactSVG } from 'react-svg'; const SvgLogo: any = (props: any) => { - console.log('logggggoooooooo'); return ; }; //export default SvgLogo;