Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ig 130 #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Ig 130 #136

wants to merge 2 commits into from

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)


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 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?


async function register() {
setLoading(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;
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

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

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;
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
2 participants