43 | )
44 | }
45 |
46 | export default MovieList;
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | My Movies App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/api/movies.json:
--------------------------------------------------------------------------------
1 | {
2 | "movies": [
3 | {
4 | "name": "The Matrix 3",
5 | "rating": "8.1",
6 | "overview": "Set in the 22nd century, The Matrix tells the story of a computer hacker who joins a group of underground insurgents fighting the vast and powerful computers who now rule the earth.",
7 | "imageURL": "https://image.tmdb.org/t/p/w600_and_h900_bestv2/dXNAPwY7VrqMAo51EKhhCJfaGb5.jpg",
8 | "id": 7
9 | },
10 | {
11 | "name": "The Matrix Reloaded",
12 | "rating": "6.9",
13 | "imageURL": "https://image.tmdb.org/t/p/w600_and_h900_bestv2/jBegA6V243J6HUnpcOILsRvBnGb.jpg",
14 | "overview": "Six months after the events depicted in The Matrix, Neo has proved to be a good omen for the free humans, as more and more humans are being freed from the matrix and brought to Zion, the one and only stronghold of the Resistance. Neo himself has discovered his superpowers including super speed, ability to see the codes of the things inside the matrix and a certain degree of pre-cognition.",
15 | "id": 8
16 | },
17 | {
18 | "name": "Saw 3D",
19 | "rating": "7.5",
20 | "overview": "SAW legacy, a group of Jigsaw survivors gathers to seek the support of self-help guru and fellow survivor Bobby Dagen, a man whose own dark secrets unleash a new wave of terror.",
21 | "imageURL": "https://image.tmdb.org/t/p/w600_and_h900_bestv2/qHCZ6LjtmqWDfXXN28TlIC9OppK.jpg",
22 | "id": 11
23 | },
24 | {
25 | "name": "Blitz 007",
26 | "rating": "11",
27 | "overview": "A tough, renegade cop with a gay sidekick is dispatched to take down a serial killer who has been targeting police officers. AÇIKLAMA AÇIKLAMA",
28 | "imageURL": "https://image.tmdb.org/t/p/w600_and_h900_bestv2/qCPMjT8Ld8tvs1zs7LY2jpKlRIK.jpg",
29 | "id": 12
30 | },
31 | {
32 | "name": "Hostage",
33 | "rating": "6.3",
34 | "imageURL": "https://image.tmdb.org/t/p/w600_and_h900_bestv2/4hne3v6jN4MlCnhSkxOW7YspJhr.jpg",
35 | "overview": "When a mafia accountant is taken hostage on his beat, a police officer – wracked by guilt from a prior stint as a negotiator – must negotiate the standoff, even as his own family is held captive by the mob.",
36 | "id": 13
37 | }
38 | ]
39 | }
--------------------------------------------------------------------------------
/src/components/AddMovie.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import serialize from 'form-serialize';
3 |
4 | class AddMovie extends React.Component {
5 |
6 | handleFormSubmit = (e) => {
7 | e.preventDefault();
8 | const newMovie = serialize(e.target, { hash: true });
9 | //console.log(newMovie);
10 | this.props.onAddMovie(newMovie);
11 | }
12 |
13 |
14 | render() {
15 |
16 | return (
17 |
18 |
54 |
55 | )
56 |
57 | }
58 | }
59 |
60 |
61 | export default AddMovie;
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `npm start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `npm test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `npm run build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `npm run eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `npm run build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/src/components/App.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import MovieList from './MovieList';
3 | import SearchBar from './SearchBar';
4 | import AddMovie from './AddMovie';
5 | import EditMovie from './EditMovie';
6 | import axios from 'axios';
7 | import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
8 |
9 | class App extends React.Component {
10 |
11 | state = {
12 | movies: [],
13 | searchQuery: ""
14 | }
15 |
16 | componentDidMount() {
17 | this.getMovies();
18 | }
19 |
20 | async getMovies() {
21 | const response = await axios.get("http://localhost:3002/movies");
22 | this.setState({ movies: response.data })
23 | }
24 |
25 |
26 |
27 |
28 | // DELETE MOVIE
29 | deleteMovie = async (movie) => {
30 |
31 | axios.delete(`http://localhost:3002/movies/${movie.id}`)
32 | const newMovieList = this.state.movies.filter(
33 | m => m.id !== movie.id
34 | );
35 | this.setState(state => ({
36 | movies: newMovieList
37 | }))
38 | }
39 |
40 |
41 | // SEARCH MOVIE
42 | searchMovie = (event) => {
43 | this.setState({ searchQuery: event.target.value })
44 | }
45 |
46 |
47 | // ADD MOVIE
48 | addMovie = async (movie) => {
49 | await axios.post(`http://localhost:3002/movies/`, movie)
50 | this.setState(state => ({
51 | movies: state.movies.concat([movie])
52 | }))
53 |
54 | this.getMovies();
55 | }
56 |
57 | // EDIT MOVIE
58 | editMovie = async (id, updatedMovie) => {
59 | await axios.put(`http://localhost:3002/movies/${id}`, updatedMovie)
60 | this.getMovies();
61 | }
62 |
63 | render() {
64 |
65 | let filteredMovies = this.state.movies.filter(
66 | (movie) => {
67 | return movie.name.toLowerCase().indexOf(this.state.searchQuery.toLowerCase()) !== -1
68 | }
69 | ).sort((a, b) => {
70 | return a.id < b.id ? 1 : a.id > b.id ? -1 : 0;
71 | });
72 |
73 | return (
74 |
75 |
76 |