Skip to content

Commit

Permalink
chore: ran prettier
Browse files Browse the repository at this point in the history
Signed-off-by: Karthik Ayangar <[email protected]>
  • Loading branch information
kituuu committed Dec 29, 2023
1 parent 59a01ed commit 6b85e27
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 108 deletions.
16 changes: 8 additions & 8 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
build:
context: ./
dockerfile: local.Dockerfile
volumes:
- ./:/app
- ./.m2:/root/.m2
working_dir: /app
command: sh run.sh
16 changes: 5 additions & 11 deletions src/app/api/file.ts
Original file line number Diff line number Diff line change
@@ -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<AxiosResponse<FileUpload>> => {
): Promise<AxiosResponse<FileUpload>> => {
const url = BACKEND_URL + '/api/protected/file/upload/' + orgName;
const formData = new FormData();
formData.append('file', file);
Expand Down
15 changes: 8 additions & 7 deletions src/app/api/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AxiosResponse<LoginData>> => {
export const login = async (
code: string
): Promise<AxiosResponse<LoginData>> => {
const url = BACKEND_URL + '/api/auth/login';
const respnse = await axios.post<LoginData>(
url,
Expand Down
15 changes: 8 additions & 7 deletions src/app/api/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -204,7 +203,9 @@ export const getOrg = async (authorizationToken: string, orgName: string) => {
return respnse;
};

export const getAllOrgs = async (authorizationToken: string): Promise<AxiosResponse<AllOrgs>> => {
export const getAllOrgs = async (
authorizationToken: string
): Promise<AxiosResponse<AllOrgs>> => {
const url = BACKEND_URL + '/api/protected/org/getAllOrg';
const respnse = await axios.get<AllOrgs>(url, {
headers: {
Expand Down
44 changes: 21 additions & 23 deletions src/app/api/user.ts
Original file line number Diff line number Diff line change
@@ -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<AxiosResponse<UserData>> => {
export const getUser = async (
authorizationToken: string
): Promise<AxiosResponse<UserData>> => {
const url = BACKEND_URL + '/api/protected/user/getUser';

const respnse = await axios.get<UserData>(url, {
headers: {
Accept: 'application/json',

Authorization: `Bearer ${authorizationToken}`,
},
});

return respnse;
const respnse = await axios.get<UserData>(url, {
headers: {
Accept: 'application/json',

Authorization: `Bearer ${authorizationToken}`,
},
});

return respnse;
};

export const getAllUser = async (authorizationToken: string):Promise<AxiosResponse<AllUserData>> => {
export const getAllUser = async (
authorizationToken: string
): Promise<AxiosResponse<AllUserData>> => {
const url = BACKEND_URL + '/api/protected/user/all';
const respnse = await axios.get<AllUserData>(url, {
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function App() {
<>
<Navbar />
<BasicRoutes />
<Toaster/>
<Toaster />
</>
);
}
Expand Down
1 change: 0 additions & 1 deletion src/app/state/action-creators/usersActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ export const setAllUsernames = (usernames: string[]) => {
});
};
};

75 changes: 33 additions & 42 deletions src/features/login/index.tsx
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
14 changes: 6 additions & 8 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<React.StrictMode>
<BrowserRouter>
<QueryClientProvider client={queryClient}>
<Provider store={store}>
<App />
</Provider>
</QueryClientProvider>
<QueryClientProvider client={queryClient}>
<Provider store={store}>
<App />
</Provider>
</QueryClientProvider>
</BrowserRouter>
</React.StrictMode>
);
Expand Down

0 comments on commit 6b85e27

Please sign in to comment.