Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Client/src/pages/AgencyForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const AgencyUpload = () => {
console.log(formData);
try {
const response = await fetch(
"https://wandrlust-server.fly.dev/agency/agenciesUpload",
"http://localhost:3000/agency/agenciesUpload",
{
method: "POST",
headers: {
Expand Down
8 changes: 4 additions & 4 deletions Client/src/pages/admin-dashboard/AdminCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function Cards(props) {
const deletePost = async (postId) => {
console.log("Delete post");
console.log(postId);
const res = await fetch(`https://wandrlust-server.fly.dev/admin/delete-post`, {
const res = await fetch(`http://localhost:3000/admin/delete-post`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -32,14 +32,14 @@ export default function Cards(props) {
}
}

const url = `https://wandrlust-server.fly.dev/${props.feed.image}`;
const url = `http://localhost:3000/${props.feed.image}`;

return (
<Card className="py-4" style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: '550px' }}>
<CardHeader className="pb-0 pt-2 px-4 flex-col items-start">
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<div className="flex items-center gap-2">
<img src={`https://wandrlust-server.fly.dev/profileImages/${props.feed.author.profileImage}`} className="rounded-[50%]" height={50} width={50} ></img>
<img src={`http://localhost:3000/profileImages/${props.feed.author.profileImage}`} className="rounded-[50%]" height={50} width={50} ></img>
<p className="font-bold text-xl">{props.feed.author.name}</p>
</div>
<small className="text-default-500">{createdAtIST}</small>
Expand All @@ -50,7 +50,7 @@ export default function Cards(props) {
<Image
alt="Card background"
className="object-cover rounded-xl"
src={`https://wandrlust-server.fly.dev/images/${props.feed.image}`}
src={`http://localhost:3000/images/${props.feed.image}`}
width={400}
style={{ border: '3px solid black' }}
/>
Expand Down
2 changes: 1 addition & 1 deletion Client/src/pages/admin-dashboard/admin-dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function AdminDashboard() {
useEffect(() => {
const getDashboardData = async () => {
setLoading(true);
const res = await fetch("https://wandrlust-server.fly.dev/admin/dashboard", {
const res = await fetch("http://localhost:3000/admin/dashboard", {
method: 'GET',
headers: {
"Content-Type": "application/json",
Expand Down
2 changes: 1 addition & 1 deletion Client/src/pages/admin-dashboard/posts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Posts() {
useEffect(() => {
const getAllPosts = async () => {
setLoadingFeeds(true);
const res = await fetch("https://wandrlust-server.fly.dev/getPhotos", {
const res = await fetch("http://localhost:3000/getPhotos", {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand Down
6 changes: 3 additions & 3 deletions Client/src/pages/admin-dashboard/user_component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Modal from "@mui/material/Modal";
export default function UserComponent({ user, setUsers }) {
const [showModal, setShowModal] = useState(false);
const blockUser = async (userId) => {
const res = await fetch("https://wandrlust-server.fly.dev/admin/block-user", {
const res = await fetch("http://localhost:3000/admin/block-user", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -29,7 +29,7 @@ export default function UserComponent({ user, setUsers }) {
console.log(user);

const unBlockUser = async (userId) => {
const res = await fetch("https://wandrlust-server.fly.dev/admin/unblock-user", {
const res = await fetch("http://localhost:3000/admin/unblock-user", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function UserComponent({ user, setUsers }) {
<img
src={
user.profileImage
? `https://wandrlust-server.fly.dev/profileImages/${user.profileImage}`
? `http://localhost:3000/profileImages/${user.profileImage}`
: "https://www.pngitem.com/pimgs/m/146-1468479_my-profile-icon-blank-profile-picture-circle-hd.png"
}
height={50}
Expand Down
2 changes: 1 addition & 1 deletion Client/src/pages/admin-dashboard/users.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function Users() {

useEffect(() => {
const getAllUsers = async () => {
const res = await fetch("https://wandrlust-server.fly.dev/getAllUsers", {
const res = await fetch("http://localhost:3000/getAllUsers", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
2 changes: 1 addition & 1 deletion Client/src/pages/agency-dashboard/agency-dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Agency = () => {

useEffect(() => {
const getAllAgencies = async () => {
const res = await fetch("https://wandrlust-server.fly.dev/agency/getAllAgency", {
const res = await fetch("http://localhost:3000/agency/getAllAgency", {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand Down
6 changes: 3 additions & 3 deletions Client/src/pages/agency.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Agency = () => {

useEffect(() => {
const getAllAgencies = async () => {
const res = await fetch("https://wandrlust-server.fly.dev/agency/getAllAgency", {
const res = await fetch("http://localhost:3000/agency/getAllAgency", {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand All @@ -28,7 +28,7 @@ const Agency = () => {

const handleEnroll = async (agencyId) => {
console.log(agencyId);
const res = await fetch(`https://wandrlust-server.fly.dev/agency/enroll/${agencyId}`, {
const res = await fetch(`http://localhost:3000/agency/enroll/${agencyId}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -51,7 +51,7 @@ const Agency = () => {

const handleUnEnroll = async (agencyId) => {
console.log(agencyId);
const res = await fetch(`https://wandrlust-server.fly.dev/agency/unenroll/${agencyId}`, {
const res = await fetch(`http://localhost:3000/agency/unenroll/${agencyId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Expand Down
2 changes: 1 addition & 1 deletion Client/src/pages/agencylogin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Signin = () => {
e.preventDefault();
const name = e.target.name.value;
const password = e.target.password.value;
const response = await fetch("https://wandrlust-server.fly.dev/agency/login", {
const response = await fetch("http://localhost:3000/agency/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
2 changes: 1 addition & 1 deletion Client/src/pages/authPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const AuthPage = (props) => {
e.preventDefault();
const { value } = e.target[0];
axios
.post("https://wandrlust-server.fly.dev/authenticate", { username: value })
.post("http://localhost:3000/authenticate", { username: value })
.then((r) => props.onAuth({ ...r.data, secret: value }))
.catch((e) => console.log("Auth Error", e));
};
Expand Down
93 changes: 61 additions & 32 deletions Client/src/pages/cards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,69 +27,100 @@ export default function Cards(props) {
const [comments, setComments] = useState(props.feed.comments);

useEffect(() => {
console.log(props.feed.comments);
setComments(props.feed.comments || []);
if (props.feed.comments) {
setComments(props.feed.comments);
}
}, [props.feed.comments]);

const handleCommentSubmit = async () => {
if (!comment.trim()) {
return; // Don't submit empty comments
}

try {
const res = await fetch(`https://wandrlust-server.fly.dev/comment/${props.feed._id}`, {
const res = await fetch(`http://localhost:3000/comment/${props.feed._id}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ text: comment, userId }),
body: JSON.stringify({
text: comment,
userId
}),
});
if (res.ok) {
const newComment = await res.json();
setComments([...comments, newComment]);
setComment("");
} else {
console.error("Failed to submit comment");

if (!res.ok) {
const errorData = await res.json();
console.error("Comment error:", errorData);
throw new Error(errorData.message || "Failed to submit comment");
}

const newComment = await res.json();
setComments(prevComments => [...prevComments, newComment]);
setComment(""); // Clear the comment input
} catch (error) {
console.error("Error submitting comment:", error);
// You might want to show a toast or error message to the user
}
};

console.log(props.feed.comments);

const url = `https://wandrlust-server.fly.dev/${props.feed.image}`;
const url = `http://localhost:3000/${props.feed.image}`;

const likePost = async (postId) => {
try {
const res = await fetch(`https://wandrlust-server.fly.dev/like/${postId}`, {
const res = await fetch(`http://localhost:3000/like/${postId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId }),
});
if (res.ok) {
props.updateLikeStatus(postId, true);

if (!res.ok) {
const errorData = await res.json();
console.error("Like error:", errorData);
return;
}

const data = await res.json();
props.updateLikeStatus(postId, true);
} catch (error) {
console.error("Error liking post:", error);
}
};

const disLikePost = async (postId) => {
try {
const res = await fetch(`https://wandrlust-server.fly.dev/dislike/${postId}`, {
const res = await fetch(`http://localhost:3000/dislike/${postId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId }),
});
if (res.ok) {
props.updateLikeStatus(postId, false);

if (!res.ok) {
const errorData = await res.json();
console.error("Dislike error:", errorData);
return;
}

const data = await res.json();
props.updateLikeStatus(postId, false);
} catch (error) {
console.error("Error unliking post:", error);
}
};

const author = props.feed.author || {};
const profileImageUrl = author.profileImage
? `http://localhost:3000/profileImages/${author.profileImage}`
: ProfileImage;

console.log('Profile Image URL:', profileImageUrl);

return (
<Card
className="py-4"
Expand All @@ -110,15 +141,13 @@ export default function Cards(props) {
>
<div className="flex items-center gap-2">
<img
src={
props.feed.author?.profileImage
? `https://wandrlust-server.fly.dev/profileImages/${props.feed.author.profileImage}`
: ProfileImage
}
src={profileImageUrl}
alt="Profile"
height={50}
width={50}
></img>
<p className="font-bold text-xl">{props.feed.author.name}</p>
onError={(e) => { e.target.src = ProfileImage; }}
/>
<p className="font-bold text-xl">{author.name || 'Unknown User'}</p>
</div>
<small className="text-default-500">{createdAtIST}</small>
</div>
Expand All @@ -135,7 +164,7 @@ export default function Cards(props) {
<Image
alt="Card background"
className="object-cover rounded-xl"
src={`https://wandrlust-server.fly.dev/images/${props.feed.image}`}
src={`http://localhost:3000/images/${props.feed.image}`}
width={400}
style={{ border: "3px solid black" }}
/>
Expand Down Expand Up @@ -179,23 +208,24 @@ export default function Cards(props) {
<img
src={
comment.author?.profileImage
? `https://wandrlust-server.fly.dev/profileImages/${comment.author?.profileImage}`
: "https://www.pngitem.com/pimgs/m/146-1468479_my-profile-icon-blank-profile-picture-circle-hd.png"
? `http://localhost:3000/profileImages/${comment.author.profileImage}`
: ProfileImage
}
height={30}
width={30}
alt="Profile"
onError={(e) => { e.target.src = ProfileImage; }}
/>
<div>
<div>
<span>
{comment.author?.username}
{comment.author?.username || 'Unknown User'}
</span>
</div>
</div>
</div>
<div>
{comment.date?.toLocaleString(
"en-US", {
{new Date(comment.date).toLocaleString("en-US", {
timeZone: "Asia/Kolkata",
weekday: "long",
year: "numeric",
Expand All @@ -204,8 +234,7 @@ export default function Cards(props) {
hour: "numeric",
minute: "numeric",
second: "numeric",
}
)}
})}
</div>
</div>
<div>
Expand Down
Loading
Loading