From 4409ed45f38c80363f6de033fb134ced3d345a6e Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 8 Sep 2025 11:32:08 -0400 Subject: [PATCH] comments page cleanup --- src/component/comments/Comments.js | 855 +++++++++++------------------ 1 file changed, 323 insertions(+), 532 deletions(-) diff --git a/src/component/comments/Comments.js b/src/component/comments/Comments.js index 773dc43..376a38e 100644 --- a/src/component/comments/Comments.js +++ b/src/component/comments/Comments.js @@ -1,558 +1,349 @@ -import React from "react"; +"use client"; +import React, { useEffect, useState } from "react"; import BreadcrumbComBS from "../breadcrumb/BreadcrumbComBS"; import getImage from "../../utils/getImage"; +import { useMutation, useQuery } from "@tanstack/react-query"; +import { contactData } from "../../services/services"; +import queryKeys from "../../services/queryKeys"; +import getCustomTime from "../../utils/getCustomTime"; export default function Comments() { + // const {data:contacts, isFetching, isError, error} = useQuery({ + // queryKey: queryKeys.contacts, + // queryFn: () => contactData() + // }) + + const [activeCategoryUID, setActiveCategoryUID] = useState("0"); // HOLDS VALUE OF THE ACTIVE CATEGORY + + const [activeContactUID, setActiveContactUID] = useState(""); + const [activeDetail, setActiveDetail] = useState([]); + + const [filteredContactData, setFiltererdContactData] = useState([]); + + const getContactData = useMutation({ + mutationFn: (reqData) => { + return contactData(reqData); + }, + onError: (error) => { + console.log(error); + }, + onSuccess: (res) => { + if (res?.data?.resultCode != "0") { + throw { message: "Something went wrong" }; + } + setFiltererdContactData(res?.data?.contacts); + }, + }); + + const changeActiveUID = (uid) => { + setActiveContactUID(uid); + let detail = contactsData.filter((item) => item.uid == uid); + setActiveDetail(detail); + }; + + const changeActiveCategoryUID = (id) => { + let filteredConData = []; + setActiveCategoryUID(id); + if (id == "0") { + filteredConData = contactsData; + } else { + filteredConData = contactsData.filter((item) => item.category == id); + } + setFiltererdContactData(filteredConData); + changeActiveUID(filteredConData[0]?.uid); + }; + + useEffect(() => { + let reqData = { + token: localStorage.getItem("token"), // USER TOKEN + uid: localStorage.getItem("uid"), // USER UID + }; + getContactData.mutate(reqData); + }, []); + + const contactsData = getContactData?.data?.data?.contacts; // LIST OF CONTACTS + const contactsCategory = getContactData?.data?.data?.category; // LIST OF CATEGORY + return ( - <> - -
- {/*
Coming Soon
*/} -
-
-
-
-
-
-
-
-
- - - -
-
-
-
- +
+
-
-
-
- -
-
-
- user -
-
-
-
-

Martin smith

-

- 06:59 PM -

-
-
Saas Designer
-

- Since there is not an "all the above" category, - I'll take the opportunity to enthusiastically - congratulate you on the very high quality. -

-

- 06:59 PM -

+
0 ? 'col-md-8 col-xxl-4' : 'col-md-8 col-xxl-10'} border-md-t`}> +
+ {/* */} +
+ { filteredContactData.length ? + filteredContactData?.map((contact, index) => { + const isActive = + contact?.uid == activeContactUID || + (!activeContactUID && index == 0); + const avtarImage = + contact?.category === undefined + ? "avtar/01.jpg" + : "avtar/" + contact.category + ".png"; + return ( + + ); + }) + : +

Messages will appear here as soon as they are available for selection

+ } +
+
-
- -
-
-
- user + {filteredContactData.length > 0 && + - - - - - - - -
-
-
-
-
-
-
- user -
-
-

Dutca Patrick

-

30 Min ago

-
-
-
-
-

Landing page Designer...

-
-
- {/**/} - {/**/} -
-
-
-

hey adminjon...

-

- I truly believe Augustine’s words are true and if you - look at history you know it is true. There are many - people in the world with amazing talents who realize - only a small percentage of their potential. We all know - people who live this truth. -

-

- We also know those epic stories, those modern-day - legends surrounding the early failures of such supremely - successful folks as Michael Jordan and Bill Gates. We - can look a bit further back in time to Albert Einstein - or even further back to Abraham Lincoln. What made each - of these people so successful? Motivation. -

-

- We know this in our gut, but what can we do about it? - How can we motivate ourselves? One of the most difficult - aspects of achieving success is staying motivated over - the long haul. -

-
-

Have lovely Day,

-

adminjon

-
-
-
- {/*
*/} - {/*
*/} - {/*
*/} - {/* */} - {/*

Wireframe

*/} - {/*

(220.MB)

*/} - {/*
*/} - {/*
*/} - {/* */} - {/*
*/} -
-
-

- Click here to{" "} - - Reply - - or - - Forward - -

- - - -
-
-
- -
-
-
-
- -
-
-
-
- -
- + }
-
-
-
- + )} + ); }