diff --git a/src/App.vue b/src/App.vue
index 5c94d15..380075c 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,6 +1,7 @@
@@ -55,7 +56,7 @@
- Search
+
diff --git a/src/components/Loader.vue b/src/components/Loader.vue
new file mode 100644
index 0000000..8c2f4e8
--- /dev/null
+++ b/src/components/Loader.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
diff --git a/src/components/Movie.vue b/src/components/Movie.vue
index 94303f6..c09f988 100644
--- a/src/components/Movie.vue
+++ b/src/components/Movie.vue
@@ -11,7 +11,7 @@
{{ movie.overview }}
-
-
+
diff --git a/src/components/Search.vue b/src/components/Search.vue
new file mode 100644
index 0000000..8aa7d6b
--- /dev/null
+++ b/src/components/Search.vue
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/stores/movie-store.js b/src/stores/movie-store.js
index 73f1cf9..22a4df4 100644
--- a/src/stores/movie-store.js
+++ b/src/stores/movie-store.js
@@ -2,26 +2,7 @@ import { defineStore } from 'pinia';
export const useMovieStore = defineStore('movieStore', {
state: () => ({
- movies: [
- {
- id: 1,
- original_title: "Spider-Man",
- overview:
- "After being bitten by a genetically altered spider at Oscorp, nerdy but endearing high school student Peter Parker is endowed with amazing powers to become the superhero known as Spider-Man.",
- poster_path: "/gh4cZbhZxyTbgxQPxD0dOudNPTn.jpg",
- release_date: "2002-05-01",
- isWatched: false,
- },
- {
- id: 2,
- original_title: "The Batman",
- overview:
- "In his second year of fighting crime, Batman uncovers corruption in Gotham City that connects to his own family while facing a serial killer known as the Riddler.",
- poster_path: "/b0PlSFdDwbyK0cf5RxwDpaOJQvQ.jpg",
- release_date: "2022-03-01",
- isWatched: true,
- },
- ],
+ movies: [],
activeTab: 1,
}),
getters: {
diff --git a/src/stores/search-store.js b/src/stores/search-store.js
new file mode 100644
index 0000000..835f158
--- /dev/null
+++ b/src/stores/search-store.js
@@ -0,0 +1,37 @@
+import { defineStore } from 'pinia';
+import { useMovieStore } from './movie-store.js';
+
+const url = `https:api.themoviedb.org/3/search/movie?api_key=${import.meta.env.VITE_API_KEY}&query=`;
+
+export const useSearchStore = defineStore('search-store', {
+ state: () => ({
+ movies: [],
+ timer: null,
+ loading: false,
+ }),
+ actions: {
+ async getMovies(search) {
+ const request = async () => {
+ const res = await fetch(url + search);
+ const data = await res.json();
+
+ this.movies = data.results
+ }
+
+ try {
+ clearTimeout(this.timer);
+ this.loading = true;
+ await request();
+ } catch (e) {
+ console.log('error', e);
+ } finally {
+ this.loading = false;
+ }
+ },
+ addToUserMovies(obj) {
+ const movieStore = useMovieStore();
+ movieStore.movies.push(obj);
+ movieStore.setActiveTab(1);
+ }
+ }
+})