diff --git a/src/App.tsx b/src/App.tsx
index 34be670b0..d61da61a1 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -2,15 +2,22 @@ import './App.scss';
import { MoviesList } from './components/MoviesList';
import { NewMovie } from './components/NewMovie';
import moviesFromServer from './api/movies.json';
+import { useState } from 'react';
export const App = () => {
+ const [movies, setMovies] = useState(moviesFromServer);
+
return (
-
+
- {}} */ />
+ {
+ setMovies(prevMovies => [...prevMovies, newMovie]);
+ }}
+ />
);
diff --git a/src/components/NewMovie/NewMovie.tsx b/src/components/NewMovie/NewMovie.tsx
index 85bace9dd..323327220 100644
--- a/src/components/NewMovie/NewMovie.tsx
+++ b/src/components/NewMovie/NewMovie.tsx
@@ -1,30 +1,91 @@
import { useState } from 'react';
import { TextField } from '../TextField';
+import { Movie } from '../../types/Movie';
-export const NewMovie = () => {
+type Props = {
+ onAdd: (newMovie: Movie) => void;
+};
+
+export const NewMovie: React.FC = ({ onAdd }) => {
// Increase the count after successful form submission
// to reset touched status of all the `Field`s
- const [count] = useState(0);
+ const [count, setCount] = useState(0);
+ const [title, setTitle] = useState('');
+ const [description, setDescription] = useState('');
+ const [imageUrl, setImageUrl] = useState('');
+ const [imdbUrl, setImdbUrl] = useState('');
+ const [imdbId, setImdbId] = useState('');
+
+ const handleResetForm = () => {
+ setCount(prevKey => prevKey + 1); // оновлюємо ключ для реініціалізації
+ setTitle('');
+ setDescription('');
+ setImageUrl('');
+ setImdbUrl('');
+ setImdbId('');
+ };
+
+ const isFormValid = [title, description, imageUrl, imdbUrl, imdbId].every(
+ value => value.trim() !== '',
+ );
return (
-