Skip to content

Conversation

@igorbacz
Copy link
Collaborator

No description provided.

@igorbacz igorbacz linked an issue May 20, 2022 that may be closed by this pull request
Copy link
Owner

@pdybowski pdybowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix and TEST requests (if you have questions just ask)

import { NotificationContext } from '../../../contexts';

export const LoginPage = (): JSX.Element => {
export const LoginPage = (): any => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why INFO when its an error?

return addNotification({
mode: NotificationMode.INFO,
title: 'Login',
message: error,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its error.message

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong url, its /auth/login

const dispatch = useDispatch();

const login = async () => {
setIsLoading(true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove?

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont want initUserState. or if you want to just empty object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

finish login and register pages

3 participants