Conversation
pdybowski
left a comment
There was a problem hiding this comment.
fix and TEST requests (if you have questions just ask)
| import { NotificationContext } from '../../../contexts'; | ||
|
|
||
| export const LoginPage = (): JSX.Element => { | ||
| export const LoginPage = (): any => { |
There was a problem hiding this comment.
dont have to set return type here
| // TODO display notification from context | ||
| console.log(error?.response.data || error?.response.status); | ||
| return addNotification({ | ||
| mode: NotificationMode.INFO, |
| return addNotification({ | ||
| mode: NotificationMode.INFO, | ||
| title: 'Login', | ||
| message: error, |
| try { | ||
| // TODO save user data to reducer | ||
| const userData = (await api.post('url..', form)) as User; | ||
| const userData = (await api.post('/login', form)) as User; |
| const dispatch = useDispatch(); | ||
|
|
||
| const login = async () => { | ||
| setIsLoading(true); |
| try { | ||
| // TODO save user data to reducer | ||
| const userData = (await api.post('url...', form)) as User; | ||
| const userData = (await api.post('/register', form)) as User; |
There was a problem hiding this comment.
check login component comments and fix ALL register
| try { | ||
| // TODO save user data to reducer | ||
| const userData = (await api.post('url..', form)) as User; | ||
| const userData = (await api.post('/login', form)) as User; |
There was a problem hiding this comment.
use generic types for POST
we want to declare with post requset will return
//
post method in api class should return Promise
| const userData = (await api.post('url..', form)) as User; | ||
| const userData = (await api.post('/login', form)) as User; | ||
| setLocalStorage(USER_TOKEN, userData.token); | ||
| dispatch(saveUserDataAction(form)); |
There was a problem hiding this comment.
we want to store userData that comes from api (check api response). not form. PASSWORD and token cannot be stored here :p
| // TODO save user data to reducer | ||
| const userData = (await api.post('url..', form)) as User; | ||
| const userData = (await api.post('/login', form)) as User; | ||
| setLocalStorage(USER_TOKEN, userData.token); |
There was a problem hiding this comment.
token doesnt exist in userData. its different (check response)
| import { User } from '../../models/user'; | ||
| import { SAVE_USER_DATA } from '../actions/userActions'; | ||
|
|
||
| const initUserState: User = new User(); |
There was a problem hiding this comment.
we dont want initUserState. or if you want to just empty object
No description provided.