diff --git a/client/app/[id]/edit/page.tsx b/client/app/[id]/edit/page.tsx
index 539247f..5e8a239 100644
--- a/client/app/[id]/edit/page.tsx
+++ b/client/app/[id]/edit/page.tsx
@@ -1,6 +1,5 @@
"use client";
-
import React, { useState, useEffect } from "react";
import {
fetchBusinessesByslug,
@@ -205,11 +204,10 @@ export default function EditBusinessPage() {
}
};
- const handleImageUpload = (assetpath: string, field: 'avatar' | 'banner') => {
- console.log('Image uploaded:', assetpath);
+ const handleImageUpload = (assetpath: string, field: "avatar" | "banner") => {
+ console.log("Image uploaded:", assetpath);
// console.log('Field:', field);
handleFieldSave(field, assetpath);
-
};
// Replace handleChange with immediate save
@@ -232,10 +230,10 @@ export default function EditBusinessPage() {
await deletebusinessMedia(businessData.profile.id, mediaId);
}
fetchData();
- toast.success('Media item deleted successfully');
+ toast.success("Media item deleted successfully");
} catch (error) {
- console.error('Error deleting media:', error);
- toast.error('Failed to delete media item');
+ console.error("Error deleting media:", error);
+ toast.error("Failed to delete media item");
}
};
@@ -294,8 +292,10 @@ export default function EditBusinessPage() {
return (
-
-
Edit Business Profile
+
+
+ Edit Business Profile
+
diff --git a/client/app/[id]/page.tsx b/client/app/[id]/page.tsx
index e306f29..804ce61 100644
--- a/client/app/[id]/page.tsx
+++ b/client/app/[id]/page.tsx
@@ -102,6 +102,9 @@ export const runtime = "edge";
const DevMorphixWebsite = () => {
const [isMenuOpen, setIsMenuOpen] = useState(false);
+ const [hoveredIcon, setHoveredIcon] = useState<{
+ platform: string;
+ } | null>(null);
const [businessData, setBusinessData] = useState
(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState(null);
@@ -623,14 +626,13 @@ const DevMorphixWebsite = () => {
- {businessData?.user.phone || "Not available"}
+ +91 {businessData?.user.phone || "Not available"}
-
-
+
+
- {" "}
{`${businessData?.profile.address}, ${businessData?.profile.city}, ${businessData?.profile.state}, ${businessData?.profile.country}`}
@@ -713,42 +715,54 @@ const DevMorphixWebsite = () => {
"No description available"}
- {businessData?.profile.socials && Object.values(businessData.profile.socials).some(url => url) && (
-
-
- Our Social Media Connects
-
-
+ {businessData?.profile.socials &&
+ Object.values(businessData.profile.socials).some(
+ (url) => url
+ ) && (
+
+
+ Our Social Media Connects
+
+
{Object.entries(businessData.profile.socials).map(
- ([platform, url]) => {
- if (url) {
- const iconSrc = socialIcons[platform.toLowerCase()];
- return (
-
- {iconSrc ? (
-
- ) : (
- platform
- )}
-
- );
- }
- return null;
- }
+ ([platform, url]) => {
+ if (url) {
+ const iconSrc = socialIcons[platform.toLowerCase()];
+
+ return (
+
+
+ {hoveredIcon?.platform === platform && (
+
+ {platform.charAt(0).toUpperCase() + platform.slice(1)}
+
+ )}
- )}
+ );
+ }
+ return null;
+ }
+ )}
+
+
+ )}
diff --git a/client/app/api/index.ts b/client/app/api/index.ts
index c6cf65a..4bf9b74 100644
--- a/client/app/api/index.ts
+++ b/client/app/api/index.ts
@@ -512,7 +512,7 @@ export const updateBusiness = async (businessId: string, updateData: Record
void;
- category: 'media' | 'avatar' | 'banner';
+ category: 'media' | 'avatar' | 'banner' |'identity';
label?: string;
showPreview?: boolean;
currentImage?: string;
@@ -63,7 +63,7 @@ const ImageUploadButton = ({
await uploadToPresignedUrl(urlResponse.presignedUrl, file);
console.log(`File ${file.name} uploaded successfully to storage`);
- if (category === 'avatar' || category === 'banner') {
+ if (category === 'avatar' || category === 'banner' || category === 'identity') {
console.log(`Completing ${category} upload with assetpath:`, urlResponse.assetpath);
onUploadComplete(urlResponse.assetpath);
} else {
diff --git a/client/app/components/OperatingHours.tsx b/client/app/components/OperatingHours.tsx
index 0358f10..e50fe5c 100644
--- a/client/app/components/OperatingHours.tsx
+++ b/client/app/components/OperatingHours.tsx
@@ -148,64 +148,74 @@ export default function OperatingHours({ hours, onUpdate }: OperatingHoursProps)
return (
{DAYS.map((day) => {
- const times = parseHours(operatingHours[day] || 'Closed');
- const isClosed = operatingHours[day] === 'Closed';
-
- return (
-
-
- {DAY_NAMES[day]}
-
-
-
- toggleClosed(day, e.target.checked)}
- className="h-4 w-4 cursor-pointer"
- id={`closed-${day}`}
- />
-
-
-
- {!isClosed && (
- <>
-
-
-
to
-
-
- >
- )}
+ const times = parseHours(operatingHours[day] || 'Closed')
+ const isClosed = operatingHours[day] === 'Closed'
+
+ return (
+
+
+
+ {DAY_NAMES[day]}
+
+
+
+
+ toggleClosed(day, e.target.checked)}
+ className="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500 cursor-pointer"
+ id={`closed-${day}`}
+ />
+
+
+
+ {!isClosed && (
+
+
+
+ to
+
+
- );
- })}
+ )}
+
+
+
+ )
+ })}
);
}
--
knotmirror 0.0.1
From d85a940a1c64f02d11491875fd223a396a461b44 Mon Sep 17 00:00:00 2001
From: Abhishek V Gopal
Date: Thu, 9 Jan 2025 00:38:06 +0530
Subject: [PATCH 02/11] added /
---
client/app/api/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/app/api/index.ts b/client/app/api/index.ts
index 4bf9b74..e65aff8 100644
--- a/client/app/api/index.ts
+++ b/client/app/api/index.ts
@@ -512,7 +512,7 @@ export const updateBusiness = async (businessId: string, updateData: Record
Date: Thu, 9 Jan 2025 00:49:57 +0530
Subject: [PATCH 03/11] added /
---
client/app/api/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/app/api/index.ts b/client/app/api/index.ts
index e65aff8..e07bcca 100644
--- a/client/app/api/index.ts
+++ b/client/app/api/index.ts
@@ -512,7 +512,7 @@ export const updateBusiness = async (businessId: string, updateData: Record
Date: Thu, 9 Jan 2025 01:08:08 +0530
Subject: [PATCH 04/11] added
---
client/app/[id]/edit/page.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/app/[id]/edit/page.tsx b/client/app/[id]/edit/page.tsx
index 5e8a239..c7d9370 100644
--- a/client/app/[id]/edit/page.tsx
+++ b/client/app/[id]/edit/page.tsx
@@ -357,8 +357,8 @@ export default function EditBusinessPage() {
multiple={false}
onUploadComplete={(assetpath) => {
if (assetpath) {
- handleImageUpload(assetpath, "avatar");
- businessData.profile.avatar = assetpath;
+ handleImageUpload(assetpath, "banner");
+ businessData.profile.banner = assetpath;
}
}}
/>
--
knotmirror 0.0.1
From 91665c875d0da06f0323d38060318b43a6883b52 Mon Sep 17 00:00:00 2001
From: Abhishek V Gopal
Date: Thu, 9 Jan 2025 10:57:44 +0530
Subject: [PATCH 05/11] added login and ui bug fix
---
client/app/[id]/page.tsx | 121 +++++++++++++++++++++----------
client/app/api/index.ts | 20 ++++-
client/app/components/imgsec.tsx | 2 +-
3 files changed, 101 insertions(+), 42 deletions(-)
diff --git a/client/app/[id]/page.tsx b/client/app/[id]/page.tsx
index 804ce61..3ac9103 100644
--- a/client/app/[id]/page.tsx
+++ b/client/app/[id]/page.tsx
@@ -25,7 +25,12 @@ import { FooterSection } from "@/app/components/FooterSection";
import { div } from "framer-motion/client";
import DynamicQRCode from "@/app/components/QrSection";
import ScrollToTopButton from "@/app/components/ScrollToTop";
-import { fetchBusinessesByslug, ASSET_BASE_URL, GetURL } from "@/app/api";
+import {
+ fetchBusinessesByslug,
+ ASSET_BASE_URL,
+ GetURL,
+ UserLogout,
+} from "@/app/api";
import { useParams, useRouter } from "next/navigation";
// Add this interface with other interfaces
@@ -165,6 +170,31 @@ const DevMorphixWebsite = () => {
router.push(`/${params.id}/edit`);
};
+ const handlelogout = async () => {
+ try {
+ const token = Cookies.get("token");
+ // console.log("Raw JWT Token:", token);
+
+ if (!token) {
+ console.log("No JWT token found in cookies");
+ return null;
+ }
+ const res = await UserLogout(token);
+
+ if (res.message === "User logged out successfully") {
+ Cookies.remove("token");
+ localStorage.removeItem("userData");
+ localStorage.removeItem("userProfiles");
+ router.push("/");
+ }else{
+ console.log("Error logging out:", res);
+ }
+
+ } catch (err) {
+ console.error("Error logging out:", err);
+ }
+ };
+
// Modify your existing fetchData function to include token handling
useEffect(() => {
const fetchData = async () => {
@@ -434,13 +464,23 @@ const DevMorphixWebsite = () => {
/>
+ {isOwner && (
+
+ )}
+
{isOwner && (
)}
@@ -724,42 +764,45 @@ const DevMorphixWebsite = () => {
Our Social Media Connects
- {Object.entries(businessData.profile.socials).map(
- ([platform, url]) => {
- if (url) {
- const iconSrc = socialIcons[platform.toLowerCase()];
-
- return (
-
- );
- }
- return null;
- }
- )}
+ {Object.entries(businessData.profile.socials).map(
+ ([platform, url]) => {
+ if (url) {
+ const iconSrc = socialIcons[platform.toLowerCase()];
+
+ return (
+
+ );
+ }
+ return null;
+ }
+ )}
)}
diff --git a/client/app/api/index.ts b/client/app/api/index.ts
index e07bcca..5e7a4a7 100644
--- a/client/app/api/index.ts
+++ b/client/app/api/index.ts
@@ -333,13 +333,29 @@ export const VerifyRegisterOTP = async (data: any) => {
export const UserLogout = async (data: any) => {
try {
+
+ const token = document.cookie
+ .split('; ')
+ .find(row => row.startsWith('token='))
+ ?.split('=')[1];
+
+ if (!token) {
+ throw new Error('No token provided');
+ }
+
+
const response = await axios.post(
`${BASE_URL}/auth/logout`,
- data
+ data,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`
+ },
+ }
);
return response.data;
} catch (error) {
- console.error('Error verifying OTP:', error);
+ console.error('Error in logout:', error);
throw error;
}
};
diff --git a/client/app/components/imgsec.tsx b/client/app/components/imgsec.tsx
index da7e292..10ee817 100644
--- a/client/app/components/imgsec.tsx
+++ b/client/app/components/imgsec.tsx
@@ -157,7 +157,7 @@ const ImageSection = ({ images = defaultImages, media = [], className }: ImageSe
return (
<>
Date: Thu, 9 Jan 2025 11:14:53 +0530
Subject: [PATCH 06/11] added
---
client/app/[id]/page.tsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/client/app/[id]/page.tsx b/client/app/[id]/page.tsx
index 3ac9103..b34d984 100644
--- a/client/app/[id]/page.tsx
+++ b/client/app/[id]/page.tsx
@@ -467,7 +467,7 @@ const DevMorphixWebsite = () => {
{isOwner && (
@@ -412,25 +376,23 @@ export default function EditBusinessPage() {
handleChange("phone", e.target.value)}
+ onChange={(e) => handleFieldChange("phone", e.target.value)}
className="w-full p-2 border rounded-lg"
/>
-
+
handleChange("address", e.target.value)}
+ onChange={(e) => handleFieldChange("address", e.target.value)}
className="w-full p-2 border rounded-lg"
/>
- {/* Add this new section after Contact Information and before Social Media Links */}
+ {/* Additional Services */}
Additional Services
@@ -461,16 +423,12 @@ export default function EditBusinessPage() {
- handleFieldSave("additional_services", e.target.value)
+ onChange={(e) =>
+ handleFieldChange("additional_services", e.target.value)
}
className="w-full p-2 border rounded-lg"
placeholder="e.g., customOrders, afterSalesSupport"
/>
-
- Enter services separated by commas. Use camelCase for multiple
- words (e.g., customOrders).
-
@@ -479,33 +437,31 @@ export default function EditBusinessPage() {
Social Media Links
- {Object.entries(socialMediaConfig).map(
- ([key, { label, icon }]) => (
-
-
-

-
-
-
-
- handleFieldSave(`socials.${key}`, e.target.value)
- }
- className="w-full p-2 border rounded-lg"
- placeholder={`Enter ${label}`}
- />
-
+ {Object.entries(socialMediaConfig).map(([key, { label, icon }]) => (
+
+
+

+
+
+
+
+ handleFieldChange(`socials.${key}`, e.target.value)
+ }
+ className="w-full p-2 border rounded-lg"
+ placeholder={`Enter ${label}`}
+ />
- )
- )}
+
+ ))}
@@ -518,34 +474,18 @@ export default function EditBusinessPage() {
/>
- {/* Tags */}
- {/*
- Business Tags
-
-
handleChange('tags', e.target.value)}
- className="w-full p-2 border rounded-lg"
- />
-
- Enter tags separated by commas (e.g., web design, development, marketing)
-
-
- */}
-
{/* Media Gallery */}
Media Gallery
fetchData()}
onDelete={handleMediaDelete}
/>
+ {/* Business Operation */}
Business Operation
@@ -588,3 +528,4 @@ export default function EditBusinessPage() {
);
}
+
--
knotmirror 0.0.1
From 93abc0fcec2194fc63a58f8b8e87f212bb45415d Mon Sep 17 00:00:00 2001
From: Abhishek V Gopal
Date: Thu, 9 Jan 2025 22:28:14 +0530
Subject: [PATCH 08/11] added
---
client/app/[id]/edit/page.tsx | 289 ++++++++++++++++++++--------------
1 file changed, 174 insertions(+), 115 deletions(-)
diff --git a/client/app/[id]/edit/page.tsx b/client/app/[id]/edit/page.tsx
index 45f28ac..c7d9370 100644
--- a/client/app/[id]/edit/page.tsx
+++ b/client/app/[id]/edit/page.tsx
@@ -7,14 +7,26 @@ import {
updateBusiness,
} from "@/app/api";
import { useParams, useRouter } from "next/navigation";
-import { Pencil, Save, X, Facebook, Instagram, Twitter, Linkedin, Youtube, Globe } from 'lucide-react';
+import {
+ Pencil,
+ Save,
+ X,
+ Facebook,
+ Instagram,
+ Twitter,
+ Linkedin,
+ Youtube,
+ Globe,
+} from "lucide-react";
import ImageGrid from "@/app/components/imgsec";
import ImageUploadButton from "@/app/components/ImageUploadButton";
import MediaGallery from "@/app/components/MediaGallery";
import OperatingHours from "@/app/components/OperatingHours";
import { deletebusinessMedia } from "@/app/api";
-import { toast } from "react-hot-toast";
+import { toast } from "react-hot-toast"; // Add toast for notifications
+import { s } from "framer-motion/client";
+// Add License interface before other interfaces
interface License {
name: string;
number: string;
@@ -22,6 +34,7 @@ interface License {
description: string;
}
+// Add MediaItem interface
interface MediaItem {
id: string;
url: string;
@@ -48,15 +61,15 @@ interface BusinessProfile {
twitter?: string;
linkedin?: string;
youtube?: string;
- [key: string]: string | undefined;
+ [key: string]: string | undefined; // Add index signature for socials
};
avatar: string;
banner: string;
type: string;
additional_services: string;
gstin: string;
- id: string;
- [key: string]: any;
+ id: string; // Add this field
+ [key: string]: any; // Add index signature to allow dynamic access
}
interface BusinessData {
@@ -66,20 +79,18 @@ interface BusinessData {
phone: string;
};
_id: string;
- media: MediaItem[];
+ media: MediaItem[]; // Add this field
category: string;
subCategory: string;
subCategoryOption: string;
- licenses: License[];
+ licenses: License[]; // Now License is defined
tags: string[];
}
-interface Changes {
- [key: string]: any;
-}
-
export const runtime = "edge";
+// Add this social media config object near the top of your component
+
const socialMediaConfig = {
website: { label: "Website URL", icon: "/icon/globe.svg" },
facebook: { label: "Facebook Profile", icon: "/icon/facebook.svg" },
@@ -95,16 +106,15 @@ const socialMediaConfig = {
github: { label: "GitHub Profile", icon: "/icon/github.svg" },
medium: { label: "Medium Profile", icon: "/icon/medium.svg" },
};
-
export default function EditBusinessPage() {
const [businessData, setBusinessData] = useState(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState(null);
- const [changes, setChanges] = useState({});
- const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
+ const [changes, setChanges] = useState>({});
const params = useParams();
const router = useRouter();
+ // Move fetchData outside useEffect so it can be referenced anywhere in the component
const fetchData = async () => {
try {
setIsLoading(true);
@@ -121,6 +131,7 @@ export default function EditBusinessPage() {
}
};
+ // Check authorization
useEffect(() => {
const token = document.cookie
.split("; ")
@@ -132,78 +143,87 @@ export default function EditBusinessPage() {
}
}, [params.id, router]);
+ // Initial data fetch
useEffect(() => {
if (params.id) {
fetchData();
}
}, [params.id]);
- useEffect(() => {
- setHasUnsavedChanges(Object.keys(changes).length > 0);
- }, [changes]);
+ const handleFieldSave = async (field: string, value: any) => {
+ try {
+ if (!businessData?.profile.id) return;
- const handleFieldChange = (field: string, value: any) => {
- setChanges((prev) => {
const fieldParts = field.split(".");
+ let updateData: Record = {};
+
if (fieldParts.length > 1 && fieldParts[0] === "socials") {
- return {
- ...prev,
- socials: {
- ...(prev.socials || {}),
- [fieldParts[1]]: value,
- },
+ // Handle social media fields specifically
+ updateData.socials = {
+ ...(businessData.profile.socials || {}),
+ [fieldParts[1]]: value,
};
+ } else {
+ // Handle regular fields
+ updateData[field] = value;
}
- return {
- ...prev,
- [field]: value,
- };
- });
-
- // Update UI immediately
- setBusinessData((prev) => {
- if (!prev) return null;
- const fieldParts = field.split(".");
- if (fieldParts.length > 1 && fieldParts[0] === "socials") {
+
+ // Ensure updateData is not empty before making the API call
+ if (Object.keys(updateData).length === 0) {
+ console.warn("No values to update");
+ return;
+ }
+
+ // Log the updateData object
+ console.log("Updating business with data:", updateData);
+
+ await updateBusiness(businessData.profile.id, updateData);
+ toast.success(`${field} updated successfully`);
+
+ // Update local state
+ setBusinessData((prev) => {
+ if (!prev) return null;
return {
...prev,
profile: {
...prev.profile,
- socials: {
- ...prev.profile.socials,
- [fieldParts[1]]: value,
- },
+ ...(fieldParts[0] === "socials"
+ ? {
+ socials: {
+ ...prev.profile.socials,
+ [fieldParts[1]]: value,
+ },
+ }
+ : updateData),
},
};
- }
- return {
- ...prev,
- profile: {
- ...prev.profile,
- [field]: value,
- },
- };
- });
+ });
+ } catch (error) {
+ console.error("Error updating field:", error);
+ toast.error(`Failed to update ${field}`);
+ }
};
- const handleSaveAllChanges = async () => {
- try {
- if (!businessData?.profile.id || Object.keys(changes).length === 0) return;
+ const handleImageUpload = (assetpath: string, field: "avatar" | "banner") => {
+ console.log("Image uploaded:", assetpath);
+ // console.log('Field:', field);
+ handleFieldSave(field, assetpath);
+ };
+
+ // Replace handleChange with immediate save
+ const handleChange = async (field: string, value: string) => {
+ await handleFieldSave(field, value);
+ };
- await updateBusiness(businessData.profile.id, changes);
- toast.success("All changes saved successfully");
- setChanges({});
+ const handleSave = async () => {
+ try {
+ // TODO: Implement API call to save all changes
router.push(`/${params.id}`);
} catch (error) {
console.error("Error saving changes:", error);
- toast.error("Failed to save changes");
}
};
- const handleImageUpload = (assetpath: string, field: "avatar" | "banner") => {
- handleFieldChange(field, assetpath);
- };
-
const handleMediaDelete = async (mediaId: string) => {
try {
if (businessData?.profile.id) {
@@ -217,8 +237,32 @@ export default function EditBusinessPage() {
}
};
- const handleOperatingHoursUpdate = (newHours: { [key: string]: string }) => {
- handleFieldChange("operating_hours", newHours);
+ const handleOperatingHoursUpdate = async (newHours: {
+ [key: string]: string;
+ }) => {
+ try {
+ if (!businessData?.profile.id) return;
+
+ await updateBusiness(businessData.profile.id, {
+ operating_hours: newHours,
+ });
+ toast.success("Operating hours updated successfully");
+
+ // Update local state
+ setBusinessData((prev) => {
+ if (!prev) return null;
+ return {
+ ...prev,
+ profile: {
+ ...prev.profile,
+ operating_hours: newHours,
+ },
+ };
+ });
+ } catch (error) {
+ console.error("Error updating operating hours:", error);
+ toast.error("Failed to update operating hours");
+ }
};
if (isLoading) {
@@ -251,11 +295,6 @@ export default function EditBusinessPage() {
Edit Business Profile
- {hasUnsavedChanges && (
-
- (Unsaved changes)
-
- )}
- {hasUnsavedChanges ? "Save All Changes" : "No Changes"}
+ Save All Changes
@@ -285,10 +319,11 @@ export default function EditBusinessPage() {
Profile Images
+ {/* Profile Avatar */}
Profile Image
{
if (assetpath) {
handleImageUpload(assetpath, "avatar");
+ businessData.profile.avatar = assetpath;
}
}}
/>
+ {/* Banner Image */}
Banner Image
{
if (assetpath) {
handleImageUpload(assetpath, "banner");
+ businessData.profile.banner = assetpath;
}
}}
/>
@@ -339,7 +377,7 @@ export default function EditBusinessPage() {
handleFieldChange("name", e.target.value)}
+ onBlur={(e) => handleFieldSave("name", e.target.value)}
className="w-full p-2 border rounded-lg"
/>
@@ -349,9 +387,7 @@ export default function EditBusinessPage() {
@@ -367,7 +403,7 @@ export default function EditBusinessPage() {
handleFieldChange("email", e.target.value)}
+ onChange={(e) => handleChange("email", e.target.value)}
className="w-full p-2 border rounded-lg"
/>
@@ -376,23 +412,25 @@ export default function EditBusinessPage() {
handleFieldChange("phone", e.target.value)}
+ onChange={(e) => handleChange("phone", e.target.value)}
className="w-full p-2 border rounded-lg"
/>
-
+
handleFieldChange("address", e.target.value)}
+ onChange={(e) => handleChange("address", e.target.value)}
className="w-full p-2 border rounded-lg"
/>
- {/* Additional Services */}
+ {/* Add this new section after Contact Information and before Social Media Links */}
Additional Services
@@ -423,12 +461,16 @@ export default function EditBusinessPage() {
- handleFieldChange("additional_services", e.target.value)
+ onBlur={(e) =>
+ handleFieldSave("additional_services", e.target.value)
}
className="w-full p-2 border rounded-lg"
placeholder="e.g., customOrders, afterSalesSupport"
/>
+
+ Enter services separated by commas. Use camelCase for multiple
+ words (e.g., customOrders).
+
@@ -437,31 +479,33 @@ export default function EditBusinessPage() {
Social Media Links
- {Object.entries(socialMediaConfig).map(([key, { label, icon }]) => (
-
-
-

-
-
-
-
- handleFieldChange(`socials.${key}`, e.target.value)
- }
- className="w-full p-2 border rounded-lg"
- placeholder={`Enter ${label}`}
- />
+ {Object.entries(socialMediaConfig).map(
+ ([key, { label, icon }]) => (
+
+
+

+
+
+
+
+ handleFieldSave(`socials.${key}`, e.target.value)
+ }
+ className="w-full p-2 border rounded-lg"
+ placeholder={`Enter ${label}`}
+ />
+
-
- ))}
+ )
+ )}
@@ -474,18 +518,34 @@ export default function EditBusinessPage() {
/>
+ {/* Tags */}
+ {/*
+ Business Tags
+
+
handleChange('tags', e.target.value)}
+ className="w-full p-2 border rounded-lg"
+ />
+
+ Enter tags separated by commas (e.g., web design, development, marketing)
+
+
+ */}
+
{/* Media Gallery */}
Media Gallery
fetchData()}
onDelete={handleMediaDelete}
/>
- {/* Business Operation */}
Business Operation
@@ -528,4 +588,3 @@ export default function EditBusinessPage() {
);
}
-
--
knotmirror 0.0.1
From 0346449cbae90da3be5e038df4dcbda760bd0a5a Mon Sep 17 00:00:00 2001
From: Abhishek V Gopal
Date: Fri, 10 Jan 2025 21:42:32 +0530
Subject: [PATCH 09/11] added
---
client/app/[id]/page.tsx | 9 ++++++++-
client/app/api/index.ts | 2 +-
client/app/components/loginpopup.tsx | 6 +++---
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/client/app/[id]/page.tsx b/client/app/[id]/page.tsx
index b34d984..d318039 100644
--- a/client/app/[id]/page.tsx
+++ b/client/app/[id]/page.tsx
@@ -127,6 +127,7 @@ const DevMorphixWebsite = () => {
if (!token) {
console.log("No JWT token found in cookies");
+ localStorage.clear();
return null;
}
@@ -146,6 +147,9 @@ const DevMorphixWebsite = () => {
if (isExpired) {
console.log("Token has expired");
+ // Cookies.remove("token");
+ localStorage.removeItem("userData");
+ localStorage.removeItem("userProfiles");
// Optionally remove expired token
Cookies.remove("token");
return null;
@@ -163,6 +167,8 @@ const DevMorphixWebsite = () => {
useEffect(() => {
const decoded = handleJWTToken();
setTokenData(decoded);
+
+
}, []);
// Add this function to handle edit click
@@ -180,8 +186,9 @@ const DevMorphixWebsite = () => {
return null;
}
const res = await UserLogout(token);
+ console.log();
- if (res.message === "User logged out successfully") {
+ if (res.status=== 200) {
Cookies.remove("token");
localStorage.removeItem("userData");
localStorage.removeItem("userProfiles");
diff --git a/client/app/api/index.ts b/client/app/api/index.ts
index 5e7a4a7..cf36855 100644
--- a/client/app/api/index.ts
+++ b/client/app/api/index.ts
@@ -353,7 +353,7 @@ export const UserLogout = async (data: any) => {
},
}
);
- return response.data;
+ return response;
} catch (error) {
console.error('Error in logout:', error);
throw error;
diff --git a/client/app/components/loginpopup.tsx b/client/app/components/loginpopup.tsx
index 7e5516d..7d729ff 100644
--- a/client/app/components/loginpopup.tsx
+++ b/client/app/components/loginpopup.tsx
@@ -7,8 +7,8 @@ import { toast } from 'react-hot-toast';
import Loader from './loader';
// Add the cookie utility function at the top
-const setCookie = (name: string, value: string, days: number) => {
- const expires = new Date(Date.now() + days * 864e5).toUTCString();
+const setCookie = (name: string, value: string, minutes: number) => {
+ const expires = new Date(Date.now() + minutes * 60 * 1000).toUTCString();
document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expires}; path=/`;
};
@@ -233,7 +233,7 @@ const LoginPopup: React.FC = ({
const { token, user } = response?.data?.data || {};
if (token) {
- setCookie('token', token, 7);
+ setCookie('token', token, 1);
}
setLocalStorage('userData', {
--
knotmirror 0.0.1
From 9cd781263c3de4e96e0ce9c3dd0b6a5a518029ec Mon Sep 17 00:00:00 2001
From: Abhishek V Gopal
Date: Fri, 10 Jan 2025 21:59:56 +0530
Subject: [PATCH 10/11] added
---
client/app/[id]/page.tsx | 1 +
client/app/components/loginpopup.tsx | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/client/app/[id]/page.tsx b/client/app/[id]/page.tsx
index d318039..f2b0892 100644
--- a/client/app/[id]/page.tsx
+++ b/client/app/[id]/page.tsx
@@ -128,6 +128,7 @@ const DevMorphixWebsite = () => {
if (!token) {
console.log("No JWT token found in cookies");
localStorage.clear();
+ router.push("/");
return null;
}
diff --git a/client/app/components/loginpopup.tsx b/client/app/components/loginpopup.tsx
index 7d729ff..fe1162a 100644
--- a/client/app/components/loginpopup.tsx
+++ b/client/app/components/loginpopup.tsx
@@ -7,8 +7,8 @@ import { toast } from 'react-hot-toast';
import Loader from './loader';
// Add the cookie utility function at the top
-const setCookie = (name: string, value: string, minutes: number) => {
- const expires = new Date(Date.now() + minutes * 60 * 1000).toUTCString();
+const setCookie = (name: string, value: string, days: number) => {
+ const expires = new Date(Date.now() + days * 864e5).toUTCString();
document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expires}; path=/`;
};
--
knotmirror 0.0.1
From 2a851d067cda47b847b05c1812eb4a580e6093c5 Mon Sep 17 00:00:00 2001
From: Abhishek V Gopal
Date: Fri, 10 Jan 2025 22:10:54 +0530
Subject: [PATCH 11/11] added
---
client/app/[id]/page.tsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/client/app/[id]/page.tsx b/client/app/[id]/page.tsx
index f2b0892..d318039 100644
--- a/client/app/[id]/page.tsx
+++ b/client/app/[id]/page.tsx
@@ -128,7 +128,6 @@ const DevMorphixWebsite = () => {
if (!token) {
console.log("No JWT token found in cookies");
localStorage.clear();
- router.push("/");
return null;
}