test to test

This commit is contained in:
wrzesinski-hubert 2020-12-08 19:25:52 +01:00
parent 68667e55de
commit a3438586bd
4 changed files with 19 additions and 6 deletions

View File

@ -162,7 +162,7 @@ export default function ({ handleTransfer }: TopbarProps) {
<FlexboxColumn> <FlexboxColumn>
<ClickAwayListener onClickAway={handleCloseDropdown}> <ClickAwayListener onClickAway={handleCloseDropdown}>
<Flexbox> <Flexbox>
<SelectMenu changeSelectedOption={changeSelectedOption} selectedOption={selectedOption} changeDropdownOpen={setOpen}/> {/* <SelectMenu changeSelectedOption={changeSelectedOption} selectedOption={selectedOption} changeDropdownOpen={setOpen}/> */}
<InputWrapper> <InputWrapper>
<Input <Input
placeholder={`Wyszukaj ${selectedOption === "studenci" ? "studentów..." : "przedmioty..."}`} placeholder={`Wyszukaj ${selectedOption === "studenci" ? "studentów..." : "przedmioty..."}`}

View File

@ -1,5 +1,5 @@
import React, { useState, useEffect, createContext, ReactNode } from 'react'; import React, { useState, useEffect, createContext, ReactNode } from 'react';
import { User } from '../types'; import { User, Token } from '../types';
import { axiosInstance } from '../utils/axiosInstance'; import { axiosInstance } from '../utils/axiosInstance';
export interface CASContext { export interface CASContext {
@ -27,10 +27,16 @@ export const CASProvider = ({ children }: CASProviderProps) => {
try { try {
if (!sessionStorage.getItem('userToken')) { if (!sessionStorage.getItem('userToken')) {
const { data: token } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/token?ticket=${ticket}`); const { data: token } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/token?ticket=${ticket}`);
sessionStorage.setItem('userToken', token); sessionStorage.setItem('userToken', token.token);
} }
const token = sessionStorage.getItem('userToken'); const tokenik:any = JSON.parse(sessionStorage.getItem('userToken')as string);
setToken(token); const token: Token = {
authorityRole: tokenik.authorityRole,
email: tokenik.email,
id: tokenik.id,
token: tokenik.token,
};
setToken(token.token);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }

View File

@ -17,7 +17,7 @@ export const UsersProvider = ({ children }: UsersProviderProps) => {
const getUsers = async () => { const getUsers = async () => {
try { try {
const {data}= await axiosInstance.get<Array<User>>(`${process.env.REACT_APP_API_URL}/api/v1/users/student/search?query=`); const {data}= await axiosInstance.get<Array<User>>(`${process.env.REACT_APP_API_URL}/api/v1/users/students`);
setUsers(data); setUsers(data);
console.log(data); console.log(data);
} catch(e){ } catch(e){

View File

@ -27,6 +27,13 @@ export interface Course {
classes?: Array<Group>; classes?: Array<Group>;
} }
export interface Token {
authorityRole: string,
email: string,
id: number,
token: string,
}
export interface User { export interface User {
email: string; email: string;
id: number; id: number;