Compare commits

...

4 Commits

Author SHA1 Message Date
victorAnumudu 9684e7fcfa added token and uid to all endpoints 2025-06-26 17:37:11 +01:00
ameye d4eda11477 Merge branch 'products-endpont' of MERMS/MermsPanelReactJS into master 2025-06-25 19:55:14 +00:00
victorAnumudu 1d31507984 new products endpoint added 2025-06-25 19:31:50 +01:00
ameye a3dbc8cab1 Merge branch 'location-reload' of MERMS/MermsPanelReactJS into master 2025-06-25 13:08:28 +00:00
2 changed files with 77 additions and 46 deletions
+30 -25
View File
@@ -1,29 +1,34 @@
import { useQuery } from '@tanstack/react-query' import React, {useEffect} from 'react'
import React from 'react' import { useMutation } from '@tanstack/react-query'
import { productData } from '../../services/services' import { productsData } from '../../services/services'
import queryKeys from '../../services/queryKeys'
import productPath from "../../utils/productpath"; import productPath from "../../utils/productpath";
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
export default function Products() {
const {data, isFetching, isError, error} = useQuery({
queryKey: queryKeys.product, export default function Products() {
queryFn: () => productData() 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(()=>{
"banner": "p1.jpg", let reqData = {
"description": "Your personal professional web presence", token: localStorage.getItem('token'), // USER TOKEN
"id": 1, uid: localStorage.getItem('uid') // USER UID
"name": "Personal Website", }
"product_id": "A000001", getProductsData.mutate(reqData)
"product_uid": "e92282b4-3ee1-4026-92ac-12cfd214b43a", },[])
"status": 5,
"status_text": "Activate Now" const products = getProductsData?.data?.data?.products_data // PRODUCTS DATA
},
*/
//const products = data?.data?.products_list?.products
const products = data?.data?.products_list
return ( return (
<> <>
@@ -32,7 +37,7 @@ export default function Products() {
<h4 className="card-title">My Products</h4> <h4 className="card-title">My Products</h4>
</div> </div>
<div className="card-body pb-0"> <div className="card-body pb-0">
{isFetching ? {getProductsData?.isPending ?
<> <>
<div className="row"> <div className="row">
<div className="col-12"> <div className="col-12">
@@ -40,10 +45,10 @@ export default function Products() {
</div> </div>
</div> </div>
</> </>
: isError ? : getProductsData?.isPending ?
<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'>{getProductsData?.error?.message}</p>
</div> </div>
</div> </div>
: :
+47 -21
View File
@@ -79,29 +79,36 @@ export const topBar = (reqData) => {
export const recentActions = (reqData) => { export const recentActions = (reqData) => {
let postData = { let postData = {
...reqData, ...reqData,
token: localStorage.getItem('token'), // USER TOKEN
uid: localStorage.getItem('uid') // USER UID
} }
//return getAuxEnd(`/panel/account/actions`) //return getAuxEnd(`/panel/account/actions`)
return postAuxEnd(`/panel/account/actions`, postData, false) return postAuxEnd(`/panel/account/actions`, postData, false)
} }
// FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION // FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION
export const productData = () => { export const productsData = (reqData) => {
let postData = { let postData = {
"token":"b", ...reqData,
"uid": 'h'
} }
return postAuxEnd(`/panel/account/products`, postData, false) return postAuxEnd(`/panel/account/products`, postData, false)
} }
// FUNCTION TO GET DASHBOARD PRODUCT URL DATA SECTION // FUNCTION TO GET DASHBOARD PRODUCT URL DATA SECTION
export const productsURL = () => { export const productsURL = (reqData) => {
return getAuxEnd(`/panel/account/products/url`) 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 // FUNCTION TO REGISTER USER
export const signUpUser = (reqData) => { export const signUpUser = (reqData) => {
let postData = { let postData = {
@@ -129,9 +136,11 @@ export const completeRegistration = (reqData) => {
// FUNCTION TO SUBSCRIBE // FUNCTION TO SUBSCRIBE
export const subscribe = (reqData) => { export const subscribe = (reqData) => {
let postData = { let postData = {
...reqData ...reqData,
token: localStorage.getItem('token'), // USER TOKEN
uid: localStorage.getItem('uid') // USER UID
} }
return postAuxEnd('/panel/myproduct/subscription', postData, false) return postAuxEnd(`/panel/myproduct/subscription`, postData, false)
} }
@@ -144,27 +153,44 @@ export const recoverPWD = (reqData) => {
} }
// FUNCTION TO GET CALENDAR EVENTS // FUNCTION TO GET CALENDAR EVENTS
export const getCalendarEvents = () => { export const getCalendarEvents = (reqData) => {
// return getAuxEnd(`/panel/account/calendar`)
let postData = { let postData = {
"a":"b" ...reqData,
token: localStorage.getItem('token'), // USER TOKEN
uid: localStorage.getItem('uid') // USER UID
} }
return postAuxEnd(`/panel/account/calendar`, postData, false) return postAuxEnd(`/panel/account/calendar`, postData, false)
} }
// FUNCTION TO GET MY PRODUCT PROVISION DATA // FUNCTION TO GET MY PRODUCT PROVISION DATA
export const productProvision = (reqData) => { export const productProvision = (reqData) => {
const postData = { ...reqData } let postData = {
return getAuxEnd(`/panel/myproduct/provision`, postData) ...reqData,
token: localStorage.getItem('token'), // USER TOKEN
uid: localStorage.getItem('uid') // USER UID
}
return postAuxEnd(`/panel/myproduct/provision`, postData, false)
// return getAuxEnd(`/panel/myproduct/provision`, postData)
} }
// FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION // FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION
export const contactData = () => { export const contactData = (reqData) => {
return getAuxEnd(`/panel/contacts`) 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`)
} }
export const MyProductData = (productID) => { export const MyProductData = (productID) => {
const reqData = { product_id : productID} const reqData = { product_id : productID}
//console.log(reqData) let postData = {
return getAuxEnd(`/panel/myproduct/dash`,reqData) ...reqData,
token: localStorage.getItem('token'), // USER TOKEN
uid: localStorage.getItem('uid') // USER UID
}
return postAuxEnd(`/panel/myproduct/dash`, postData, false)
// return getAuxEnd(`/panel/myproduct/dash`,reqData)
} }