Skip to content

Project 3 - Frontend (Ian Lau, Qian Ling, Charles Lee)#48

Open
charlesleezhaoyi wants to merge 172 commits into
rocketacademy:mainfrom
charlesleezhaoyi:main
Open

Project 3 - Frontend (Ian Lau, Qian Ling, Charles Lee)#48
charlesleezhaoyi wants to merge 172 commits into
rocketacademy:mainfrom
charlesleezhaoyi:main

Conversation

@charlesleezhaoyi

Copy link
Copy Markdown

No description provided.

charlesleezhaoyi and others added 30 commits March 15, 2024 22:49
Test forum navbar + Initial FE auth logic
Add function in tailwind.config.js for component checking
…dded error alert on onboarding when user has not verified email
charlesleezhaoyi and others added 27 commits April 13, 2024 21:27
added API calls to fetch token + send verification email on clicking …
}) {
const { getAccessTokenSilently } = useAuth0();
const { bookId } = useParams();
const handleSubmit = async () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

naming a bit odd. This should be handleClick rather, since we do not submit a form in this component

},
{ headers: { Authorization: `Bearer ${token}` } }
);
window.location.reload();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

By right we should avoid reloads like such, as it goes against react principles

@@ -0,0 +1,15 @@
const Button = ({ label, onClick }) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You could have used this for the AcceptRequestButton instead of writing another component. This could be made generic enough to fit the AcceptRequestButton criteria

setSelectedCategories((prevSelected) => {
if (prevSelected.includes(category)) {
// If it is, remove it from the array
return prevSelected.filter((c) => c !== category);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nested loop, not exactly efficient

key={category}
onClick={(e) => toggleCategory(e, category)}
className={`px-4 py-2 rounded-full border ${
selectedCategories.includes(category)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could we solve this in another way? Looping through a whole array just to apply styles seems a bit overkill

Comment thread src/pages/NewBook.js
import useLoadCategories from "../hooks.js/useLoadCategories.js";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import Photo from "../components/Common/Photo.js";
const defaultInput = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If we don't reuse this, why not just place the object in the default state directly?

Comment thread src/pages/NewBook.js
Comment on lines +118 to +139
<TextInput
label="Book title"
type="text"
onChange={(e) =>
setInputData((prev) => {
return { ...prev, title: e.target.value };
})
}
value={inputData.title}
placeholder="Grumpy Monkey"
/>
<TextInput
label="Author"
type="text"
onChange={(e) =>
setInputData((prev) => {
return { ...prev, author: e.target.value };
})
}
value={inputData.author}
placeholder="Suzanne Lang"
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I see a lot of repetition here that we could easily handle dynamically

Comment thread src/pages/SingleBook.js
setPhotoURLs(
photos.map((photo) => convertBufferToPhoto(photo.file.data))
);
const requestRes = await axios.get(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would almost want to create a second useEffect here to separate responsibilities

Comment thread src/pages/SingleBook.js

const photosDisplay = photoURLs.map((url) => <Photo url={url} key={url} />);

const nonDonorRequestDisplay = isBeneRequested ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's write out words like Bene. This is not intuitive to read for everyone and takes up brain capacity to spell out

Comment thread src/pages/SingleBook.js
Comment on lines +84 to +86
return isLoadingData ? (
<Loading />
) : (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think two return statements might be easier to read here :)

Comment thread README.md

https://www.figma.com/file/BltTY2KqZ9q43BWp3k065P/Book-exchange-app?type=design&node-id=0-1&mode=design&t=IHFmjkw6Xp3dVCND-0

## How to install the app

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What about the environment variables needed to setup?

</div>
<div className="flex flex-col w-5/6 space-y-3">
<label className="text-xl self-start">Genres:</label>
{!!categoryOptions.length ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
{!!categoryOptions.length ? (
{categoryOptions.length ? (

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.

4 participants