diff --git a/web/package.json b/web/package.json index c553c4e..6f800b7 100644 --- a/web/package.json +++ b/web/package.json @@ -4,6 +4,7 @@ "private": true, "scripts": { "dev": "vite dev", + "dev:host": "vite dev --host", "build": "vite build", "prepare": "cd ../ && husky install web/.husky", "preview": "vite preview", diff --git a/web/src/ambient.d.ts b/web/src/ambient.d.ts index 55a4f8f..1bab3c8 100644 --- a/web/src/ambient.d.ts +++ b/web/src/ambient.d.ts @@ -59,6 +59,8 @@ export type Stats = { }; export type SearchResult = { - db: (MovieTye & { lists: ListType })[]; + db: MovieWithLists[]; tmdb: MovieType[]; }; + +export type MovieWithLists = MovieType & { lists: ListType[] }; diff --git a/web/src/lib/Modal.svelte b/web/src/lib/Modal.svelte index a775c9c..0ea2b8f 100644 --- a/web/src/lib/Modal.svelte +++ b/web/src/lib/Modal.svelte @@ -56,7 +56,7 @@ bind:this="{dialog}" on:close="{() => (showModal = false)}" on:click|self="{closeDialog}" - class="min-w-96 bg-background text-text rounded-xl" + class="w-11/12 sm:w-2/3 lg:w-2/4 xl:w-1/3 3xl:w-1/4 bg-background text-text rounded-xl" >
diff --git a/web/src/lib/Movie/MovieModal.svelte b/web/src/lib/Movie/MovieModal.svelte index 3217a45..49e58a4 100644 --- a/web/src/lib/Movie/MovieModal.svelte +++ b/web/src/lib/Movie/MovieModal.svelte @@ -3,12 +3,12 @@ import { FontAwesomeIcon } from '@fortawesome/svelte-fontawesome'; import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons'; import MovieResult from './MovieResult.svelte'; - import type { MovieType } from '../../ambient'; + import type { MovieWithLists } from '../../ambient'; export let showMovieModal: boolean; export let listId: string; let search: string; - let movies: MovieType[] = []; + let movies: MovieWithLists[] = []; const handleOnClick = async () => { const response = await fetch(`/search?search=${search}`, { @@ -22,11 +22,15 @@ movies = await response.json(); } }; + + const handleKeyPress = async (e: KeyboardEvent) => { + e.key === 'Enter' && (await handleOnClick()); + };
-

movie

+

search

-
-
-
-

{movie.rating.toFixed(1)}

-

- : {new Date(movie.releaseDate).getFullYear() || - 'unavailable'} -

-
- - - - - - - - - -
-
-
-

- : - {movie.title} -

-

- : - {#each movie.genre as genre (genre)} - {genre} - {/each} -

-

- : - {movie.description} -

+
+
+
+
+

{movie.rating.toFixed(1)}

+

+ : {new Date(movie.releaseDate).getFullYear() || + 'unavailable'} +

+
+ + + + + + + + + +
+
+
+

+ : + {movie.title} +

+

+ : + {#each movie.genre as genre (genre)} + {genre} + {/each} +

+

+ : + {movie.description} +

+
+ {#if movie.lists.length} + + {/if}
diff --git a/web/src/lib/Search/Lists.svelte b/web/src/lib/Search/Lists.svelte new file mode 100644 index 0000000..1844eb2 --- /dev/null +++ b/web/src/lib/Search/Lists.svelte @@ -0,0 +1,15 @@ + + +
+

Film in list(s)

+ {#each lists as list (list.id)} + {list.name} + {/each} +
diff --git a/web/src/routes/search/+server.ts b/web/src/routes/search/+server.ts index 96712e2..b49fd72 100644 --- a/web/src/routes/search/+server.ts +++ b/web/src/routes/search/+server.ts @@ -1,5 +1,5 @@ import { json } from '@sveltejs/kit'; -import type { SearchResult } from '../../ambient.js'; +import type { MovieWithLists, SearchResult } from '../../ambient.js'; import { API_HOST } from '$env/static/private'; const API = process.env.API_HOST || API_HOST || 'http://localhost:4000'; @@ -24,9 +24,18 @@ export const GET = async ({ url, locals, fetch }) => { if (res.status !== 200) { throw new Error(); } - const { tmdb }: SearchResult = await res.json(); + const { tmdb, db }: SearchResult = await res.json(); - return json(tmdb); + const moviesWithLists: MovieWithLists[] = tmdb.map(movie => { + const dbMovie = db.find(m => m.tmdbId === movie.tmdbId); + + return { + ...movie, + lists: dbMovie ? dbMovie.lists.filter(l => l.creatorId === locals.user?.id) : [] + }; + }); + + return json(moviesWithLists); } catch (e) { console.error({ error: e }); } diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 4cce374..d0711ff 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -8,6 +8,7 @@ export default { text: '#f7f7f7', primary: '#999999', secondary: '#1f1f1f', + 'secondary-hover': '#2f2f2f', accent: '#858585', error: '#9e3641', info: '#999999', diff --git a/web/tsconfig.json b/web/tsconfig.json index e3eeb22..abcbe4d 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -9,6 +9,8 @@ "skipLibCheck": true, "sourceMap": true, "strict": true, + "target": "ES2022", + "useDefineForClassFields": true, "plugins": [ { "name": "typescript-svelte-plugin",