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

Origin/implement login page/ login signup pages components #78

Closed
wants to merge 8 commits into from

Conversation

lylaaron98
Copy link

@lylaaron98 lylaaron98 commented Mar 3, 2024

created login page and signup page.tsx, isolated components under components directory

Closes #7

reconfigured layout.tsx to avoid re-creating it on each render
login and sign up pages
isolated the components from the full page.tsx
Refactor the Signup page by isolating form-related logic and UI elements into modular components.
Introduced components in the form, layout, and ui directories for better code organization.
update page.tsx for signup
@Ziyang-98 Ziyang-98 added frontend Frontend related feature A new feature labels Mar 3, 2024
@Ziyang-98 Ziyang-98 added this to the M2: More features milestone Mar 3, 2024
Copy link
Collaborator

Choose a reason for hiding this comment

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

Help to remove empty files

Copy link
Author

Choose a reason for hiding this comment

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

image

Copy link
Author

Choose a reason for hiding this comment

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

im not sure which empty file are you referring to. can you highlight it again

Copy link
Author

Choose a reason for hiding this comment

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

image

Copy link
Author

Choose a reason for hiding this comment

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

not sure which empty file are you referring to

Copy link
Collaborator

Choose a reason for hiding this comment

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

these files are in your local machine but there are not commited and pushed to the branch on GitHub. You should check when you create a PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, please fix all the red lines above. They are errors and even if your app works, they can cause probs in the future.


return (
<PageLayout title={loading ? "Processing" : "Login"} loading={loading}>
<LoginForm onLogin={onLogin} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this importing an empty component?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to import this form component since you already have form input fields in the same file

Copy link
Author

Choose a reason for hiding this comment

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

PageLayout is from flowforge\frontend\src\components\layouts\pageLayout.tsx
while LoginForm is from flowforge\frontend\src\components\form\loginForm.tsx

I've recommitted the changes to origin again. maybe the first commit did not register the saved changes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Your new commit only pushed inputField.tsx. The other files are still empty

return (
<PageLayout title={loading ? "Processing" : "Login"} loading={loading}>
<LoginForm onLogin={onLogin} />
<InputField
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is input field?

Copy link
Author

Choose a reason for hiding this comment

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

inputField is a component I created under frontend\src\components\ui\inputField.tsx

Copy link
Author

Choose a reason for hiding this comment

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

image
inputField.tsx, component under flowforge\frontend\src\components\ui\inputField.tsx

Copy link
Author

Choose a reason for hiding this comment

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

shld I remove the components ive created and instead utilise the existing ones? thought its easier since its kind of different. lmk thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes please use the shadcn ui components we have for consistency. It is easier to implement with them as compared to vanilla HTML since its a library with pre-coded logic. We don't want to introduce other libs also.

import Link from "next/link";
import React, { useState } from "react";
import axios from "axios";
import { toast } from "react-hot-toast";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't use another toast library. There is already an existing toast component you can use. Also in my opinion, no need to use toast here. Simply login on success or display error below the form field if any. This can be done with the existing shadcn ui form component (Guide)

onChange={(value) => setUser({ ...user, password: value })}
placeholder="password"
/>
<button
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use our existing shadcn ui button component for consistent UI

Copy link
Collaborator

@Ziyang-98 Ziyang-98 left a comment

Choose a reason for hiding this comment

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

I believe your PR is incomplete yet. Please help to address the comments, thanks.

updated some of the PR issues highlighted
updated according to comments in PR #78
@@ -0,0 +1,19 @@
import React from "react";

const InputField = ({ id, type, value, onChange, placeholder }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are using Typescript so this should flag out an error since the props type is not defined

return (
<div>
<label htmlFor={id}>{id}</label>
<input
Copy link
Collaborator

Choose a reason for hiding this comment

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

try to use the shadcn ui components we have. Can look here for details on how to use.

Copy link
Collaborator

@Ziyang-98 Ziyang-98 Mar 6, 2024

Choose a reason for hiding this comment

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

loginForm.tsx, signupForm.tsx and pageLayout.tsx are still empty files

@Ziyang-98
Copy link
Collaborator

Still an incomplete PR. Please check if your code works in your local machine too

const onLogin = async (user) => {
try {
setLoading(true);
const response = await axios.post("/api/users/login", user);
Copy link
Collaborator

@Ziyang-98 Ziyang-98 Mar 6, 2024

Choose a reason for hiding this comment

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

Why are you usin axios already when there is no backend api for login? /api/users/login does not exist. Please remove this to prevent invalid and unnecessary API calls.

@Ziyang-98 Ziyang-98 closed this Mar 7, 2024
@joshtyf joshtyf deleted the origin/implement-login-page branch July 1, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature frontend Frontend related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement login page
2 participants