diff --git a/package-lock.json b/package-lock.json
index 110a876..b297ae6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11,9 +11,10 @@
"@reduxjs/toolkit": "^1.9.5",
"axios": "^1.4.0",
"formik": "^2.2.9",
+ "js-cookie": "^3.0.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "react-icons": "^4.8.0",
+ "react-icons": "^4.10.1",
"react-redux": "^8.0.5",
"react-router-dom": "^6.12.1",
"yup": "^1.1.1"
@@ -2807,6 +2808,14 @@
"jiti": "bin/jiti.js"
}
},
+ "node_modules/js-cookie": {
+ "version": "3.0.5",
+ "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
+ "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==",
+ "engines": {
+ "node": ">=14"
+ }
+ },
"node_modules/js-sdsl": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz",
@@ -3568,9 +3577,9 @@
"integrity": "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw=="
},
"node_modules/react-icons": {
- "version": "4.8.0",
- "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.8.0.tgz",
- "integrity": "sha512-N6+kOLcihDiAnj5Czu637waJqSnwlMNROzVZMhfX68V/9bu9qHaMIJC4UdozWoOk57gahFCNHwVvWzm0MTzRjg==",
+ "version": "4.10.1",
+ "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.10.1.tgz",
+ "integrity": "sha512-/ngzDP/77tlCfqthiiGNZeYFACw85fUjZtLbedmJ5DTlNDIwETxhwBzdOJ21zj4iJdvc0J3y7yOsX3PpxAJzrw==",
"peerDependencies": {
"react": "*"
}
@@ -6345,6 +6354,11 @@
"integrity": "sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==",
"dev": true
},
+ "js-cookie": {
+ "version": "3.0.5",
+ "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
+ "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw=="
+ },
"js-sdsl": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz",
@@ -6866,9 +6880,9 @@
"integrity": "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw=="
},
"react-icons": {
- "version": "4.8.0",
- "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.8.0.tgz",
- "integrity": "sha512-N6+kOLcihDiAnj5Czu637waJqSnwlMNROzVZMhfX68V/9bu9qHaMIJC4UdozWoOk57gahFCNHwVvWzm0MTzRjg==",
+ "version": "4.10.1",
+ "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.10.1.tgz",
+ "integrity": "sha512-/ngzDP/77tlCfqthiiGNZeYFACw85fUjZtLbedmJ5DTlNDIwETxhwBzdOJ21zj4iJdvc0J3y7yOsX3PpxAJzrw==",
"requires": {}
},
"react-is": {
diff --git a/package.json b/package.json
index d09831c..d680c13 100644
--- a/package.json
+++ b/package.json
@@ -13,9 +13,10 @@
"@reduxjs/toolkit": "^1.9.5",
"axios": "^1.4.0",
"formik": "^2.2.9",
+ "js-cookie": "^3.0.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "react-icons": "^4.8.0",
+ "react-icons": "^4.10.1",
"react-redux": "^8.0.5",
"react-router-dom": "^6.12.1",
"yup": "^1.1.1"
diff --git a/src/App.jsx b/src/App.jsx
index ac54132..de40eb7 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,27 +1,16 @@
-import AddNote from "./components/AddNote";
-import Notes from "./components/Notes";
-import EditNote from "./components/EditNote";
-import { Routes, Route } from "react-router-dom";
+// import { Route, Routes } from "react-router-dom";
+import Home from "./components/Home";
+// import Notes from "./components/Notes";
+// import AddNote from "./components/AddNote";
+// import EditNote from "./components/EditNote";
+// import Login from "./Auth/Login";
+// import Register from "./Auth/Register";
function App() {
return (
-
-
-
My Notes
-
- {window.location.pathname === "/" && (
- } />
- ) } else {
- } />
- }
-
-
-
-
-
-
+
);
}
diff --git a/src/Auth/Login.jsx b/src/Auth/Login.jsx
new file mode 100644
index 0000000..3e7a7b5
--- /dev/null
+++ b/src/Auth/Login.jsx
@@ -0,0 +1,48 @@
+
+import { ErrorMessage, Field, Form, Formik } from "formik";
+import * as Yup from "yup";
+import { useLoginMutation } from "../store/api/AuthSlice";
+import { useNavigate } from "react-router-dom";
+const Login = () => {
+ const [login] = useLoginMutation();
+ const navigate = useNavigate();
+ const initialValue = {
+ email: '',
+ password: ''
+ }
+ const ValidationSchema = Yup.object({
+ email: Yup.string().required("enter your email "),
+ password: Yup.string().required("enter your password ")
+ })
+ const handleSubmit = (values) => {
+ login({
+ email: values.email,
+ password: values.password
+ }).then(() => {
+ navigate('/')
+ }).catch((err) => {
+ console.log(err)
+ })
+ }
+ return (
+
+ )
+}
+
+export default Login
\ No newline at end of file
diff --git a/src/Auth/Register.jsx b/src/Auth/Register.jsx
new file mode 100644
index 0000000..a7e51e2
--- /dev/null
+++ b/src/Auth/Register.jsx
@@ -0,0 +1,52 @@
+import { ErrorMessage, Field, Form, Formik } from "formik";
+import * as Yup from "yup";
+import { useRegisterMutation } from "../store/api/AuthSlice";
+import { useNavigate } from "react-router-dom";
+const Register = () => {
+ const [register] =useRegisterMutation();
+ const navigate = useNavigate();
+ const initialValue = {
+ name: '',
+ email: '',
+ password : ''
+ }
+ const ValidationSchema = Yup.object({
+ name: Yup.string().required("enter your name "),
+ email: Yup.string().required("enter your email "),
+ password: Yup.string().required("enter your password ")
+ })
+ const handleSubmit = (values) => {
+ console.log(values);
+ register({
+ name: values.name,
+ email: values.email,
+ password : values.password
+ }).then(() => { navigate('/Login')})
+ .catch( (error) => {
+ console.log(error)
+ })
+ }
+ return (
+
+ )
+}
+
+export default Register
\ No newline at end of file
diff --git a/src/BaseQuery.js b/src/BaseQuery.js
new file mode 100644
index 0000000..b839a5d
--- /dev/null
+++ b/src/BaseQuery.js
@@ -0,0 +1,2 @@
+const BaseQuery = "https://notes-60by.onrender.com";
+export default BaseQuery;
\ No newline at end of file
diff --git a/src/assets/avator.png b/src/assets/avator.png
new file mode 100644
index 0000000..85aaea9
Binary files /dev/null and b/src/assets/avator.png differ
diff --git a/src/components/AddNote.jsx b/src/components/AddNote.jsx
index 931f954..9297792 100644
--- a/src/components/AddNote.jsx
+++ b/src/components/AddNote.jsx
@@ -1,74 +1,48 @@
-import React from 'react';
-import { Formik, Form, Field, ErrorMessage } from 'formik';
-import * as Yup from 'yup';
-import { useAddNoteMutation } from '../store/api/NoteSlice';
-
+import { ErrorMessage, Field, Form, Formik } from "formik";
+import * as Yup from "yup";
+import { useAddNotesMutation } from "../store/api/NoteSlice";
+import { useNavigate } from "react-router-dom";
const AddNote = () => {
-
- const [addNote ] = useAddNoteMutation();
-
- const initialValues = {
+ const [addNotes] = useAddNotesMutation();
+ const navigate = useNavigate();
+ const initialValue = {
title: '',
- content: '',
- };
-
- const validationSchema = Yup.object({
- title: Yup.string().required('Title is required'),
- content: Yup.string().required('Content is required'),
- });
-
- const handleSubmit = (values, { resetForm }) => {
- // Send the data to the server (localhost:9000/create_note)
+ content: ''
+ }
+ const ValidationSchema = Yup.object({
+ title: Yup.string().required("enter your title note "),
+ content: Yup.string().required("enter your content note ")
+ })
+ const handleSubmit = (values) => {
console.log(values);
- addNote({
+ addNotes({
title: values.title,
- content: values.content,
- });
-
-
- // Reset the form after submission
- resetForm();
- };
-
+ content: values.content
+ }).then(() => {
+ navigate('/');
+ }).catch((err) => {
+ console.log(err);
+ })
+ }
return (
-