Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ac742e5d6 | |||
| c2db47cbb8 |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@@ -2,27 +2,40 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import BreadcrumbComBS from "../breadcrumb/BreadcrumbComBS";
|
import BreadcrumbComBS from "../breadcrumb/BreadcrumbComBS";
|
||||||
import getImage from "../../utils/getImage";
|
import getImage from "../../utils/getImage";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { contactData } from "../../services/services";
|
import { contactData } from "../../services/services";
|
||||||
import queryKeys from "../../services/queryKeys";
|
import queryKeys from "../../services/queryKeys";
|
||||||
import getCustomTime from "../../utils/getCustomTime";
|
import getCustomTime from "../../utils/getCustomTime";
|
||||||
|
|
||||||
export default function Contacts(){
|
export default function Contacts(){
|
||||||
|
|
||||||
const {data:contacts, isFetching, isError, error} = useQuery({
|
// const {data:contacts, isFetching, isError, error} = useQuery({
|
||||||
queryKey: queryKeys.contacts,
|
// queryKey: queryKeys.contacts,
|
||||||
queryFn: () => contactData()
|
// 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 [activeCategoryUID, setActiveCategoryUID] = useState('0') // HOLDS VALUE OF THE ACTIVE CATEGORY
|
||||||
|
|
||||||
const [activeContactUID, setActiveContactUID] = useState(null)
|
const [activeContactUID, setActiveContactUID] = useState('')
|
||||||
const [activeDetail, setActiveDetail] = useState(null)
|
const [activeDetail, setActiveDetail] = useState([])
|
||||||
|
|
||||||
const [filteredContactData, setFiltererdContactData] = useState(null)
|
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) => {
|
const changeActiveUID = (uid) => {
|
||||||
setActiveContactUID(uid)
|
setActiveContactUID(uid)
|
||||||
@@ -42,10 +55,21 @@ export default function Contacts(){
|
|||||||
changeActiveUID(filteredConData[0]?.uid)
|
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(
|
return(
|
||||||
<>
|
<>
|
||||||
<BreadcrumbComBS title='Contacts' paths={['Dashboard', 'Contacts']} />
|
<BreadcrumbComBS title='Contacts' paths={['Dashboard', 'Contacts']} />
|
||||||
{isFetching ?
|
{getContactData?.isPending ?
|
||||||
<>
|
<>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
@@ -53,10 +77,10 @@ export default function Contacts(){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
: isError ?
|
: getContactData?.error ?
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<p className='text-danger'>{error.message}</p>
|
<p className='text-danger'>{getContactData?.error?.message}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
:
|
:
|
||||||
@@ -121,14 +145,14 @@ export default function Contacts(){
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{contactsCategory && contactsCategory.map(item => (
|
{contactsCategory && contactsCategory.map(item => (
|
||||||
<li key={item?.product_id} className="py-2" onClick={()=>changeActiveCategoryUID(item?.product_id)} style={{cursor: 'pointer'}}>
|
<li key={item?.cid} className="py-2" onClick={()=>changeActiveCategoryUID(`A00000${item?.cid}`)} style={{cursor: 'pointer'}}>
|
||||||
<div>
|
<div>
|
||||||
<span className="nav align-items-center">
|
<span className="nav align-items-center">
|
||||||
<span>
|
<span>
|
||||||
<i className={`fa fa-circle-o pr-4 ${activeCategoryUID == item?.product_id ? 'text-primary' : 'text-warning'}`}></i>
|
<i className={`fa fa-circle-o pr-4 ${activeCategoryUID == `A00000${item?.cid}` ? 'text-primary' : 'text-warning'}`}></i>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<span>{item?.title}</span>
|
<span>{item?.description}</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -177,10 +201,10 @@ export default function Contacts(){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mail-msg scrollbar scroll_dark">
|
<div className="mail-msg scrollbar scroll_dark">
|
||||||
{contactsData && (filteredContactData || contactsData).map((contact, index)=> {
|
{contactsData && filteredContactData?.map((contact, index)=> {
|
||||||
const isActive = (contact.uid == activeContactUID) || (!activeContactUID && index == 0)
|
const isActive = (contact?.uid == activeContactUID) || (!activeContactUID && index == 0)
|
||||||
return (
|
return (
|
||||||
<div key={contact.uid} onClick={()=>changeActiveUID(contact.uid)} className={`mail-msg-item ${isActive && 'bg-light'}`}>
|
<div key={contact?.uid} onClick={()=>changeActiveUID(contact?.uid)} className={`mail-msg-item ${isActive && 'bg-light'}`}>
|
||||||
<a href="#">
|
<a href="#">
|
||||||
<div className="media align-items-center">
|
<div className="media align-items-center">
|
||||||
<div className="mr-3">
|
<div className="mr-3">
|
||||||
@@ -190,15 +214,15 @@ export default function Contacts(){
|
|||||||
</div>
|
</div>
|
||||||
<div className="w-100">
|
<div className="w-100">
|
||||||
<div className="mail-msg-item-titel justify-content-between">
|
<div className="mail-msg-item-titel justify-content-between">
|
||||||
<p>{contact.sender}</p>
|
<p>{contact?.sender}</p>
|
||||||
{/* <p className="d-none d-xl-block">06:59 <span> PM </span></p> */}
|
{/* <p className="d-none d-xl-block">06:59 <span> PM </span></p> */}
|
||||||
<p className="d-none d-xl-block"><span>{new Date(contact.added).toDateString()}</span></p>
|
<p className="d-none d-xl-block"><span>{new Date(contact?.added).toDateString()}</span></p>
|
||||||
</div>
|
</div>
|
||||||
<h5 className="mb-0 my-2">{contact.title}</h5>
|
<h5 className="mb-0 my-2">{contact?.title}</h5>
|
||||||
<p>{contact.message.length < 100 ? contact.message : contact.message.substring(0,101) + ' ...' }</p>
|
<p>{contact?.message?.length < 100 ? contact?.message : contact?.message.substring(0,101) + ' ...' }</p>
|
||||||
<p className="d-xl-none">
|
<p className="d-xl-none">
|
||||||
<span>
|
<span>
|
||||||
{new Date(contact.added).toDateString()}
|
{new Date(contact?.added).toDateString()}
|
||||||
{/* {getCustomTime(contact.added)} */}
|
{/* {getCustomTime(contact.added)} */}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
@@ -219,13 +243,13 @@ export default function Contacts(){
|
|||||||
<img src={getImage("avtar/03.jpg")} className="img-fluid" alt="user" />
|
<img src={getImage("avtar/03.jpg")} className="img-fluid" alt="user" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4 className="mb-0">{activeContactUID ? activeDetail[0].sender : contactsData[0].sender}</h4>
|
<h4 className="mb-0">{activeContactUID ? activeDetail[0]?.sender : filteredContactData[0]?.sender}</h4>
|
||||||
<p>{activeContactUID ? new Date(activeDetail[0].added).toDateString() : new Date(contactsData[0].added).toDateString()}</p>
|
<p>{activeContactUID ? new Date(activeDetail[0]?.added).toDateString() : new Date(filteredContactData[0]?.added).toDateString()}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 d-flex justify-content-between">
|
<div className="mt-4 d-flex justify-content-between">
|
||||||
<div>
|
<div>
|
||||||
<h3>{activeContactUID ? activeDetail[0].title : contactsData[0].title}</h3>
|
<h3>{activeContactUID ? activeDetail[0]?.title : filteredContactData[0]?.title}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
{/*<a href="javascript:void(0)"><i className="fa fa-reply font-22 pr-3"></i></a>*/}
|
{/*<a href="javascript:void(0)"><i className="fa fa-reply font-22 pr-3"></i></a>*/}
|
||||||
@@ -233,7 +257,7 @@ export default function Contacts(){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p>{activeContactUID ? activeDetail[0].message : contactsData[0].message}</p>
|
<p>{activeContactUID ? activeDetail[0]?.message : filteredContactData[0]?.message}</p>
|
||||||
{/* <p className="my-4">hey adminjon...</p>
|
{/* <p className="my-4">hey adminjon...</p>
|
||||||
<p className="mb-2">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.</p>
|
<p className="mb-2">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.</p>
|
||||||
<p>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.</p>
|
<p>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.</p>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export default function UserHeader(){
|
|||||||
<ul className="navbar-nav nav-right ml-auto">
|
<ul className="navbar-nav nav-right ml-auto">
|
||||||
<li className="nav-item user-profile">
|
<li className="nav-item user-profile">
|
||||||
<a href="#" className="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown">
|
<a href="#" className="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown">
|
||||||
<img src={getImage('avtar/02.jpg')} alt="avtar-img" />
|
<img src={getImage('profile-pic-circle.png')} alt="avtar-img" />
|
||||||
<span className="bg-success user-status"></span>
|
<span className="bg-success user-status"></span>
|
||||||
</a>
|
</a>
|
||||||
<div className="dropdown-menu animated fadeIn">
|
<div className="dropdown-menu animated fadeIn">
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ export default function ProductFactory(){
|
|||||||
getProductData.mutate(reqData)
|
getProductData.mutate(reqData)
|
||||||
},[])
|
},[])
|
||||||
|
|
||||||
const myproduct_data = getProductData?.data?.data?.myproduct?.myproudct // PRODUCT DETAILS
|
const myproduct_data = getProductData?.data?.data?.myproduct?.myproudct // PRODUCT DETAILS
|
||||||
const product_name = myproduct_data?.product_name;
|
const product_name = myproduct_data?.product_name;
|
||||||
const product_status = myproduct_data?.status;
|
const product_status = myproduct_data?.status;
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -85,7 +85,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mail-contant .mail-f{
|
.mail-contant .mail-f{
|
||||||
position: absolute;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
@include desktop {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
@include desktop-lg {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,14 @@ export const getCalendarEvents = (reqData) => {
|
|||||||
return postAuxEnd(`/panel/account/calendar`, postData, false)
|
return postAuxEnd(`/panel/account/calendar`, postData, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION
|
||||||
|
export const contactData = (reqData) => {
|
||||||
|
let postData = {
|
||||||
|
...reqData,
|
||||||
|
}
|
||||||
|
return postAuxEnd(`/panel/contacts`, postData, false)
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION TO GET DASHBOARD RECENT ACTIONS SECTION
|
// FUNCTION TO GET DASHBOARD RECENT ACTIONS SECTION
|
||||||
export const recentActions = (reqData) => {
|
export const recentActions = (reqData) => {
|
||||||
let postData = {
|
let postData = {
|
||||||
@@ -180,13 +188,3 @@ export const productProvision = (reqData) => {
|
|||||||
// return getAuxEnd(`/panel/myproduct/provision`, postData)
|
// return getAuxEnd(`/panel/myproduct/provision`, postData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION
|
|
||||||
export const contactData = (reqData) => {
|
|
||||||
let postData = {
|
|
||||||
...reqData,
|
|
||||||
token: localStorage.getItem('token'), // USER TOKEN
|
|
||||||
uid: localStorage.getItem('uid') // USER UID
|
|
||||||
}
|
|
||||||
return postAuxEnd(`/panel/contacts`, postData, false)
|
|
||||||
// return getAuxEnd(`/panel/contacts`)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user