From b77f1d6213b8373bb9581cd9e3cca51beeb857c0 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sun, 28 Sep 2025 22:43:39 -0400 Subject: [PATCH] display fix --- .../settingsTab/SiteTemplateSelector.jsx | 140 +++++++++--------- .../profile_complete/ProfileCompleteCom.jsx | 2 +- 2 files changed, 75 insertions(+), 67 deletions(-) diff --git a/src/component/product/settingsTab/SiteTemplateSelector.jsx b/src/component/product/settingsTab/SiteTemplateSelector.jsx index 09a4319..465a2f2 100644 --- a/src/component/product/settingsTab/SiteTemplateSelector.jsx +++ b/src/component/product/settingsTab/SiteTemplateSelector.jsx @@ -1,14 +1,14 @@ import React, {memo} from 'react' import getImage from "../../../utils/getImage"; -import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; +import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'; import queryKeys from '../../../services/queryKeys'; -import { getProductTemplateData, activateTemplate } from '../../../services/services'; +import {getProductTemplateData, activateTemplate} from '../../../services/services'; -const SiteTemplateSelector = memo(({name='Full Name', data, productData}) =>{ +const SiteTemplateSelector = memo(({name = 'Full Name', data, productData}) => { const queryClient = useQueryClient() - const {data:templateData, isFetching, isError, error} = useQuery({ + const {data: templateData, isFetching, isError, error} = useQuery({ queryKey: queryKeys.productTemplateData, queryFn: () => { let reqData = { @@ -16,7 +16,7 @@ const SiteTemplateSelector = memo(({name='Full Name', data, productData}) =>{ uid: localStorage.getItem('uid'), // USER UID product_id: productData?.product_id } - return getProductTemplateData(reqData) + return getProductTemplateData(reqData) }, staleTime: 0 }) @@ -24,16 +24,17 @@ const SiteTemplateSelector = memo(({name='Full Name', data, productData}) =>{ const templateResponse = templateData?.data const currentTemUID = templateResponse?.current_template_uid const templates = templateResponse?.templates + const custom_template_name = templateResponse?.custom_template_name // console.log('data Template', templateResponse) - // console.log("Page data == ", data) + console.log("Page data == ", data) const handleActivateTemplate = useMutation({ mutationFn: (fields) => { return activateTemplate(fields) }, onSuccess: (res) => { - if(res?.data?.resultCode != '0'){ + if (res?.data?.resultCode != '0') { throw new Error(res.data.resultDescription) } queryClient.refetchQueries({ // refetches productProvision API call @@ -41,7 +42,7 @@ const SiteTemplateSelector = memo(({name='Full Name', data, productData}) =>{ }) }, onSettled: () => { - setTimeout(()=>{ + setTimeout(() => { handleActivateTemplate.reset() }, 3000) } @@ -57,51 +58,57 @@ const SiteTemplateSelector = memo(({name='Full Name', data, productData}) =>{ // console.log(reqData) handleActivateTemplate.mutate(reqData) } - + if (custom_template_name && custom_template_name != '') { + // This implies we have a custom template , just return here + return <>This product is using a custom template named {custom_template_name} + } return (
- {isFetching ? - <> -
-
-

Loading...

-
-
- - : isError ? -
-
-

{error?.message}

-
-
- : -
+ {isFetching ? <> - {!templates?.length ? -

No data Found

- : - templates.map(template => ( -
-
-
-
-
- {template.title} -
-

{template.title}

- {currentTemUID == template.template_uid ? - - : - - } -
-
-
+
+
+

Loading...

- )) - } - {/* {Object.entries(data)?.map(([key, value]) => ( +
+ + : isError ? +
+
+

{error?.message}

+
+
+ : +
+ <> + {!templates?.length ? +

No data Found

+ : + templates.map(template => ( +
+
+
+
+
+ {template.title}/ +
+

{template.title}

+ {currentTemUID == template.template_uid ? + + : + + } +
+
+
+
+ )) + } + {/* {Object.entries(data)?.map(([key, value]) => (
@@ -116,24 +123,25 @@ const SiteTemplateSelector = memo(({name='Full Name', data, productData}) =>{
))} */} - - -
- <> - {handleActivateTemplate.isPending ? -

loading...

- : - handleActivateTemplate.isError ? -

{handleActivateTemplate.error.message}

- : - handleActivateTemplate.isSuccess? -

Templated activated successfully

- : - null - } - -
-
+ + +
+ <> + {handleActivateTemplate.isPending ? +

loading...

+ : + handleActivateTemplate.isError ? +

{handleActivateTemplate.error.message}

+ : + handleActivateTemplate.isSuccess ? +

Templated activated + successfully

+ : + null + } + +
+
}
diff --git a/src/component/profile_complete/ProfileCompleteCom.jsx b/src/component/profile_complete/ProfileCompleteCom.jsx index 7f50c5c..d9072a5 100644 --- a/src/component/profile_complete/ProfileCompleteCom.jsx +++ b/src/component/profile_complete/ProfileCompleteCom.jsx @@ -54,7 +54,7 @@ export default function ProfileCompleteCom() { mutationFn: (fields) => { const {practice, specialization, url_name} = fields if (!practice || !specialization || !url_name) { - throw new Error('Please select both practice, specialization and Enter URL_Name') + throw new Error('Please Select both Practice, Specialization and Enter URL_Name') } return completeProfile(fields) },