diff --git a/MyFirstBlogFrontEnd b/MyFirstBlogFrontEnd
new file mode 160000
index 00000000..90f60a4d
--- /dev/null
+++ b/MyFirstBlogFrontEnd
@@ -0,0 +1 @@
+Subproject commit 90f60a4d53eb486cf6a03cfa30785a6d57ce9313
diff --git a/src/App.js b/src/App.js
new file mode 100644
index 00000000..89570437
--- /dev/null
+++ b/src/App.js
@@ -0,0 +1,15 @@
+import React from 'react';
+import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
+import NewPost from './components/NewPost';
+
+function App() {
+ return (
+
+
+ } />
+
+
+ );
+}
+
+export default App;
\ No newline at end of file
diff --git a/src/components/NewPost.js b/src/components/NewPost.js
new file mode 100644
index 00000000..22035a95
--- /dev/null
+++ b/src/components/NewPost.js
@@ -0,0 +1,64 @@
+import React, { useState } from 'react';
+import axios from 'axios';
+import { useNavigate } from 'react-router-dom';
+
+function NewPost() {
+ const [title, setTitle] = useState('');
+ const [description, setDescription] = useState('');
+ const [errors, setErrors] = useState([]);
+ const navigate = useNavigate();
+
+ const handleSubmit = async (e) => {
+ e.preventDefault();
+ setErrors([]);
+
+ try {
+ const response = await axios.post('http://localhost:8000/posts/', {
+ title,
+ description,
+ });
+
+ const { title: newTitle } = response.data.post;
+ navigate(`/posts/${encodeURIComponent(newTitle)}`);
+ } catch (error) {
+ if (error.response?.data?.errors) {
+ setErrors(error.response.data.errors);
+ } else {
+ setErrors(['Unexpected error occurred']);
+ }
+ }
+ };
+
+ return (
+
+
Create a New Post
+ {errors.length > 0 && (
+
+ {errors.map((err, idx) => - {err}
)}
+
+ )}
+
+
+ );
+}
+
+export default NewPost;
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
new file mode 100644
index 00000000..c760e597
--- /dev/null
+++ b/src/index.js
@@ -0,0 +1,6 @@
+import React from 'react';
+import ReactDOM from 'react-dom/client';
+import App from './App';
+
+const root = ReactDOM.createRoot(document.getElementById('root'));
+root.render();
\ No newline at end of file