- {calendarEvents?.isPending ?
+ {isFetching ?
<>
>
- : calendarEvents?.error ?
+ : isError ?
-
{calendarEvents?.error?.message}
+
{error?.message}
:
<>
diff --git a/src/component/calendar/EventCalendar.jsx b/src/component/calendar/EventCalendar.jsx
index 7720cdb..dd6eb49 100644
--- a/src/component/calendar/EventCalendar.jsx
+++ b/src/component/calendar/EventCalendar.jsx
@@ -81,7 +81,7 @@ export default function EventCalendar({removeAfterDrop, eventList, activeCategor
useEffect(()=>{
// let newEventList = eventList?.map(item => ({...item, start: new Date(item?.start)}))
let newEventList = eventList?.filter(item => (Number(item.category) == Number(activeCategory)))?.map(item => ({...item, start: new Date(item?.start)}))
- console.log('newEventList', newEventList)
+ // console.log('newEventList', newEventList)
setCurrentEvents(newEventList)
},[activeCategory])
diff --git a/src/component/home/Products.jsx b/src/component/home/Products.jsx
index ecc58bc..f3877a1 100644
--- a/src/component/home/Products.jsx
+++ b/src/component/home/Products.jsx
@@ -1,34 +1,22 @@
-import React, {useEffect} from 'react'
-import { useMutation } from '@tanstack/react-query'
+import { useQuery } from '@tanstack/react-query'
import { productsData } from '../../services/services'
import productPath from "../../utils/productpath";
import { Link } from 'react-router-dom';
+import queryKeys from '../../services/queryKeys'
+
export default function Products() {
- const getProductsData = useMutation({
- mutationFn: (reqData) => {
- return productsData(reqData)
- },
- onError: (error) => {
- console.log(error)
- },
- onSuccess: (res) => {
- if(res?.data?.resultCode != '0'){
- throw({message: 'Something went wrong'})
- }
- }
- })
- useEffect(()=>{
- let reqData = {
+ let reqData = {
token: localStorage.getItem('token'), // USER TOKEN
uid: localStorage.getItem('uid') // USER UID
- }
- getProductsData.mutate(reqData)
- },[])
-
- const products = getProductsData?.data?.data?.products_data // PRODUCTS DATA
+ }
+ const {data, isFetching, isError, error} = useQuery({
+ queryKey: queryKeys.product,
+ queryFn: () => productsData(reqData)
+ })
+ const products = data?.data?.products_data // PRODUCTS DATA
return (
<>
@@ -37,7 +25,7 @@ export default function Products() {
My Products
- {getProductsData?.isPending ?
+ {isFetching ?
<>
@@ -45,10 +33,10 @@ export default function Products() {
>
- : getProductsData?.isPending ?
+ : isError ?
-
{getProductsData?.error?.message}
+
{error?.message}
:
diff --git a/src/component/home/ProductsURL.jsx b/src/component/home/ProductsURL.jsx
index 8538731..f497481 100644
--- a/src/component/home/ProductsURL.jsx
+++ b/src/component/home/ProductsURL.jsx
@@ -5,12 +5,18 @@ import queryKeys from '../../services/queryKeys'
export default function ProductsURL() {
- const {data:data, isFetching, isError, error} = useQuery({
+ let reqData = {
+ token: localStorage.getItem('token'), // USER TOKEN
+ uid: localStorage.getItem('uid') // USER UID
+ }
+
+ const {data, isFetching, isError, error} = useQuery({
queryKey: queryKeys.product_url,
- queryFn: () => productsURL()
+ queryFn: () => productsURL(reqData)
})
- const urlData = data?.data?.url_data?.url
+ const urlData = data?.data?.products_data
+ // console.log('data', urlData)
return (
<>
@@ -57,8 +63,8 @@ export default function ProductsURL() {
let productUrl = '/product/'+ item?.product_id
return (
- | {Number(item?.no) + Number(index)} |
- {item?.description} - {item?.url} |
+ {Number(item?.id)} |
+ {item?.description} - {item?.external_url} |
{item?.status} |
|
diff --git a/src/component/home/TopBar.jsx b/src/component/home/TopBar.jsx
index 5a350f0..dd42f60 100644
--- a/src/component/home/TopBar.jsx
+++ b/src/component/home/TopBar.jsx
@@ -1,36 +1,44 @@
-import React, {useEffect} from 'react'
-import { useMutation } from '@tanstack/react-query'
+import { useQuery } from '@tanstack/react-query'
import { topBar } from '../../services/services'
+import queryKeys from '../../services/queryKeys'
export default function TopBar() {
- const topBarData = useMutation({
- mutationFn: (reqData) => {
- return topBar(reqData)
- },
- onError: (error) => {
- console.log(error)
- },
- onSuccess: (res) => {
- if(res?.data?.resultCode != '0'){
- throw({message: 'Something went wrong'})
- }
- }
- })
+// const topBarData = useMutation({
+// mutationFn: (reqData) => {
+// return topBar(reqData)
+// },
+// onError: (error) => {
+// console.log(error)
+// },
+// onSuccess: (res) => {
+// if(res?.data?.resultCode != '0'){
+// throw({message: 'Something went wrong'})
+// }
+// }
+// })
- useEffect(()=>{
- let reqData = {
+// useEffect(()=>{
+// let reqData = {
+// token: localStorage.getItem('token'), // USER TOKEN
+// uid: localStorage.getItem('uid') // USER UID
+// }
+// topBarData.mutate(reqData)
+// },[])
+
+ let reqData = {
token: localStorage.getItem('token'), // USER TOKEN
uid: localStorage.getItem('uid') // USER UID
- }
- topBarData.mutate(reqData)
- },[])
-
- const data = topBarData?.data?.data?.top_bar // top bar data
+ }
+ const {data:topBarData, isFetching, isError, error} = useQuery({
+ queryKey: queryKeys.topBar,
+ queryFn: () => topBar(reqData)
+ })
+ const data = topBarData?.data?.top_bar // top bar data
return (
<>
- {topBarData.isPending ?
+ {isFetching ?
<>
@@ -38,10 +46,10 @@ export default function TopBar() {
>
- : topBarData.error ?
+ : isError?
-
{topBarData.error.message}
+
{error.message}
:
diff --git a/src/services/services.js b/src/services/services.js
index a492647..1a61f98 100644
--- a/src/services/services.js
+++ b/src/services/services.js
@@ -99,6 +99,22 @@ export const contactData = (reqData) => {
return postAuxEnd(`/panel/contacts`, postData, false)
}
+// FUNCTION TO GET DASHBOARD PRODUCT URL DATA SECTION
+export const productsURL = (reqData) => {
+ let postData = {
+ ...reqData,
+ }
+ return postAuxEnd(`/panel/account/products/url`, postData, false)
+}
+
+// FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION
+export const productsData = (reqData) => {
+ let postData = {
+ ...reqData,
+ }
+ return postAuxEnd(`/panel/account/products`, postData, false)
+}
+
// FUNCTION TO GET DASHBOARD RECENT ACTIONS SECTION
export const recentActions = (reqData) => {
let postData = {
@@ -110,29 +126,13 @@ export const recentActions = (reqData) => {
return postAuxEnd(`/panel/account/actions`, postData, false)
}
-// FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION
-export const productsData = (reqData) => {
- let postData = {
- ...reqData,
- }
- return postAuxEnd(`/panel/account/products`, postData, false)
-}
-// FUNCTION TO GET DASHBOARD PRODUCT URL DATA SECTION
-export const productsURL = (reqData) => {
- let postData = {
- ...reqData,
- token: localStorage.getItem('token'), // USER TOKEN
- uid: localStorage.getItem('uid') // USER UID
- }
- return postAuxEnd(`/panel/account/products/url`, postData, false)
- // return getAuxEnd(`/panel/account/products/url`)
-}
+
// FUNCTION TO REGISTER USER
export const signUpUser = (reqData) => {