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

Phone Catalog - Done #338

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

Conversation

netzelnatalia
Copy link

<div className="App">
<h1>React Phone Catalog</h1>
</div>
<GeneralProvider>

Choose a reason for hiding this comment

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

Don't you find the name 'GeneralProvider' like... too general? :)
It's not a mistake, but why don't we think about some alternative naming?

@@ -0,0 +1,57 @@
import { Product } from '../types/Product';

export const BASE_URL

Choose a reason for hiding this comment

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

Nice. Creating a const for a basic url is a great approach.


export const getHotPriceProducts = () => {
return getAllProducts()
.then(products => products
Copy link

@yevhenii-pyl yevhenii-pyl Feb 15, 2024

Choose a reason for hiding this comment

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

Well, basically, you fill never do filtering like this on a FE side and this will be handled on the backend.
However, as a simplification for training purposes this may work.

@@ -0,0 +1,57 @@
import { Product } from '../types/Product';

Choose a reason for hiding this comment

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

I'd probably called this file index.ts and use it as a main entry point for all API calls.

Then, create for each category: phones, tablets, all products just to have it nicely stored.

Definitely, not a mistake here on your side as for current assignment, but as the app grows having all API calls in one file may become a bit of a pain.

setCartList(newCart);
};

const increaseNumber = () => changeNumber(1);

Choose a reason for hiding this comment

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

Why don't you use changeNumber as a handler directly?
Having that extra functions looks unnecessary.

@@ -0,0 +1,85 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable global-require */
import React, { useState } from 'react';

Choose a reason for hiding this comment

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

I'd change imports order for consistency:

// external libs
import React, { useState } from 'react';
import { Link } from 'react-router-dom';

// components
import { Checkout } from '../Checkout';

// styles
import './Footer.scss';

Routes,
Route,
Navigate,
} from 'react-router-dom';

Choose a reason for hiding this comment

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

Can't see react-router-dom at the package.json


useEffect(() => {
setIsLoading(true);
getPhones().then(setPhonesList)

Choose a reason for hiding this comment

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

What if there is a fetching error?


useEffect(() => {
const fetchData = async () => {
try {

Choose a reason for hiding this comment

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

catch?

@@ -0,0 +1,52 @@
import React, { useEffect, useState } from 'react';

Choose a reason for hiding this comment

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

It's not a helper, it is a context. I believe, that should be a separate folder for it like store or something.

Copy link

@yevhenii-pyl yevhenii-pyl left a comment

Choose a reason for hiding this comment

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

Solid work!
Let's just go through failed tests and provide a few minor adjustments.

@netzelnatalia netzelnatalia changed the title add task solution Phone Catalog Nov 15, 2024
@netzelnatalia netzelnatalia changed the title Phone Catalog Phone Catalog - Done Nov 15, 2024
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.

2 participants