Skip to content

Commit

Permalink
fix: profile page fixed #339
Browse files Browse the repository at this point in the history
profile page 404 fixed
  • Loading branch information
jasirtp committed Nov 4, 2021
1 parent 161b45b commit 512e964
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion component/profile/ProfileDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function ProfileDetails({ userData }) {
<div className="relative">
<div className="rounded-full h-24 w-24 bg-blue-200 overflow-hidden">
<Image
src={userData.avatar}
src={userData.avatar === null ? '/images/svgs/avatar.svg' : userData.avatar }
alt="avatar"
className="rounded-full h-24 w-24"
layout="fill"
Expand Down
27 changes: 14 additions & 13 deletions pages/u/[username].js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ export async function getServerSideProps(context) {
let isThisUserTheCurrentLoggedIn = false;
const LIMIT = 10; //should be 10
const CLICK_N0 = 0;
const { data } = await UserService.getUserByUsername(username);
const data = await UserService.getUserByUsername(username);
const userId = data.id;
const response = await PostService.getPublishedPostsByUserId(
userId,
LIMIT,
CLICK_N0
);
console.log(data,'error')
// const response = await PostService.getPublishedPostsByUserId(
// userId,
// LIMIT,
// CLICK_N0
// );
/**
* isThisUserTheCurrentLoggedIn is used to show/hide the edit icon
* in the profile details section
Expand All @@ -48,20 +49,20 @@ export async function getServerSideProps(context) {
}
return {
props: {
userData: data,
userData: data.data,
postsCount: {},
posts: response,
limit: LIMIT,
posts: {},
limit: {},
}
};
} catch (err) {
//Redirect to 404 page if there is any kind of error
// console.log(err);
return {
redirect: {
permanent: false,
destination: "/404"
}
// redirect: {
// permanent: false,
// destination: "/404"
// }
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/UserService.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function getLatestUsers(reqParams) {

//Api call for fetching userdetails
async function getUserByUsername(username) {
let url = getUrl();
// let url = getUrl();

try {
const { data } = await axios.get(
Expand Down

0 comments on commit 512e964

Please sign in to comment.