diff --git a/src/assets/img/product/p6.jpg b/src/assets/img/product/p6.jpg new file mode 100644 index 0000000..af5c66d Binary files /dev/null and b/src/assets/img/product/p6.jpg differ diff --git a/src/component/product/ProductActive.jsx b/src/component/product/ProductActive.jsx index d51e341..fbed335 100644 --- a/src/component/product/ProductActive.jsx +++ b/src/component/product/ProductActive.jsx @@ -66,7 +66,7 @@ export default function ProductActive({productData}){ -
+
@@ -87,7 +87,7 @@ export default function ProductActive({productData}){

Site Settings

-
+
diff --git a/src/component/product/ProductProvision.jsx b/src/component/product/ProductProvision.jsx index 8bdc67f..1410c03 100644 --- a/src/component/product/ProductProvision.jsx +++ b/src/component/product/ProductProvision.jsx @@ -28,7 +28,7 @@ export default function ProductProvision(props) { const provisionData = provision?.data useEffect(() => { - const provision_room = "PROVISION_"+productSubUID; + const provision_room = "PROVISION_" + productSubUID; console.log("JOINING ROOM ON START *** ", provision_room); joinRoom(provision_room); // provision subscription room }, []) diff --git a/src/component/product/settingsTab/ColorStyleConfigure.jsx b/src/component/product/settingsTab/ColorStyleConfigure.jsx index 54822a2..e79e4b1 100644 --- a/src/component/product/settingsTab/ColorStyleConfigure.jsx +++ b/src/component/product/settingsTab/ColorStyleConfigure.jsx @@ -1,6 +1,174 @@ -const ColorStyleConfigure =()=>{ +import React, {memo} from 'react' +import getImage from "../../../utils/getImage"; +import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'; +import queryKeys from '../../../services/queryKeys'; +import { + getProductcolorStyleCss, + activateTemplate, + getProductColorStyles, + activateColorStyle +} from '../../../services/services'; +import {Link} from "react-router-dom"; +import siteLinks from "../../../links/siteLinks"; - return <>COLOR CONFIG -} +const ColorStyleConfigure = memo(({name = 'Full Name', data, productData}) => { -export default ColorStyleConfigure \ No newline at end of file + const queryClient = useQueryClient() + + const {data: colorStyleCss, isFetching, isError, error} = useQuery({ + queryKey: queryKeys.productcolorStyleCss, + queryFn: () => { + let reqData = { + token: localStorage.getItem('token'), // USER TOKEN + uid: localStorage.getItem('uid'), // USER UID + product_id: productData?.product_id + } + return getProductColorStyles(reqData) + }, + staleTime: 0 + }) + + const templateResponse = colorStyleCss?.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) + + const handleActivateTemplate = useMutation({ + mutationFn: (fields) => { + return activateColorStyle(fields) + }, + onSuccess: (res) => { + if (res?.data?.resultCode != '0') { + throw new Error(res.data.resultDescription) + } + queryClient.refetchQueries({ // refetches productProvision API call + queryKey: [...queryKeys.settingsData], + }) + }, + onSettled: () => { + setTimeout(() => { + handleActivateTemplate.reset() + }, 3000) + } + }) + + const handleSubmit = (style_uid) => { + const reqData = { + token: localStorage.getItem('token'), // USER TOKEN + uid: localStorage.getItem('uid'), // USER UID + product_id: productData?.product_id, + color_style_uid: style_uid + } + // console.log(reqData) + handleActivateTemplate.mutate(reqData) + } + if (custom_template_name && custom_template_name != '') { + // This implies we have a custom template , just return here + return <> +
+
+

Custom Product Template.

+ mail-alert +

This product is using a custom template named “{custom_template_name}” .

+
+
+ + + } + return ( +
+
+ {isFetching ? + <> +
+
+

Loading...

+
+
+ + : isError ? +
+
+

{error?.message}

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

No data Found

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

{color_style.title}

+ {currentTemUID === color_style.color_style_uid ? + + : + + } +
+
+
+
+ )) + } + {/* {Object.entries(data)?.map(([key, value]) => ( +
+
+
+
+
+ {value.title} +
+

{value.title}

+ Activate +
+
+
+
+ ))} */} + + +
+ <> + {handleActivateTemplate.isPending ? +

loading...

+ : + handleActivateTemplate.isError ? +

{handleActivateTemplate.error.message}

+ : + handleActivateTemplate.isSuccess ? +

Templated activated + successfully

+ : + null + } + +
+
+ } +
+
+ ) + } +) +export default ColorStyleConfigure \ No newline at end of file diff --git a/src/component/product/settingsTab/GeneralTab.jsx b/src/component/product/settingsTab/GeneralTab.jsx index 1a1b8f2..15849ec 100644 --- a/src/component/product/settingsTab/GeneralTab.jsx +++ b/src/component/product/settingsTab/GeneralTab.jsx @@ -112,9 +112,15 @@ const GeneralTab = memo(({ <> {isCustom === true ? <> - {(tabKey === 'template_tab') && } - {(tabKey === 'url_config_tab') && } - {(tabKey === 'color_scheme_tab') && } + {(tabKey === 'template_tab') && + } + {(tabKey === 'url_config_tab') && + } + {(tabKey === 'color_scheme_tab') && + } :
diff --git a/src/services/services.js b/src/services/services.js index 0a281a8..1cd36dd 100644 --- a/src/services/services.js +++ b/src/services/services.js @@ -214,6 +214,12 @@ export const getProductTemplateData = (reqData) => { return postAuxEnd(`/panel/account/products/templates`, postData, false) } +export const getProductColorStyles = (reqData) => { + let postData = { + ...reqData, + } + return postAuxEnd(`/panel/account/products/color-styles`, postData, false) +} // FUNCTION TO ACTIVATE TEMPLATE export const activateTemplate = (reqData) => { let postData = { @@ -222,6 +228,14 @@ export const activateTemplate = (reqData) => { return postAuxEnd(`/panel/account/template/activate`, postData, false) } +export const activateColorStyle = (reqData) => { + let postData = { + ...reqData, + } + return postAuxEnd(`/panel/account/colorstyle/activate`, postData, false) +} + + // FUNCTION TO GET PRODUCT SUBSCRIPTIONS export const completeProfile = (reqData) => { let postData = {