"use client" import React, { useEffect, useState } from "react"; import BreadcrumbComBS from "../breadcrumb/BreadcrumbComBS"; import getImage from "../../utils/getImage"; import { useQuery } from "@tanstack/react-query"; import { contactData } from "../../services/services"; import queryKeys from "../../services/queryKeys"; import getCustomTime from "../../utils/getCustomTime"; export default function Contacts(){ const {data:contacts, isFetching, isError, error} = useQuery({ queryKey: queryKeys.contacts, queryFn: () => contactData() }) const contactsData = contacts?.data?.calendar_data?.contacts // LIST OF CONTACTS const contactsCategory = contacts?.data?.calendar_data?.category // LIST OF CATEGORY const [activeCategoryUID, setActiveCategoryUID] = useState('0') // HOLDS VALUE OF THE ACTIVE CATEGORY const [activeContactUID, setActiveContactUID] = useState(null) const [activeDetail, setActiveDetail] = useState(null) const [filteredContactData, setFiltererdContactData] = useState(null) 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) } return( <> {isFetching ? <>

Loading...

: isError ?

{error.message}

:
{/*
Coming Soon
*/}
  • changeActiveCategoryUID('0')} style={{cursor: 'pointer'}}>
    All
  • {contactsCategory && contactsCategory.map(item => (
  • changeActiveCategoryUID(item?.product_id)} style={{cursor: 'pointer'}}>
    {item?.title}
  • ))} {/*
  • Work
  • Add Category
  • */}
{/*
*/} {/* */} {/* */} {/*
*/}
{contactsData && (filteredContactData || contactsData).map((contact, index)=> { const isActive = (contact.uid == activeContactUID) || (!activeContactUID && index == 0) return ( ) })}
user

{activeContactUID ? activeDetail[0].sender : contactsData[0].sender}

{activeContactUID ? new Date(activeDetail[0].added).toDateString() : new Date(contactsData[0].added).toDateString()}

{activeContactUID ? activeDetail[0].title : contactsData[0].title}

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

{activeContactUID ? activeDetail[0].message : contactsData[0].message}

{/*

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

*/} {/*
*/}

Click here to ReplyorForward

{/*
    */} {/*
  • */} {/*
  • */} {/*
  • */} {/*
*/}
{/*Send */}
} ) }