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

ci: add a lot of linting #1

Closed
wants to merge 13 commits into from
Closed

ci: add a lot of linting #1

wants to merge 13 commits into from

Conversation

Rei-x
Copy link
Collaborator

@Rei-x Rei-x commented May 18, 2024

No description provided.

Comment on lines 20 to 35
useEffect(() => {
localStorage.setItem('favorites', JSON.stringify(favorites));
localStorage.setItem("favorites", JSON.stringify(favorites));
}, [favorites]);

const handleFavorite = (book) => {
const handleFavorite = (book: Book_t) => {
setFavorites((prevFavorites) => {
const isAlreadyFavorite = prevFavorites.some(f => f.id === book.id);
const isAlreadyFavorite = prevFavorites.some(
(f: Book_t) => f.id === book.id,
);
const updatedFavorites = isAlreadyFavorite
? prevFavorites.filter(f => f.id !== book.id)
? prevFavorites.filter((f: Book_t) => f.id !== book.id)
: [...prevFavorites, book];
localStorage.setItem('favorites', JSON.stringify(updatedFavorites));
localStorage.setItem("favorites", JSON.stringify(updatedFavorites));
return updatedFavorites;
});
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

po co jest ten useEffect na górze, skoro niżej wstawiasz rzeczy do local storage'u?

Copy link
Collaborator Author

@Rei-x Rei-x left a comment

Choose a reason for hiding this comment

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

widać chata gpt 😭, bo kodzik wygląda nie najgorzej

good job Dawid, spisałeś się

Comment on lines +26 to +28
const isAlreadyFavorite = prevFavorites.some(
(f: Book_t) => f.id === book.id,
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nie potrzebujesz tu adnotacji

Suggested change
const isAlreadyFavorite = prevFavorites.some(
(f: Book_t) => f.id === book.id,
);
const isAlreadyFavorite = prevFavorites.some(
(f) => f.id === book.id,
);

Comment on lines +12 to 15
const handleFavoriteClick = (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
handleFavorite(book);
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

byś nie musiał tego typować jakbyś to wrzucił bezpośrednio koło buttona

        <button
          className={styles.favorite_container}
          onClick={(e) => {
            e.stopPropagation();
            handleFavorite(book);
          }}
        >

import styles from "../styles/book.module.css";
import type { BookProps } from "./appContext";

const Book = React.memo(function Book({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

te memo i tak nie zadziała tutaj 😭, lepiej je wyrzucić

export function toggleStringInList(string, list) {
const DELAY = 300;

export function toggleStringInList(string: string, list: string[]): string[] {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nie potrzebujesz tu typu

Suggested change
export function toggleStringInList(string: string, list: string[]): string[] {
export function toggleStringInList(string: string, list: string[]) {

<div>
{languages.map((clickedLanguage) => (
<button
key={clickedLanguage} // Unique key prop added here
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

xd, dobry komentarz

<Book
key={book.id}
book={book}
isFavorite={favorites.some((f: Book_t) => f.id === book.id)}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
isFavorite={favorites.some((f: Book_t) => f.id === book.id)}
isFavorite={favorites.some((f) => f.id === book.id)}

/>
))}
<div>
{favoriteBooks.map((book: Book_t) => (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
{favoriteBooks.map((book: Book_t) => (
{favoriteBooks.map((book) => (

Comment on lines +17 to +21
const savedFavoritesJSON = localStorage.getItem("favorites");
const savedFavorites =
savedFavoritesJSON !== null
? (JSON.parse(savedFavoritesJSON) as Book_t[])
: [];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

czemu ładujesz to na nowo skoro masz z props'ów tablice favorites? nie mogłeś jej użyć?

@Rei-x Rei-x closed this May 31, 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