diff --git a/db.json b/db.json
index 6dff256..cbd9977 100644
--- a/db.json
+++ b/db.json
@@ -1,12 +1,115 @@
{
- "user": {
- "id": 1,
- "name": "Anup",
- "email": "anup.singh@gmail.com",
- "password": "123123123",
- "profilePhoto": "",
- "phonme": "98181311488"
- },
+ "user": [
+ {
+ "name": "Niraj yadav",
+ "phone": "8102162627",
+ "email": "Niraj@gamil.com",
+ "password": "123456",
+ "profilePhoto": {
+ "0": {}
+ },
+ "id": "11ad4790-33bb-4fb1-84e1-c2d3dbfcedd5"
+ },
+ {
+ "name": "vikash",
+ "phone": "8102162627",
+ "email": "Rupesh@gamil.com",
+ "password": "123123123",
+ "profilePhoto": {
+ "0": {}
+ },
+ "id": "8d62203a-2e0f-45bf-b0b0-094da9d78758"
+ },
+ {
+ "name": "md maaz",
+ "phone": "08102162627",
+ "email": "Maa12@gmail.com",
+ "password": "123456",
+ "profilePhoto": {
+ "0": {}
+ },
+ "id": "b733170b-039c-44e8-8561-964d7b4cd986"
+ },
+ {
+ "name": "Anup",
+ "phone": "12312313",
+ "email": "anup.singh2071@gmail.com",
+ "password": "12312313",
+ "profilePhoto": {
+ "0": {}
+ },
+ "id": "a615e268-bd88-4f70-a9c6-822d92261cf5"
+ },
+ {
+ "name": "Anup Kumar Singh",
+ "phone": "699999",
+ "email": "anup.singh71@gmail.com",
+ "password": "123123123",
+ "profilePhoto": {
+ "0": {}
+ },
+ "id": "d2100bb1-009e-4ea3-b92a-66fb440987d1"
+ }
+ ],
+ "blog": [
+ {
+ "id": 1,
+ "user_id": 12,
+ "title": "Art",
+ "description": "User Interface Designer",
+ "location": "New York",
+ "workType": "Full-Time",
+ "createdAt": "2h ago"
+ },
+ {
+ "title": "Finance",
+ "description": "Upgrade your finacial score",
+ "location": "Gremany",
+ "workType": "Full Time",
+ "createdAt": "09:12",
+ "id": "047d6e54-4d0e-4c00-a895-9036f522c7ce"
+ },
+ {
+ "title": "Medical",
+ "description": "Medical Science",
+ "location": "India",
+ "workType": "Part Time",
+ "createdAt": "09:16",
+ "id": "327198a3-088d-47c5-a536-5a708a6d04cf"
+ },
+ {
+ "title": "Marketing",
+ "description": "Markeing experience",
+ "location": "Norway",
+ "workType": "Full Time",
+ "createdAt": "21:17",
+ "id": "27f45704-b9aa-464b-911a-e0170d2045cb"
+ },
+ {
+ "title": "sports",
+ "description": "cricket",
+ "location": "Banglore ",
+ "workType": "Full Time",
+ "createdAt": "20:49",
+ "id": "a4d03cfb-b51e-4287-aebc-f9f956adf8f1"
+ },
+ {
+ "title": "Java Developer",
+ "description": "FullStack Java Developer",
+ "location": "INdia",
+ "workType": "Full Time",
+ "createdAt": "07:32",
+ "id": "e41fbadc-7fef-4c18-bd1c-cfef262cfc74"
+ },
+ {
+ "title": "Sports",
+ "description": "Football",
+ "location": "India",
+ "workType": "Full Time",
+ "createdAt": "16:06",
+ "id": "14a3f625-9386-4e78-a200-9f2ac9973afe"
+ }
+ ],
"employees": [
{
"_id": 1,
diff --git a/src/api/auth.js b/src/api/auth.js
index 7cd561b..2d018f0 100644
--- a/src/api/auth.js
+++ b/src/api/auth.js
@@ -6,8 +6,12 @@ class AuthApi {
return axios.get(`/user/`, params)
}
- static signup = (params) => {
- return axios.post(`/user/`, params)
+ static signup = (data) => {
+ return axios({
+ method: 'post',
+ url: `${BASE_URL}/user`,
+ data: data
+ })
}
static createBlog = (blog) => {
@@ -18,23 +22,19 @@ class AuthApi {
})
}
- static getBlog = (blog) => {
- return axios.get(`${BASE_URL}/blog`, blog)
+ static getBlog = (blog, page=1, limit=10) => {
+ return axios.get(`${BASE_URL}/blog?_page=${page}&_limit=${limit}`, blog)
}
static signin = (data) => {
return axios.post(`${base}/auth/signin`,data)
}
-
static Register = (data) => {
return axios.post(`${base}/register`, data);
};
-
static Logout = (data) => {
return axios.post(`${base}/logout`, data, { headers: { Authorization: `${data.token}` } });
};
}
-
let base = "users";
-
-export default AuthApi;
+export default AuthApi;
\ No newline at end of file
diff --git a/src/api/profile .js b/src/api/profile .js
new file mode 100644
index 0000000..2357d59
--- /dev/null
+++ b/src/api/profile .js
@@ -0,0 +1,10 @@
+import axios from "./index";
+
+class ProfileApi {
+
+ static edit = (id, body) => {
+ return axios.put(`/user/${id}`, body)
+ }
+}
+
+export default ProfileApi;
\ No newline at end of file
diff --git a/src/components/Button.js b/src/components/Button.js
deleted file mode 100644
index e69de29..0000000
diff --git a/src/components/fields/Button.js b/src/components/fields/Button.js
index 690c467..27c761a 100644
--- a/src/components/fields/Button.js
+++ b/src/components/fields/Button.js
@@ -5,11 +5,11 @@ const Button = (props) => {
props;
return (
);
};
diff --git a/src/config/url.js b/src/config/url.js
index 1d2c9ec..6cea4c4 100644
--- a/src/config/url.js
+++ b/src/config/url.js
@@ -10,5 +10,6 @@ const PROFILE_URL = '/profile';
// Auth
const LOGIN_URL = '/login';
+const SIGNUP_URL = '/signup';
-export {ROOT_URL, EMPLOYEE_FORM, EMPLOYEE_LIST_URL, LOGIN_URL, FEED_URL, PROFILE_URL};
\ No newline at end of file
+export {ROOT_URL, EMPLOYEE_FORM, EMPLOYEE_LIST_URL, LOGIN_URL, FEED_URL, PROFILE_URL, SIGNUP_URL};
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index 613079a..13c392a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -5,6 +5,8 @@ import App from "./App";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import Feed from "./views/feed";
import Login from "./views/auth/Login";
+import Signup from "./views/auth/Signup/index";
+import CreateBlog from "./views/feed/CreateBlog"
import Dashboard from "./views/dashboard";
import EmployeeForm from "./views/employees/Form";
import { Profile } from "./views/employees/Profile";
@@ -38,6 +40,8 @@ root.render(
} />
} />
} />
+ } />
+ } />
diff --git a/src/views/auth/Login/Form.js b/src/views/auth/Login/Form.js
index 52ddb47..a870018 100644
--- a/src/views/auth/Login/Form.js
+++ b/src/views/auth/Login/Form.js
@@ -3,10 +3,10 @@ import { useForm } from "react-hook-form";
import AuthApi from "../../../api/auth";
import Swal from "sweetalert2";
import { useAuth } from "../../../context/AuthProvider";
-import { useNavigate } from "react-router-dom";
-import Button from "../../../components/fields/Button";
+import { useNavigate, Link } from "react-router-dom";
import { PROFILE_URL } from "../../../config/url";
import InputField from "../../../components/fields/InputField";
+import Button from "../../../components/fields/Button";
const LoginForm = () => {
const {
@@ -17,22 +17,25 @@ const LoginForm = () => {
const { user, setUser } = useAuth();
const navigate = useNavigate();
- useEffect(() => {
- if (user) {
- console.log("user", user);
- navigate(PROFILE_URL);
- }
- }, [user]);
+ // useEffect(() => {
+ // if (user) {
+ // console.log("user", user);
+ // // navigate(PROFILE_URL);
+ // }
+ // }, [user]);
+
+
const onSubmit = (data) => {
// setUser(data);
- console.log("user =---->", JSON.stringify(data));
+ localStorage.setItem("user =---->", JSON.stringify(data));
- // call an API to login
+ // call an API to login
// when api gives success response, navigate to root url
- AuthApi.login(data).then((result) => {
- console.log("signin -> ", result);
+ AuthApi.login(data).then((result) => {
+ console.log("signin -> ", result);
if (result.status === 200) {
+ navigate(PROFILE_URL);
Swal.fire({
timer: 1500,
showConfirmButton: false,
@@ -105,7 +108,6 @@ const LoginForm = () => {
}}
placeholder="Password"
errors={errors}
- required
/>
@@ -113,13 +115,21 @@ const LoginForm = () => {
Forgot password?
-