Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Project 1T30-Project-1

## Links

Repo: [https://git.ntnu.no/IT2810-H26/T30-Project-1]

Webiste: [http://it2810-30.idi.ntnu.no/project1]


## Docs

Read docs in [/docs](/docs/README.md)

## Useful commands

> These are generated in ./package.json `scripts` tag. Leaving them here as a cheatsheet.
Expand Down
Binary file added docs/Architecture/plan1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5,424 changes: 5,424 additions & 0 deletions docs/Architecture/plan1_excalidraw.md

Large diffs are not rendered by default.

64 changes: 60 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,65 @@

This directory contains all the docs for this project.

Fill in this readme as needed to index new subdirectories
with high level information. This avoids our docs from being too abstract

1. ./old_root_readme/
- ./old_root_readme/
Contains the original readme's that I deleted from root, so you may
read it if you wish
- Here is a `tree` of our tests, it cover all components and features.

```bash
│   ├── pokemon.test.ts
├── App.test.tsx
│   │   ├── Favorite.test.tsx
│   │   └── Favorite.test.tsx.snap
│   │   ├── FavoritePokemon.test.tsx
│   │   └── FavoritePokemon.test.tsx.snap
│   │   ├── Filter.test.tsx
│   │   └── Filter.test.tsx.snap
│   │   ├── PokemonCard.test.tsx
│   │   └── PokemonCard.test.tsx.snap
│   ├── PokemonList.test.tsx
│   ├── pokemonController.test.ts
│   ├── useFavorites.test.ts
│   ├── useFilters.test.ts
│   ├── favorites.test.ts
│   ├── filters.test.ts

```

All tests pass:

![image of passed tests](./tests.png)

- . We had one meeting in the beginning to discuss the project. We ended up deciding to use MVC pattern and created the following diagram `plan1.png` (`plan1_excalidraw.md`)

![plan1 driagram](./Architecture/plan1.png)

- Worksheet:
```json
{
"Alberto Corvaglia": {
"7/9": "6 hours",
"8/9": "6 hours"
},

"Ayush Bhardwaj": {
"11/9": "4 hours",
"14/9": "4 hours",
"16/9": "4 hours"

},

"Ilias Bouqdire": {
"8/9": "4 hours",
"9/9": "5 hours",
"18/9": "3 hours"
},

"Thomas-Andre Hetlesaether": {
"8/9": "4 hours",
"13/9": "4 hours",
"14/9": "4 hours",
"18/9": "1 hour"
}
}
```
Binary file added docs/tests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/Filter/Filter.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
/* On a narrow screen the panel fills the width instead of floating */
@media (max-width: 1000px) {
.filter-panel {
position: static;
position: absolute;
width: auto;
max-height: none;
}
Expand Down
4 changes: 0 additions & 4 deletions src/controllers/useFavorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ import {
import { GetMany } from "./pokemonController";

export function useFavorites() {
// 1. Lazy initialization from localStorage
const [favoriteIds, setFavoriteIds] = useState<number[]>(loadFavorites);

// 2. Keep storage in sync so favorites survive closing the browser
useEffect(() => {
saveFavorites(favoriteIds);
}, [favoriteIds]);

// 3. Fetch through TanStack Query so the data is cached between toggles
const { data: favoritePokemons = [], isPending } = useQuery({
queryKey: ["favorites", favoriteIds],
queryFn: () => GetMany(favoriteIds),
enabled: favoriteIds.length > 0,
});

// 4. Handlers passed down to the components
const toggleFavorite = useCallback((id: number) => {
setFavoriteIds((prev) => toggleInList(prev, id));
}, []);
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";

export default defineConfig({
base: "http://it2810-30.idi.ntnu.no/project1/",
plugins: [react()],

test: {
Expand Down