Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6884aa19b2 | |||
| 597a45dcba | |||
| 4f7274c30c | |||
| 290356780c | |||
| bd1450887b | |||
| 923a2483ed | |||
| 7f0ccf35b2 |
@@ -66,7 +66,7 @@ export default function ProductActive({productData}){
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-body" style={{minHeight: '680px'}}>
|
||||
<div className="card-body" style={{minHeight: '600px', maxHeight: '600px'}}>
|
||||
<iframe ref={iframe} style={{borderWidth: '0px'}} src={externalUrl} width="100%" height="600" title={externalUrl}></iframe>
|
||||
</div>
|
||||
<div className="p-4 ml-auto">
|
||||
|
||||
@@ -5,6 +5,7 @@ import queryKeys from '../../../services/queryKeys';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import sortObjectByListOrder from '../../../helpers/sortObjectByListOrder'
|
||||
import TemplateConfigure from './TemplateConfigure';
|
||||
|
||||
const Settings = memo(({productData}) => {
|
||||
|
||||
@@ -24,7 +25,7 @@ const Settings = memo(({productData}) => {
|
||||
})
|
||||
const settingsConfig = configData?.data?.settings_items
|
||||
// console.log('CONFIG DATA...', settingsConfig)
|
||||
|
||||
// console.log('configData', configData?.data?.subscription_template)
|
||||
|
||||
const [fieldsChanged, setFieldsChanged] = useState(false)
|
||||
|
||||
@@ -81,12 +82,12 @@ const Settings = memo(({productData}) => {
|
||||
</div>
|
||||
</div>
|
||||
:
|
||||
<div className="tab tab-vertical">
|
||||
<ul className="nav nav-tabs" role="tablist">
|
||||
<div className="d-flex">
|
||||
<ul className="bg-body-secondary flex-column nav" role="tablist" style={{width: '25%', minHeight: '670px', maxHeight: '670px'}}>
|
||||
<>
|
||||
{Object.entries(sortedSettingsConfig).map(([key, value], index) => (
|
||||
<li key={key} className="nav-item">
|
||||
<a className={`nav-link ${(activeTab == value.controls || (index == 0 & !activeTab)) && 'active show'}`}
|
||||
<p className={`text-black nav-link ${(activeTab == value.controls || (index == 0 & !activeTab)) && 'active show bg-primary text-white'}`}
|
||||
id={key}
|
||||
// data-bs-toggle="pill"
|
||||
// data-bs-target={`#${value.controls}`}
|
||||
@@ -97,12 +98,27 @@ const Settings = memo(({productData}) => {
|
||||
onClick={()=>handleChangeTab(value.controls)}
|
||||
>
|
||||
{value.title}
|
||||
</a>
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
{configData?.data?.subscription_template &&
|
||||
<li className="mt-auto nav-item">
|
||||
<p className={`text-black nav-link ${(activeTab == 'config_temp') && 'active show bg-primary text-white'}`}
|
||||
// data-bs-toggle="pill"
|
||||
// data-bs-target={`#${value.controls}`}
|
||||
type="button"
|
||||
// role="tab"
|
||||
// aria-controls={value.controls}
|
||||
// aria-selected="true"
|
||||
onClick={()=>handleChangeTab('config_temp')}
|
||||
>
|
||||
Configure Template
|
||||
</p>
|
||||
</li>
|
||||
}
|
||||
</>
|
||||
</ul>
|
||||
<div className="tab-content">
|
||||
<div className="p-3 tab-content" style={{width: '75%'}}>
|
||||
<>
|
||||
{Object.entries(sortedSettingsConfig).map(([key, value], index) => (
|
||||
<div key={key} className={`tab-pane fade ${(activeTab == value.controls || (index == 0 & !activeTab)) && 'active show'}`}
|
||||
@@ -112,6 +128,10 @@ const Settings = memo(({productData}) => {
|
||||
<GeneralTab tabKey={key} name={value.title} data={value.data} isCustom={value.custom} productData={productData} backendValues={settingsData} setFieldsChanged={setFieldsChanged} />
|
||||
</div>
|
||||
))}
|
||||
<div className={`tab-pane fade ${(activeTab == 'config_temp') && 'active show'}`}
|
||||
>
|
||||
<TemplateConfigure productData={productData} />
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
import React, {memo, useState} from 'react'
|
||||
import getImage from "../../../utils/getImage";
|
||||
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
||||
import queryKeys from '../../../services/queryKeys';
|
||||
import {
|
||||
getTemplateConfig,
|
||||
uploadFile,
|
||||
} from '../../../services/services';
|
||||
import {Link} from "react-router-dom";
|
||||
import siteLinks from "../../../links/siteLinks";
|
||||
|
||||
const TemplateConfigure = ({productData}) => {
|
||||
|
||||
const [selectedFile, setSelectedFile] = useState({id: '', img: ''});
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
setSelectedFile({id: event.target.id, img:event.target.files[0]});
|
||||
};
|
||||
|
||||
// /panel/myproduct/template-config
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const {data: templateData, isFetching, isError, error} = useQuery({
|
||||
queryKey: queryKeys.templateConfigItems,
|
||||
queryFn: () => {
|
||||
let reqData = {
|
||||
token: localStorage.getItem('token'), // USER TOKEN
|
||||
uid: localStorage.getItem('uid'), // USER UID
|
||||
product_id: productData?.product_id
|
||||
}
|
||||
return getTemplateConfig(reqData)
|
||||
},
|
||||
staleTime: 0
|
||||
})
|
||||
|
||||
const templateResponse = templateData?.data
|
||||
const templateImages = templateResponse?.template_images?.data;
|
||||
// debugger;
|
||||
console.log("templateResponse", templateResponse);
|
||||
// const currentColorUID = templateResponse?.current_colorstyle_uid
|
||||
// const color_styles = templateResponse?.color_styles
|
||||
// const custom_template_name = templateResponse?.custom_template_name
|
||||
//
|
||||
|
||||
const uploadFileMutation = useMutation({
|
||||
mutationFn: (fields) => {
|
||||
if(!fields.file){
|
||||
throw({message: 'Please select a file first!'})
|
||||
}
|
||||
// return uploadFile(fields)
|
||||
setTimeout(()=>{
|
||||
uploadFileMutation.reset()
|
||||
}, 3000)
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
// console.log('res', res.data)
|
||||
// if(res.data.resultCode != '0' || !res?.data?.pending_uid){
|
||||
// throw({message: res?.data?.resultDescription})
|
||||
// }
|
||||
setSelectedFile({id: '', img: ''})
|
||||
// queryClient.refetchQueries({
|
||||
// queryKey: [...queryKeys.my_files],
|
||||
// type: 'active',
|
||||
// exact: true,
|
||||
// })
|
||||
},
|
||||
onSettled: () => {
|
||||
setTimeout(()=>{
|
||||
uploadFileMutation.reset()
|
||||
}, 3000)
|
||||
}
|
||||
})
|
||||
|
||||
const handleUpload = () => {
|
||||
let reqData = {
|
||||
token: localStorage.getItem("token"), // USER TOKEN
|
||||
member_uid: localStorage.getItem("uid"), // USER UID
|
||||
file: selectedFile?.img
|
||||
};
|
||||
uploadFileMutation.mutate(reqData)
|
||||
}
|
||||
|
||||
return <>
|
||||
<div className="card card-statistics">
|
||||
{isFetching ?
|
||||
<>
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<p className='text-mute'>Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
: isError ?
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<p className='text-danger'>{error?.message}</p>
|
||||
</div>
|
||||
</div>
|
||||
:
|
||||
<>
|
||||
<div className="card-header">
|
||||
<div className="card-heading">
|
||||
<h4 className="card-title"
|
||||
style={{textTransform: 'none'}}>{templateResponse?.template_name}</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<div className="col-12">
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<h4>Image List</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<ul className="list-unstyled">
|
||||
{templateImages && templateImages.map(
|
||||
(item) => {
|
||||
const currImage = item?.default_val;
|
||||
return (
|
||||
<li className="media">
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
padding: '5px',
|
||||
backgroundColor: 'aliceblue',
|
||||
margin: '2px',
|
||||
maxHeight: '150px'
|
||||
}}>
|
||||
<div style={{padding: '2px'}}>
|
||||
<img className="mr-5 mb-3 mb-xxs-0 img-fluid"
|
||||
style={{width: 'auto', height: '100px',}}
|
||||
src={(selectedFile?.img && selectedFile?.id == item?.id) ? URL.createObjectURL(selectedFile?.img) : currImage} alt="image"/>
|
||||
</div>
|
||||
|
||||
<div className="media-body" style={{padding: '2px'}}>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
}}>
|
||||
<div style={{textAlign: 'right',width: '100%'}}></div>
|
||||
{/* [Change Image] */}
|
||||
<label htmlFor={item?.id}>[Change Image]</label>
|
||||
<input id={item?.id} name={item?.id} className="d-none form-control form-control-sm" type="file" onChange={handleFileChange}/>
|
||||
<div>
|
||||
<h5 className="mt-0 mb-1">{item?.name}</h5>
|
||||
{item?.description}
|
||||
</div>
|
||||
</div>
|
||||
{(selectedFile.img && selectedFile?.id == item?.id) &&
|
||||
<div style={{width: '100%', textAlign: 'right'}}>
|
||||
<button
|
||||
className="btn btn-square btn-inverse-light btn-xs d-inline-block mt-2 mb-0"
|
||||
onClick={handleUpload}
|
||||
disabled={!selectedFile?.img || uploadFileMutation.isPending || uploadFileMutation.isSuccess}
|
||||
>
|
||||
{uploadFileMutation.isPending ? 'Loading' : uploadFileMutation.isSuccess ? 'Uploaded' : 'Upload'}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</>
|
||||
|
||||
|
||||
} </div>
|
||||
</>
|
||||
}
|
||||
|
||||
export default TemplateConfigure
|
||||
@@ -244,6 +244,14 @@ export const getProductColorStyles = (reqData) => {
|
||||
}
|
||||
return postAuxEnd(`/panel/account/products/color-styles`, postData, false)
|
||||
}
|
||||
|
||||
export const getTemplateConfig = (reqData) => {
|
||||
let postData = {
|
||||
...reqData,
|
||||
}
|
||||
return postAuxEnd(`/panel/myproduct/template-config`, postData, false)
|
||||
}
|
||||
|
||||
// FUNCTION TO ACTIVATE TEMPLATE
|
||||
export const activateTemplate = (reqData) => {
|
||||
let postData = {
|
||||
|
||||
Reference in New Issue
Block a user