moved to vite
This commit is contained in:
@@ -121,6 +121,7 @@ export const addPost =
|
||||
(formData: { text: string }): AppThunk =>
|
||||
async (dispatch) => {
|
||||
try {
|
||||
console.log(1);
|
||||
const res = await api.post("/posts", formData);
|
||||
|
||||
dispatch(addPostAction(res.data));
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Box, Typography } from "@mui/material";
|
||||
|
||||
const Education = ({ education }: { education: EducationType[] }) => {
|
||||
const dispatch = useAppDispatch();
|
||||
if (!education) return <></>;
|
||||
const educations = education.map((edu) => (
|
||||
<tr key={edu._id}>
|
||||
<td>{edu.school}</td>
|
||||
@@ -35,7 +36,7 @@ const Education = ({ education }: { education: EducationType[] }) => {
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Typography variant='h5'>Education Credentials</Typography>
|
||||
<Typography variant="h5">Education Credentials</Typography>
|
||||
<table className="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useAppDispatch } from "../../utils/hooks";
|
||||
|
||||
const Experience = ({ experience }: { experience: ExperienceType[] }) => {
|
||||
const dispatch = useAppDispatch();
|
||||
if (!experience) return <></>;
|
||||
const experiences = experience.map((exp) => (
|
||||
<tr key={exp._id}>
|
||||
<td>{exp.company}</td>
|
||||
@@ -27,7 +28,9 @@ const Experience = ({ experience }: { experience: ExperienceType[] }) => {
|
||||
|
||||
if (experiences.length === 0)
|
||||
return (
|
||||
<Typography variant="h5">You have no experiences, consider adding some.</Typography>
|
||||
<Typography variant="h5">
|
||||
You have no experiences, consider adding some.
|
||||
</Typography>
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -127,7 +127,7 @@ const Navbar = () => {
|
||||
}}
|
||||
>
|
||||
{isAuthenticated ? (
|
||||
<>
|
||||
<div>
|
||||
{" "}
|
||||
{authLinks.map((el) => (
|
||||
<MenuItem
|
||||
@@ -149,7 +149,7 @@ const Navbar = () => {
|
||||
</a>
|
||||
</MenuItem>
|
||||
,
|
||||
</>
|
||||
</div>
|
||||
) : (
|
||||
guestLinks.map((el) => (
|
||||
<MenuItem
|
||||
|
||||
@@ -14,8 +14,9 @@ const PostForm = () => {
|
||||
display="flex"
|
||||
gap="1rem"
|
||||
noValidate
|
||||
sx={{ mt: 3,mb:3 }}
|
||||
sx={{ mt: 3, mb: 3 }}
|
||||
onSubmit={async (e) => {
|
||||
console.log(1);
|
||||
e.preventDefault();
|
||||
await dispatch(addPost({ text }));
|
||||
setText("");
|
||||
@@ -26,9 +27,9 @@ const PostForm = () => {
|
||||
label="Create a post"
|
||||
fullWidth
|
||||
value={text}
|
||||
onChange={(e)=> setText(e.target.value)}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
multiline
|
||||
rows={3}
|
||||
rows={3}
|
||||
required
|
||||
/>
|
||||
<Button variant="contained">Submit</Button>
|
||||
|
||||
@@ -14,15 +14,20 @@ const Posts = () => {
|
||||
fetchData();
|
||||
}, [dispatch]);
|
||||
const posts = useAppSelector((state) => state.post.posts);
|
||||
if (!posts) return <></>;
|
||||
|
||||
return (
|
||||
<Container maxWidth="sm">
|
||||
<Typography variant="h3">Posts</Typography>
|
||||
<Typography variant='h4'>Welcome to the community</Typography>
|
||||
<Typography variant="h4">Welcome to the community</Typography>
|
||||
<PostForm />
|
||||
{posts.map((post) => (
|
||||
<PostItem key={post._id} post={post} />
|
||||
))}
|
||||
<Box>
|
||||
{posts.length > 0 && Array.isArray(posts) ? (
|
||||
posts.map((post) => <PostItem key={post._id} post={post} />)
|
||||
) : (
|
||||
<Typography>No posts found...</Typography>
|
||||
)}
|
||||
</Box>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ const Profiles = () => {
|
||||
Browse and connect with developers
|
||||
</Typography>
|
||||
<Box>
|
||||
{profiles.length > 0 ? (
|
||||
{profiles.length > 0 && Array.isArray(profiles) ? (
|
||||
profiles.map((profile) => (
|
||||
<ProfileItem key={profile._id} profile={profile} />
|
||||
))
|
||||
|
||||
@@ -2,7 +2,7 @@ import axios from "axios";
|
||||
import store from "../store";
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: "/api",
|
||||
baseURL: "http://localhost:5000/api",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user