Initial Commit
This commit is contained in:
commit
c3bdd1d0ff
26
.gitignore
vendored
Normal file
26
.gitignore
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
|
||||
.env
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
10
README.md
Normal file
10
README.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Assignment: Movie Search App
|
||||
### Objective:
|
||||
##### Build a movie search application using an API like OMDB API (https://www.omdbapi.com/).
|
||||
### Requirements:
|
||||
- Use React.js and fetch movie data based on user input.
|
||||
- Display movie title, poster, and ratings.
|
||||
- Implement a search bar for searching movies.
|
||||
### Bonus Points:
|
||||
- Add a favorites list where users can save movies.
|
||||
- Implement a loading spinner while fetching data.
|
38
eslint.config.js
Normal file
38
eslint.config.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import react from 'eslint-plugin-react'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
|
||||
export default [
|
||||
{ ignores: ['dist'] },
|
||||
{
|
||||
files: ['**/*.{js,jsx}'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
ecmaFeatures: { jsx: true },
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
settings: { react: { version: '18.3' } },
|
||||
plugins: {
|
||||
react,
|
||||
'react-hooks': reactHooks,
|
||||
'react-refresh': reactRefresh,
|
||||
},
|
||||
rules: {
|
||||
...js.configs.recommended.rules,
|
||||
...react.configs.recommended.rules,
|
||||
...react.configs['jsx-runtime'].rules,
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'react/jsx-no-target-blank': 'off',
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
13
index.html
Normal file
13
index.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + React</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
6522
package-lock.json
generated
Normal file
6522
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
36
package.json
Normal file
36
package.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "assignment--movie-search-app",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.0",
|
||||
"@mui/material": "^6.3.1",
|
||||
"axios": "^1.7.9",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-router-dom": "^7.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.17.0",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.17.0",
|
||||
"eslint-plugin-react": "^7.37.2",
|
||||
"eslint-plugin-react-hooks": "^5.0.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.16",
|
||||
"globals": "^15.14.0",
|
||||
"postcss": "^8.4.49",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"vite": "^6.0.5"
|
||||
}
|
||||
}
|
8
postcss.config.js
Normal file
8
postcss.config.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
// postcss.config.js (as ES module)
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
1
public/vite.svg
Normal file
1
public/vite.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
After Width: | Height: | Size: 1.5 KiB |
13
src/App.jsx
Normal file
13
src/App.jsx
Normal file
|
@ -0,0 +1,13 @@
|
|||
import React from 'react'
|
||||
import { Route, Routes } from 'react-router-dom'
|
||||
import MainLayout from './layouts/MainLayout'
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/" element={<MainLayout />} />
|
||||
</Routes>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
35
src/components/Footer.jsx
Normal file
35
src/components/Footer.jsx
Normal file
|
@ -0,0 +1,35 @@
|
|||
import React from "react";
|
||||
|
||||
const Footer = () => {
|
||||
return (
|
||||
<footer className="bg-secondary text-white py-6">
|
||||
<div className="container mx-auto text-center">
|
||||
<p className="text-sm">
|
||||
© 2025 Movie Search App. All rights reserved.
|
||||
</p>
|
||||
<div className="mt-4">
|
||||
<a
|
||||
href="/about"
|
||||
className="text-primary hover:text-white px-4"
|
||||
>
|
||||
About
|
||||
</a>
|
||||
<a
|
||||
href="/contact"
|
||||
className="text-primary hover:text-white px-4"
|
||||
>
|
||||
Contact
|
||||
</a>
|
||||
<a
|
||||
href="/privacy"
|
||||
className="text-primary hover:text-white px-4"
|
||||
>
|
||||
Privacy Policy
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Footer;
|
11
src/components/Header.jsx
Normal file
11
src/components/Header.jsx
Normal file
|
@ -0,0 +1,11 @@
|
|||
import React from 'react'
|
||||
|
||||
const Header = () => {
|
||||
return (
|
||||
<header className="fixed w-full h-[5vh] py-3 px-6 bg-secondary">
|
||||
<a href="/">DigiFlix</a>
|
||||
</header>
|
||||
)
|
||||
};
|
||||
|
||||
export default Header;
|
26
src/hooks/useFetch.jsx
Normal file
26
src/hooks/useFetch.jsx
Normal file
|
@ -0,0 +1,26 @@
|
|||
import axios from "axios";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
const useFetch = ({ url }) => {
|
||||
const [data, setData] = useState({});
|
||||
// const [error, setError] = useState("");
|
||||
useEffect(() => {
|
||||
const fetch = async () => {
|
||||
let response;
|
||||
try {
|
||||
response = await axios.get(url);
|
||||
console.log("USEFETCH:",response)
|
||||
setData(response);
|
||||
} catch {
|
||||
console.log("Error in useFetch: ");
|
||||
return "Error Fetching Data";
|
||||
}
|
||||
};
|
||||
fetch();
|
||||
}, [url]);
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
|
||||
export default useFetch;
|
3
src/index.css
Normal file
3
src/index.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
19
src/layouts/MainLayout.jsx
Normal file
19
src/layouts/MainLayout.jsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import React from "react";
|
||||
import Header from "../components/Header";
|
||||
import Footer from "../components/Footer";
|
||||
import { Routes, Route } from "react-router-dom";
|
||||
import HomePage from "../pages/HomePage";
|
||||
|
||||
const MainLayout = () => {
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<Routes>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
</Routes>
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default MainLayout;
|
10
src/main.jsx
Normal file
10
src/main.jsx
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { createRoot } from "react-dom/client";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import "./index.css";
|
||||
import App from "./App.jsx";
|
||||
|
||||
createRoot(document.getElementById("root")).render(
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
);
|
39
src/pages/HomePage.jsx
Normal file
39
src/pages/HomePage.jsx
Normal file
|
@ -0,0 +1,39 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import useFetch from "../hooks/useFetch";
|
||||
|
||||
const HomePage = () => {
|
||||
const [inputValue, setInputValue] = useState("")
|
||||
const [searchValue, setSearchValue] = useState("")
|
||||
|
||||
const url = import.meta.env.VITE_BASE_URL;
|
||||
console.log("URL =", `${url}s=${searchValue}`)
|
||||
const data = useFetch(`${url}s=${searchValue}`);
|
||||
|
||||
// console.log("DATA = ", data)
|
||||
|
||||
const handleSearch = (event) => {
|
||||
event.preventDefault();
|
||||
setSearchValue(inputValue);
|
||||
};
|
||||
return (
|
||||
<div className=" min-h-[90vh] w-full pt-[10vh] bg-primary flex justify-center">
|
||||
<div>
|
||||
<form className="">
|
||||
<input
|
||||
type="text"
|
||||
name="search"
|
||||
id="search"
|
||||
value={inputValue}
|
||||
onChange={(event) => setInputValue(event?.target?.value)}
|
||||
className="p-1 text-quadnary bg-primary rounded outline-none border border-ternary"
|
||||
/>
|
||||
<button type="button" className="text-quadnary" onClick={handleSearch}>
|
||||
Search
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default HomePage;
|
13
tailwind.config.js
Normal file
13
tailwind.config.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
export default {
|
||||
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
||||
theme: {
|
||||
colors: {
|
||||
primary: "#191A19",
|
||||
secondary: "#1E5128",
|
||||
ternary: "#4E9F3D",
|
||||
quadnary: "#D8E9A8",
|
||||
},
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
7
vite.config.js
Normal file
7
vite.config.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
Loading…
Reference in a new issue