diff --git a/docker-compose.yaml b/docker-compose.yaml index 6df6d6e..9265be0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,11 +1,11 @@ version: '3.3' services: api: - build: - context: ./ - dockerfile: local.Dockerfile - volumes: - - ./:/app - - ./.m2:/root/.m2 - working_dir: /app - command: sh run.sh \ No newline at end of file + build: + context: ./ + dockerfile: local.Dockerfile + volumes: + - ./:/app + - ./.m2:/root/.m2 + working_dir: /app + command: sh run.sh diff --git a/src/app/api/file.ts b/src/app/api/file.ts index b187ec4..821e22b 100644 --- a/src/app/api/file.ts +++ b/src/app/api/file.ts @@ -1,23 +1,17 @@ import axios, { AxiosResponse } from 'axios'; import { BACKEND_URL } from 'envConstants'; - -export interface FileUpload{ - - message: string, - isSuccessful: boolean, - statusCode: number, - +export interface FileUpload { + message: string; + isSuccessful: boolean; + statusCode: number; } - - - export const uploadIcon = async ( authorizationToken: string, orgName: string, file: File -):Promise> => { +): Promise> => { const url = BACKEND_URL + '/api/protected/file/upload/' + orgName; const formData = new FormData(); formData.append('file', file); diff --git a/src/app/api/login.ts b/src/app/api/login.ts index 6f1f1c9..2fdfa66 100644 --- a/src/app/api/login.ts +++ b/src/app/api/login.ts @@ -2,15 +2,16 @@ import axios from 'axios'; import { BACKEND_URL } from 'envConstants'; import { AxiosResponse } from 'axios'; - -export interface LoginData{ - token: string, - username: string, - type: string, - id: number +export interface LoginData { + token: string; + username: string; + type: string; + id: number; } -export const login = async (code: string):Promise> => { +export const login = async ( + code: string +): Promise> => { const url = BACKEND_URL + '/api/auth/login'; const respnse = await axios.post( url, diff --git a/src/app/api/organization.ts b/src/app/api/organization.ts index e182af3..2cba422 100644 --- a/src/app/api/organization.ts +++ b/src/app/api/organization.ts @@ -6,13 +6,12 @@ export interface organizationBody { description: string; } - -export interface AllOrgs{ +export interface AllOrgs { organizations: { - id: number, - name: string, - description: string|null - }[] + id: number; + name: string; + description: string | null; + }[]; } export const deleteOrg = async ( @@ -204,7 +203,9 @@ export const getOrg = async (authorizationToken: string, orgName: string) => { return respnse; }; -export const getAllOrgs = async (authorizationToken: string): Promise> => { +export const getAllOrgs = async ( + authorizationToken: string +): Promise> => { const url = BACKEND_URL + '/api/protected/org/getAllOrg'; const respnse = await axios.get(url, { headers: { diff --git a/src/app/api/user.ts b/src/app/api/user.ts index 5b6fbfd..ad71ade 100644 --- a/src/app/api/user.ts +++ b/src/app/api/user.ts @@ -1,38 +1,36 @@ -import axios,{AxiosResponse} from 'axios'; +import axios, { AxiosResponse } from 'axios'; import { BACKEND_URL } from 'envConstants'; - - - -export interface UserData{ - message: string +export interface UserData { + message: string; } - - -export interface AllUserData{ +export interface AllUserData { users: { - id: number, - username: string - }[] + id: number; + username: string; + }[]; } -export const getUser= async (authorizationToken: string):Promise> => { +export const getUser = async ( + authorizationToken: string +): Promise> => { const url = BACKEND_URL + '/api/protected/user/getUser'; - const respnse = await axios.get(url, { - headers: { - Accept: 'application/json', - - Authorization: `Bearer ${authorizationToken}`, - }, - }); - - return respnse; + const respnse = await axios.get(url, { + headers: { + Accept: 'application/json', + + Authorization: `Bearer ${authorizationToken}`, + }, + }); + return respnse; }; -export const getAllUser = async (authorizationToken: string):Promise> => { +export const getAllUser = async ( + authorizationToken: string +): Promise> => { const url = BACKEND_URL + '/api/protected/user/all'; const respnse = await axios.get(url, { headers: { diff --git a/src/app/index.tsx b/src/app/index.tsx index c71f936..062bd6b 100644 --- a/src/app/index.tsx +++ b/src/app/index.tsx @@ -8,7 +8,7 @@ function App() { <> - + ); } diff --git a/src/app/state/action-creators/usersActions.ts b/src/app/state/action-creators/usersActions.ts index 3911e53..e7078bc 100644 --- a/src/app/state/action-creators/usersActions.ts +++ b/src/app/state/action-creators/usersActions.ts @@ -17,4 +17,3 @@ export const setAllUsernames = (usernames: string[]) => { }); }; }; - diff --git a/src/features/login/index.tsx b/src/features/login/index.tsx index 33dff2d..2e44165 100644 --- a/src/features/login/index.tsx +++ b/src/features/login/index.tsx @@ -1,60 +1,51 @@ - - import { useEffect } from 'react'; import { CLIENT_ID } from '../../envConstants'; import { useNavigate, useSearchParams } from 'react-router-dom'; import { login } from 'app/api/login'; import { useQuery } from 'react-query'; -import {getUser } from 'app/api/user'; +import { getUser } from 'app/api/user'; import toast from 'react-hot-toast'; - const Login = () => { - const [searchParam, ] = useSearchParams(); + const [searchParam] = useSearchParams(); const navigate = useNavigate(); - const token=localStorage.getItem('token') - const checklogin=async()=>{ - if(token!=null){ - try{ - const userData= await getUser(token); - navigate('/') - - }catch(e){ - navigate('/login') - } - + const token = localStorage.getItem('token'); + const checklogin = async () => { + if (token != null) { + try { + const userData = await getUser(token); + navigate('/'); + } catch (e) { + navigate('/login'); + } } - } + }; - useEffect(()=>{ - checklogin() - },[]) - - + useEffect(() => { + checklogin(); + }, []); - const loginFunc= async()=>{ - - if(searchParam.get('code')!==null){ - console.log("hello") - const code:string= searchParam.get('code')!; - const loginData= await login(code); - const token= loginData.data.token - localStorage.setItem('token',token) - toast.success('Login successfull') - navigate("/") - } - - } + const loginFunc = async () => { + if (searchParam.get('code') !== null) { + console.log('hello'); + const code: string = searchParam.get('code')!; + const loginData = await login(code); + const token = loginData.data.token; + localStorage.setItem('token', token); + toast.success('Login successfull'); + navigate('/'); + } + }; - const {isError}=useQuery({ - queryFn: ()=>loginFunc(), - queryKey:"loginData" - }) + const { isError } = useQuery({ + queryFn: () => loginFunc(), + queryKey: 'loginData', + }); - if(isError){ - toast.error('Some error occured') - navigate("/login") + if (isError) { + toast.error('Some error occured'); + navigate('/login'); } function loginWithGithub() { diff --git a/src/index.tsx b/src/index.tsx index 062718b..8289a63 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,22 +7,20 @@ import { store } from 'app/state/store'; import { Provider } from 'react-redux'; import { QueryClient, QueryClientProvider } from 'react-query'; - -const queryClient= new QueryClient() +const queryClient = new QueryClient(); const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement ); - root.render( - - - - - + + + + + );