Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ea1047356 | |||
| 9b9a7cc5da | |||
| 290e1fbd7e | |||
| 6884aa19b2 | |||
| 597a45dcba | |||
| 4f7274c30c | |||
| 290356780c |
@@ -51,4 +51,11 @@ button{
|
|||||||
|
|
||||||
.accordion-button, .accordion-button:not(.collapsed) {
|
.accordion-button, .accordion-button:not(.collapsed) {
|
||||||
background-color: transparent!important;
|
background-color: transparent!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 992px) {
|
||||||
|
.modal-50 {
|
||||||
|
min-width: 50%;
|
||||||
|
max-width: 50%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ console.log('imageLink', imageLink)
|
|||||||
|
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-xl-6 col-xxl-4 m-b-30">
|
<div className="col-xl-6 col-xxl-4 m-b-30">
|
||||||
<div className="card card-statistics h-50 mb-0 widget-support-list">
|
<div className="card card-statistics mb-0 widget-support-list">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<div className="card-heading">
|
<div className="card-heading">
|
||||||
<h4 className="card-title">Upload File</h4>
|
<h4 className="card-title">Upload File</h4>
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ const Settings = memo(({productData}) => {
|
|||||||
))}
|
))}
|
||||||
<div className={`tab-pane fade ${(activeTab == 'config_temp') && 'active show'}`}
|
<div className={`tab-pane fade ${(activeTab == 'config_temp') && 'active show'}`}
|
||||||
>
|
>
|
||||||
<TemplateConfigure />
|
<TemplateConfigure productData={productData} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,24 +1,127 @@
|
|||||||
|
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} from '../../../services/services';
|
||||||
|
import {Link} from "react-router-dom";
|
||||||
|
import siteLinks from "../../../links/siteLinks";
|
||||||
|
import UploadModal from './UploadModal';
|
||||||
|
|
||||||
const TemplateConfigure = ({productData}) => {
|
const TemplateConfigure = ({productData}) => {
|
||||||
|
|
||||||
|
// /panel/myproduct/template-config
|
||||||
|
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
const {data: templateData, isFetching, isError, error} = useQuery({
|
||||||
|
queryKey: queryKeys.myTemplateConfig,
|
||||||
|
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
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<div className="card card-statistics">
|
<div className="card card-statistics">
|
||||||
<div className="card-header">
|
{isFetching ?
|
||||||
<div className="card-heading">
|
<>
|
||||||
<h4 className="card-title" style={{textTransform: 'none'}}>Some headings</h4>
|
<div className="row">
|
||||||
</div>
|
<div className="col-12">
|
||||||
</div>
|
<p className='text-mute'>Loading...</p>
|
||||||
{/*<div className="card-body">*/}
|
</div>
|
||||||
{/* <div className="form-group">*/}
|
</div>
|
||||||
{/* /!*<label htmlFor="exampleInputEmail1">Email address</label>*!/*/}
|
</>
|
||||||
{/* <input type="email" className="form-control"*/}
|
: isError ?
|
||||||
{/* aria-describedby="defaultUrlHelp" value={defaultUrl} readOnly={true} />*/}
|
<div className="row">
|
||||||
{/* </div>*/}
|
<div className="col-12">
|
||||||
{/*</div>*/}
|
<p className='text-danger'>{error?.message}</p>
|
||||||
</div>
|
</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 className='d-flex justify-content-center align-items-center' style={{padding: '6px', width: '120px', height: '100px'}}>
|
||||||
|
<img className="mb-xxs-0 img-fluid"
|
||||||
|
style={{height: 'auto', maxHeight: '100px'}}
|
||||||
|
src={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 className='w-100 text-end' data-bs-toggle="modal" data-bs-target="#verticalCenter" style={{cursor: 'pointer'}}>[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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</>
|
||||||
|
|
||||||
|
|
||||||
|
} </div>
|
||||||
|
<UploadModal />
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
import React, { useRef, useState } from 'react'
|
||||||
|
import { Modal } from "bootstrap";
|
||||||
|
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
||||||
|
import queryKeys from '../../../services/queryKeys';
|
||||||
|
import {getMediaFileList, getTemplateConfig, uploadFile} from '../../../services/services';
|
||||||
|
|
||||||
|
export default function UploadModal() {
|
||||||
|
|
||||||
|
const [selectedFiles, setSelectedFiles] = useState([])
|
||||||
|
|
||||||
|
const handleSelectedFiles = (file_uid) => {
|
||||||
|
if(selectedFiles.length && selectedFiles.includes(file_uid)){
|
||||||
|
let indexOfItem = selectedFiles.indexOf(file_uid)
|
||||||
|
let oldFiles = [...selectedFiles]
|
||||||
|
oldFiles.splice(indexOfItem, 1)
|
||||||
|
setSelectedFiles(oldFiles)
|
||||||
|
}else{
|
||||||
|
setSelectedFiles(prev => [...prev, file_uid])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const modalRef = useRef(null)
|
||||||
|
|
||||||
|
const dismissModal = () => {
|
||||||
|
const body = document.querySelector('body')
|
||||||
|
body.removeAttribute('style')
|
||||||
|
// body.classList.toggle('modal-open')
|
||||||
|
|
||||||
|
const modalBackdrop = document.querySelectorAll('.modal-backdrop')
|
||||||
|
modalBackdrop.forEach(item => {
|
||||||
|
if (item) {
|
||||||
|
item.remove();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const modal = Modal.getInstance(modalRef.current);
|
||||||
|
modal && modal.hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
const uploadFileMutation = useMutation({
|
||||||
|
mutationFn: (fields) => {
|
||||||
|
if(!fields.file){
|
||||||
|
throw({message: 'Please select a file first!'})
|
||||||
|
}
|
||||||
|
// return uploadFile(fields)
|
||||||
|
// remember to close the modal
|
||||||
|
dismissModal()
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
const {data, isFetching, isError, error} = useQuery({
|
||||||
|
queryKey: queryKeys.my_files,
|
||||||
|
queryFn: () => {
|
||||||
|
let reqData = {
|
||||||
|
token: localStorage.getItem('token'), // USER TOKEN
|
||||||
|
uid: localStorage.getItem('uid') // USER UID
|
||||||
|
}
|
||||||
|
return getMediaFileList(reqData)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const mediaFileList = data?.data
|
||||||
|
// console.log('mediaFileList', mediaFileList) //file_list
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{/* Vertical Center Modal */}
|
||||||
|
<div ref={modalRef} className="modal fade" id="verticalCenter" tabIndex="-1" role="dialog" aria-hidden="false">
|
||||||
|
<div className="modal-50 modal-dialog modal-dialog-centered modal-50" role="document">
|
||||||
|
<div className="modal-content">
|
||||||
|
<div className="modal-header">
|
||||||
|
<h5 className="modal-title" style={{fontSize: '18px'}} id="verticalCenterTitle">Select New Picture</h5>
|
||||||
|
<button type="button" className="close" data-bs-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="modal-body">
|
||||||
|
{isFetching ?
|
||||||
|
<>
|
||||||
|
<div className="col-12">
|
||||||
|
<p className='text-mute'>Loading...</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
: isError ?
|
||||||
|
<div className="col-12">
|
||||||
|
<p className='text-danger'>{error?.message}</p>
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
<div className='row g-5 justify-content-center'>
|
||||||
|
{mediaFileList?.file_list?.length ?
|
||||||
|
<>
|
||||||
|
{mediaFileList?.file_list?.map(item => {
|
||||||
|
const file_url = (mediaFileList?.media_server + "/" + item?.file_group + "/" + item?.file_uid + "/" + item.filename).toLowerCase();
|
||||||
|
return(
|
||||||
|
<div onClick={()=>handleSelectedFiles(item?.file_uid)} className={`p-3 text-center col-4`} style={{cursor: 'pointer'}}>
|
||||||
|
<div className={`p-3 ${selectedFiles.includes(item?.file_uid) && 'bg-light'}`}>
|
||||||
|
<img key={item?.file_uid} className="img-fluid" src={file_url} alt='file-image' />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</>
|
||||||
|
:
|
||||||
|
<p>No File(s) found!</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{/* <div style={{fontSize: '18px'}} className="" dangerouslySetInnerHTML={{__html: saleText}}/> */}
|
||||||
|
{/* {mutation.error &&
|
||||||
|
<>
|
||||||
|
<div className="col-12">
|
||||||
|
<p className='text-danger'>{mutation.error.message}</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
{mutation.isSuccess &&
|
||||||
|
<>
|
||||||
|
<div className="col-12">
|
||||||
|
<p className='text-success'>{'subscription is successful'}</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
} */}
|
||||||
|
|
||||||
|
{/* {requestStatus.message && (
|
||||||
|
<div className="col-12">
|
||||||
|
<p className={`p-2 text-center ${requestStatus.status ? 'text-success' : 'text-danger'}`}>{requestStatus.message}</p>
|
||||||
|
</div>
|
||||||
|
)} */}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div className="modal-footer">
|
||||||
|
<button type="button" className="btn btn-danger" data-bs-dismiss="modal">Cancel</button>
|
||||||
|
{selectedFiles.length > 0 &&
|
||||||
|
<button type="button" className="btn btn-primary" disabled={uploadFileMutation?.isPending || uploadFileMutation?.isSuccess} onClick={handleUpload}>{uploadFileMutation?.isPending ? 'Upload...' : uploadFileMutation?.isSuccess ? 'Uploaded' : 'Upload'}</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* END of Vertical Center Modal */}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ const queryKeys = {
|
|||||||
recentAction: ['recent-action'],
|
recentAction: ['recent-action'],
|
||||||
settingsData: ['settings_data'],
|
settingsData: ['settings_data'],
|
||||||
myProductConfig: ['myproduct_config'],
|
myProductConfig: ['myproduct_config'],
|
||||||
|
myTemplateConfig: ['mytemplate_config'],
|
||||||
productTemplateData: ['product_template_data'],
|
productTemplateData: ['product_template_data'],
|
||||||
subscriptions: ['subscriptions'],
|
subscriptions: ['subscriptions'],
|
||||||
profile_data: ['profile_data'],
|
profile_data: ['profile_data'],
|
||||||
|
|||||||
@@ -244,6 +244,14 @@ export const getProductColorStyles = (reqData) => {
|
|||||||
}
|
}
|
||||||
return postAuxEnd(`/panel/account/products/color-styles`, postData, false)
|
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
|
// FUNCTION TO ACTIVATE TEMPLATE
|
||||||
export const activateTemplate = (reqData) => {
|
export const activateTemplate = (reqData) => {
|
||||||
let postData = {
|
let postData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user