Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb4b0e89c7 | |||
| b898f7c3e3 | |||
| a5fc0890b4 |
@@ -66,7 +66,7 @@ export default function UserExist() {
|
|||||||
navigate(RouteLinks.login, {replace:true})
|
navigate(RouteLinks.login, {replace:true})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(userDetails.name){
|
if(userDetails?.email || userDetails?.username){
|
||||||
setPageIsLoading(false)
|
setPageIsLoading(false)
|
||||||
}else if(!userDetails.name && localStorage.getItem('token')){
|
}else if(!userDetails.name && localStorage.getItem('token')){
|
||||||
loadUser(localStorage.getItem('token'))
|
loadUser(localStorage.getItem('token'))
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ export default function LoginCom() {
|
|||||||
const {jwt_token, user} = res?.data
|
const {jwt_token, user} = res?.data
|
||||||
if (jwt_token) {
|
if (jwt_token) {
|
||||||
localStorage.setItem('token', jwt_token)
|
localStorage.setItem('token', jwt_token)
|
||||||
// localStorage.setItem('room', room)
|
dispatch(updateUserDetails({jwt_token, ...user}));
|
||||||
const data = {jwt_token}
|
|
||||||
dispatch(updateUserDetails({...data, ...user}));
|
|
||||||
}
|
}
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
navigate(RouteLinks.homePage, {state: {proceed: 'true'}}) // later add redux to dispatch state
|
navigate(RouteLinks.homePage, {state: {proceed: 'true'}}) // later add redux to dispatch state
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useSelector } from "react-redux";
|
||||||
import { LuSunDim } from "react-icons/lu";
|
import { LuSunDim } from "react-icons/lu";
|
||||||
import { IoMdSunny } from "react-icons/io";
|
import { IoMdSunny } from "react-icons/io";
|
||||||
|
|
||||||
@@ -17,6 +18,8 @@ export default function DashboardHeader() {
|
|||||||
|
|
||||||
const {theme, handleTheme, setLogoutModal, activeMenu, handleActiveMenu, showAsideDrawer, setShowAsideDrawer} = GeneralLayoutContext()
|
const {theme, handleTheme, setLogoutModal, activeMenu, handleActiveMenu, showAsideDrawer, setShowAsideDrawer} = GeneralLayoutContext()
|
||||||
|
|
||||||
|
const {userDetails:{username, email}} = useSelector((state) => state.userDetails) // GETS LOGGED IN USER
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* HEADER SECTION*/}
|
{/* HEADER SECTION*/}
|
||||||
@@ -60,8 +63,8 @@ export default function DashboardHeader() {
|
|||||||
<div className="pop-modal z-[777] absolute p-4 w-52 sm:w-96 bg-white dark:bg-black-box right-0 top-16 rounded shadow-round_black dark:shadow-round_white">
|
<div className="pop-modal z-[777] absolute p-4 w-52 sm:w-96 bg-white dark:bg-black-box right-0 top-16 rounded shadow-round_black dark:shadow-round_white">
|
||||||
<div className="w-full h-full flex flex-col gap-4">
|
<div className="w-full h-full flex flex-col gap-4">
|
||||||
<div className="flex flex-col text-black dark:text-white text-base sm:text-lg">
|
<div className="flex flex-col text-black dark:text-white text-base sm:text-lg">
|
||||||
<h1 className="font-semibold">Username</h1>
|
<h1 className="font-semibold">{username}</h1>
|
||||||
<p className="-mt-2">username@gmail.com</p>
|
<p className="-mt-2">{email}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="rounded w-full flex justify-center items-center gap-2">
|
<div className="rounded w-full flex justify-center items-center gap-2">
|
||||||
<MainBtn
|
<MainBtn
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import DashboardHeader from './DashboardHeader'
|
|||||||
import { GeneralLayoutContext } from '../../context/GeneralLayoutContext'
|
import { GeneralLayoutContext } from '../../context/GeneralLayoutContext'
|
||||||
import DashboardAside from './aside/DashboardAside'
|
import DashboardAside from './aside/DashboardAside'
|
||||||
import RightAsideBar from './rightaside/RightAsideBar'
|
import RightAsideBar from './rightaside/RightAsideBar'
|
||||||
|
import { memo } from 'react'
|
||||||
|
|
||||||
export default function DashboardLayout() {
|
const DashboardLayout =memo(()=> {
|
||||||
|
|
||||||
// let {pathname} = useLocation()
|
// let {pathname} = useLocation()
|
||||||
|
|
||||||
@@ -54,4 +55,6 @@ export default function DashboardLayout() {
|
|||||||
</>
|
</>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
|
export default DashboardLayout
|
||||||
@@ -1,22 +1,23 @@
|
|||||||
import {useLocation} from 'react-router-dom'
|
import {useLocation} from 'react-router-dom'
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
import RouteLinks from "../../../RouteLinks";
|
import RouteLinks from "../../../RouteLinks";
|
||||||
import DummyLogo from "../../DummyLogo";
|
import DummyLogo from "../../DummyLogo";
|
||||||
import MainBtn from "../../MainBtn";
|
import MainBtn from "../../MainBtn";
|
||||||
import AsideLink from "./AsideLink";
|
import AsideLink from "./AsideLink";
|
||||||
import AsideLinkWithSubLinks from "./AsideLinkWithSubLinks";
|
import AsideLinkWithSubLinks from "./AsideLinkWithSubLinks";
|
||||||
// import { useSelector } from "react-redux";
|
|
||||||
import {GeneralLayoutContext} from "../../../context/GeneralLayoutContext";
|
import {GeneralLayoutContext} from "../../../context/GeneralLayoutContext";
|
||||||
import {TbLogout2} from "react-icons/tb";
|
import {TbLogout2} from "react-icons/tb";
|
||||||
import UserAvatar from '../../../assets/user_avatar.jpg'
|
import UserAvatar from '../../../assets/user_avatar.jpg'
|
||||||
import Icons from "../../Icons";
|
import Icons from "../../Icons";
|
||||||
|
|
||||||
|
|
||||||
export default function DashboardAside() {
|
export default function DashboardAside() {
|
||||||
|
|
||||||
const {pathname} = useLocation()
|
const {pathname} = useLocation()
|
||||||
|
|
||||||
const {setLogoutModal, handleActiveMenu} = GeneralLayoutContext()
|
const {setLogoutModal, handleActiveMenu} = GeneralLayoutContext()
|
||||||
|
|
||||||
// const {userDetails} = useSelector((state) => state.userDetails) // GETS LOGGED IN USER ROLE DETAILS
|
const {userDetails:{username, email}} = useSelector((state) => state.userDetails) // GETS LOGGED IN USER
|
||||||
// const {role}= userDetails
|
// const {role}= userDetails
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -126,8 +127,8 @@ export default function DashboardAside() {
|
|||||||
<div className="w-full min-h-48 flex flex-col justify-between gap-4">
|
<div className="w-full min-h-48 flex flex-col justify-between gap-4">
|
||||||
<div className="w-full h-full">
|
<div className="w-full h-full">
|
||||||
<div className="flex flex-col text-black dark:text-white text-base sm:text-lg">
|
<div className="flex flex-col text-black dark:text-white text-base sm:text-lg">
|
||||||
<h1 className="font-semibold">Username</h1>
|
<h1 className="font-semibold">{username}</h1>
|
||||||
<p className="-mt-2">username@gmail.com</p>
|
<p className="-mt-2">{email}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="rounded w-full flex items-center gap-2">
|
<div className="rounded w-full flex items-center gap-2">
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import ModalWrapper from '../modals/ModalWrapper'
|
||||||
|
import MainBtn from '../MainBtn'
|
||||||
|
|
||||||
|
export default function RebuildModal({data={}, templateRebuild, closeModal, proceedFunc}) {
|
||||||
|
return (
|
||||||
|
<ModalWrapper maxWidth='max-w-sm'>
|
||||||
|
<div className='relative bg-white rounded-lg shadow-round_black dark:border-[1px] dark:border-[#1E2027] dark:bg-black-box dark:text-white'>
|
||||||
|
{/* <!-- Modal header --> */}
|
||||||
|
{/* <div className="p-8 sm:p-12 flex items-center justify-between border-b rounded-t border-gray-300 dark:border-gray-600">
|
||||||
|
<h3 className="text-xl font-semibold text-gray-900 dark:text-white">
|
||||||
|
EDIT
|
||||||
|
</h3>
|
||||||
|
<button onClick={closeModal} type="button" className="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-hide="default-modal">
|
||||||
|
<svg className="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
||||||
|
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
||||||
|
</svg>
|
||||||
|
<span className="sr-only">Close modal</span>
|
||||||
|
</button>
|
||||||
|
</div> */}
|
||||||
|
{/* <!-- Modal body --> */}
|
||||||
|
<div className='p-8 sm:p-12 mb-4 flex flex-col flex-wrap gap-4 lg:gap-8'>
|
||||||
|
<div className='w-full text-center'>
|
||||||
|
<p className='text-lg font-semibold mb-1'>Please confirm you want product rebuild to start</p>
|
||||||
|
{templateRebuild.isPending && <p className='text-sm text-emerald-600'>Rebuild started ...</p>}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between items-center gap-4'>
|
||||||
|
<MainBtn
|
||||||
|
onClick={proceedFunc}
|
||||||
|
className={`bg-primary dark:bg-primary-dark px-2 py-1 mt-4 rounded-md text-white font-medium sm:self-end`}
|
||||||
|
text='Proceed'
|
||||||
|
/>
|
||||||
|
<MainBtn
|
||||||
|
type='button'
|
||||||
|
className={`bg-red-500 px-2 py-1 mt-4 rounded-md text-white font-medium sm:self-end`}
|
||||||
|
text='Cancel'
|
||||||
|
onClick={closeModal}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ModalWrapper>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
import {useLocation, useNavigate, Link} from 'react-router-dom'
|
import {useLocation, useNavigate, Link} from 'react-router-dom'
|
||||||
import { useQuery, useMutation } from '@tanstack/react-query'
|
import {useQuery, useMutation} from '@tanstack/react-query'
|
||||||
import { FaCaretDown } from "react-icons/fa";
|
import {FaCaretDown} from "react-icons/fa";
|
||||||
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
|
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
|
||||||
import {useEffect, useState} from 'react';
|
import {useEffect, useState} from 'react';
|
||||||
import RouteLinks from '../../RouteLinks';
|
import RouteLinks from '../../RouteLinks';
|
||||||
import { getSubscriptionsView, updateTemplate, updateCustomTemplate } from '../../services/siteServices'
|
import {getSubscriptionsView, updateTemplate, updateCustomTemplate, rebuildTemplate} from '../../services/siteServices'
|
||||||
import queryKeys from '../../services/queryKeys'
|
import queryKeys from '../../services/queryKeys'
|
||||||
import getDateTimeFromDateString from '../../helpers/getDateTimeFromDateString';
|
import getDateTimeFromDateString from '../../helpers/getDateTimeFromDateString';
|
||||||
|
import RebuildModal from './RebuildModal';
|
||||||
|
|
||||||
export default function SubscriptionViewCom() {
|
export default function SubscriptionViewCom() {
|
||||||
|
|
||||||
@@ -14,16 +15,16 @@ export default function SubscriptionViewCom() {
|
|||||||
const {state} = useLocation()
|
const {state} = useLocation()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const [reqStatus, setReqStatus] = useState({loading: false, type: '', error: false, success: false})
|
const [rebuildStatus, setRebuildStatus] = useState({status: false, data: {}})
|
||||||
|
|
||||||
const [values, setValues] = useState({custom_id: '', template_uid: ''})
|
const [values, setValues] = useState({custom_id: '', template_uid: ''})
|
||||||
|
|
||||||
const handleValueChange = ({target:{name, value}}) => {
|
const handleValueChange = ({target: {name, value}}) => {
|
||||||
if(name == 'custom_template'){
|
if (name == 'custom_template') {
|
||||||
setValues(prev => ({...prev, custom_id: value}))
|
setValues(prev => ({...prev, custom_id: value}))
|
||||||
}else if (name == 'template') {
|
} else if (name == 'template') {
|
||||||
setValues(prev => ({...prev, template_uid: value}))
|
setValues(prev => ({...prev, template_uid: value}))
|
||||||
}else{
|
} else {
|
||||||
setValues(prev => ({...prev}))
|
setValues(prev => ({...prev}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +35,7 @@ export default function SubscriptionViewCom() {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const {data, isFetching, isError, error} = useQuery({
|
const {data, isFetching, isError, error} = useQuery({
|
||||||
queryKey: queryKeys.subscriptions_view,
|
queryKey: queryKeys.subscriptions_view,
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
// const filterData = filter?.type ? {[filter?.type]: filter.id} : {}
|
// const filterData = filter?.type ? {[filter?.type]: filter.id} : {}
|
||||||
@@ -63,6 +64,17 @@ export default function SubscriptionViewCom() {
|
|||||||
// }
|
// }
|
||||||
// },[data])
|
// },[data])
|
||||||
|
|
||||||
|
const templateRebuild = useMutation({
|
||||||
|
mutationFn: (fields) => {
|
||||||
|
return rebuildTemplate(fields)
|
||||||
|
},
|
||||||
|
onSettled: () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setRebuildStatus({status: false, data: {}})
|
||||||
|
templateRebuild.reset()
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const templateUpdate = useMutation({
|
const templateUpdate = useMutation({
|
||||||
mutationFn: (fields) => {
|
mutationFn: (fields) => {
|
||||||
@@ -73,7 +85,7 @@ export default function SubscriptionViewCom() {
|
|||||||
// onSuccess: (res) => {
|
// onSuccess: (res) => {
|
||||||
// },
|
// },
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
templateUpdate.reset()
|
templateUpdate.reset()
|
||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
@@ -88,7 +100,7 @@ export default function SubscriptionViewCom() {
|
|||||||
// onSuccess: (res) => {
|
// onSuccess: (res) => {
|
||||||
// },
|
// },
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
customTemplateUpdate.reset()
|
customTemplateUpdate.reset()
|
||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
@@ -102,6 +114,13 @@ export default function SubscriptionViewCom() {
|
|||||||
templateUpdate.mutate(reqData)
|
templateUpdate.mutate(reqData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleRebuildTemplate = () => {
|
||||||
|
const reqData = {
|
||||||
|
subscription_uid: state?.subscriptionUID,
|
||||||
|
}
|
||||||
|
templateRebuild.mutate(reqData)
|
||||||
|
}
|
||||||
|
|
||||||
const handleUpdateCustomTemplate = () => {
|
const handleUpdateCustomTemplate = () => {
|
||||||
const reqData = {
|
const reqData = {
|
||||||
subscrtiption_uid: state?.subscriptionUID,
|
subscrtiption_uid: state?.subscriptionUID,
|
||||||
@@ -113,89 +132,116 @@ export default function SubscriptionViewCom() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full flex flex-col gap-8'>
|
<div className='w-full flex flex-col gap-8'>
|
||||||
<BreadcrumbCom title={`Subscription View [${state?.subscriptionUID}]`} paths={['Dashboard', 'Subscription View']}/>
|
<BreadcrumbCom title={`Subscription View [${state?.subscriptionUID}]`}
|
||||||
|
paths={['Dashboard', 'Subscription View']}/>
|
||||||
|
|
||||||
{isFetching ?
|
{isFetching ?
|
||||||
<>
|
|
||||||
<p className='text-slate-800'>Loading...</p>
|
|
||||||
</>
|
|
||||||
: isError ?
|
|
||||||
<p className='text-red-500'>{error.message}</p>
|
|
||||||
:
|
|
||||||
<>
|
<>
|
||||||
<div className='w-full box bg-white dark:bg-black-box text-black-body dark:text-white-body overflow-x-auto'>
|
<p className='text-slate-800'>Loading...</p>
|
||||||
<table className="py-2 w-full text-sm bg-[aliceblue] dark:bg-transparent rounded-[10px]">
|
</>
|
||||||
<tbody>
|
: isError ?
|
||||||
|
<p className='text-red-500'>{error.message}</p>
|
||||||
|
:
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className='w-full box bg-white dark:bg-black-box text-black-body dark:text-white-body overflow-x-auto'>
|
||||||
|
<table className="py-2 w-full text-sm bg-[aliceblue] dark:bg-transparent rounded-[10px]">
|
||||||
|
<tbody>
|
||||||
<tr className="py-2 border-t border-dashed border-slate-300">
|
<tr className="py-2 border-t border-dashed border-slate-300">
|
||||||
<td className="px-2 py-2">
|
<td className="px-2 py-2">
|
||||||
<div className="text-left">
|
<div className="text-left">
|
||||||
<div className="text-base font-semibold">{getDateTimeFromDateString(selectedSubscription?.added)}</div>
|
<div
|
||||||
|
className="text-base font-semibold">{getDateTimeFromDateString(selectedSubscription?.added)}</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-2">
|
<td className="px-2">
|
||||||
<div className="text-left">
|
<div className="text-left">
|
||||||
<div className="text-base font-semibold">{selectedSubscription?.product_id}</div>
|
<div
|
||||||
|
className="text-base font-semibold">{selectedSubscription?.product_id}</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-2">
|
<td className="px-2">
|
||||||
<div className="text-left">
|
<div className="text-left">
|
||||||
<div className="text-base font-semibold">{selectedSubscription?.internal_url}
|
<div
|
||||||
<br /><span>Template :</span> {selectedSubscription?.product_template}
|
className="text-base font-semibold">{selectedSubscription?.internal_url}
|
||||||
<br /><span>Custom :</span> {selectedSubscription?.custom_template}
|
<br/><span>Template :</span> {selectedSubscription?.product_template}
|
||||||
|
<br/><span>Custom :</span> {selectedSubscription?.custom_template}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-2">
|
<td className="px-2">
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
<div className="text-base font-semibold">{selectedSubscription?.status}</div>
|
<div
|
||||||
|
className="text-base font-semibold">{selectedSubscription?.status}</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td className="px-2">
|
||||||
|
<div className="text-right">
|
||||||
|
<button name='template' onClick={()=>setRebuildStatus({status: true, data:{}})}
|
||||||
|
className={`rounded-md p-2 bg-primary text-white text-center`}>
|
||||||
|
Rebuild
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
|
||||||
|
|
||||||
<div className='w-full'>
|
|
||||||
<label className='font-medium'>Assign Template</label>
|
|
||||||
<div className='flex flex-col xs:flex-row md:items-center gap-2'>
|
|
||||||
<div className='w-full h-10 relative overflow-hidden rounded-md'>
|
|
||||||
<select name='template' value={currentTemplate || values.template_uid} onChange={handleValueChange} className='w-full h-full p-2 appearance-none dark:bg-transparent border-0 dark:border-1 border-white ring-0 outline-none'>
|
|
||||||
<option value=''>None</option>
|
|
||||||
{availableTemplates && availableTemplates.map(item => (
|
|
||||||
<option key={item?.template_uid} value={item?.template_uid}>{`${item?.product_id}-${item?.provision_name}`}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
<FaCaretDown className='text-base absolute top-1/2 -translate-y-1/2 right-2' />
|
|
||||||
</div>
|
|
||||||
<button name='template' onClick={handleUpdateTemplate} disabled={(templateUpdate.isPending || !values.template_uid)} className={`rounded-md p-2 bg-primary text-white text-center ${(templateUpdate.isPending || !values.template_uid) && 'opacity-50'}`}>Update</button>
|
|
||||||
</div>
|
|
||||||
<p className={`p-2 mt-4 ${templateUpdate.isSuccess ? 'text-emerald-500' : 'text-red-500'}`}>{templateUpdate.isSuccess ? 'Template updated' : templateUpdate.isSuccess ? 'Unable to complete request, try again' : ''}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||||
|
|
||||||
<div className='w-full'>
|
<div className='w-full'>
|
||||||
<label className='font-medium'>Assign Custom Template</label>
|
<label className='font-medium'>Assign Template</label>
|
||||||
<div className='flex flex-col xs:flex-row md:items-center gap-2'>
|
<div className='flex flex-col xs:flex-row md:items-center gap-2'>
|
||||||
<div className='w-full h-10 relative overflow-hidden rounded-md'>
|
<div className='w-full h-10 relative overflow-hidden rounded-md'>
|
||||||
<select name='custom_template' value={currentCustomTem || values.custom_id} onChange={handleValueChange} className='w-full h-full p-2 appearance-none dark:bg-transparent border-0 dark:border-1 border-white ring-0 outline-none'>
|
<select name='template' value={currentTemplate || values.template_uid}
|
||||||
<option value=''>None</option>
|
onChange={handleValueChange}
|
||||||
{customTemplates && customTemplates.map(item => (
|
className='w-full h-full p-2 appearance-none dark:bg-transparent border-0 dark:border-1 border-white ring-0 outline-none'>
|
||||||
<option key={item?.custom_id} value={item?.custom_id}>{`${item?.custom_id}-${item?.provision_name}`}</option>
|
<option value=''>None</option>
|
||||||
))}
|
{availableTemplates && availableTemplates.map(item => (
|
||||||
</select>
|
<option key={item?.template_uid}
|
||||||
<FaCaretDown className='text-base absolute top-1/2 -translate-y-1/2 right-2' />
|
value={item?.template_uid}>{`${item?.product_id}-${item?.provision_name}`}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
<FaCaretDown className='text-base absolute top-1/2 -translate-y-1/2 right-2'/>
|
||||||
|
</div>
|
||||||
|
<button name='template' onClick={handleUpdateTemplate}
|
||||||
|
disabled={(templateUpdate.isPending || !values.template_uid)}
|
||||||
|
className={`rounded-md p-2 bg-primary text-white text-center ${(templateUpdate.isPending || !values.template_uid) && 'opacity-50'}`}>Update
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button name='custom_template' onClick={handleUpdateCustomTemplate} disabled={(customTemplateUpdate.isPending || !values.custom_id)} className={`rounded-md p-2 bg-primary text-white text-center ${(customTemplateUpdate.isPending || !values.custom_id) && 'opacity-50'}`}>Update</button>
|
<p className={`p-2 mt-4 ${templateUpdate.isSuccess ? 'text-emerald-500' : 'text-red-500'}`}>{templateUpdate.isSuccess ? 'Template updated' : templateUpdate.isSuccess ? 'Unable to complete request, try again' : ''}</p>
|
||||||
</div>
|
</div>
|
||||||
<p className={`p-2 mt-4 ${customTemplateUpdate.isSuccess ? 'text-emerald-500' : 'text-red-500'}`}>{customTemplateUpdate.isSuccess ? 'Custom Template updated' : customTemplateUpdate.isSuccess ? 'Unable to complete request, try again' : ''}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</>
|
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||||
}
|
|
||||||
|
<div className='w-full'>
|
||||||
|
<label className='font-medium'>Assign Custom Template</label>
|
||||||
|
<div className='flex flex-col xs:flex-row md:items-center gap-2'>
|
||||||
|
<div className='w-full h-10 relative overflow-hidden rounded-md'>
|
||||||
|
<select name='custom_template' value={currentCustomTem || values.custom_id}
|
||||||
|
onChange={handleValueChange}
|
||||||
|
className='w-full h-full p-2 appearance-none dark:bg-transparent border-0 dark:border-1 border-white ring-0 outline-none'>
|
||||||
|
<option value=''>None</option>
|
||||||
|
{customTemplates && customTemplates.map(item => (
|
||||||
|
<option key={item?.custom_id}
|
||||||
|
value={item?.custom_id}>{`${item?.custom_id}-${item?.provision_name}`}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
<FaCaretDown className='text-base absolute top-1/2 -translate-y-1/2 right-2'/>
|
||||||
|
</div>
|
||||||
|
<button name='custom_template' onClick={handleUpdateCustomTemplate}
|
||||||
|
disabled={(customTemplateUpdate.isPending || !values.custom_id)}
|
||||||
|
className={`rounded-md p-2 bg-primary text-white text-center ${(customTemplateUpdate.isPending || !values.custom_id) && 'opacity-50'}`}>Update
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p className={`p-2 mt-4 ${customTemplateUpdate.isSuccess ? 'text-emerald-500' : 'text-red-500'}`}>{customTemplateUpdate.isSuccess ? 'Custom Template updated' : customTemplateUpdate.isSuccess ? 'Unable to complete request, try again' : ''}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
{ rebuildStatus?.status && <RebuildModal data={{}} templateRebuild={templateRebuild} proceedFunc={handleRebuildTemplate} closeModal={()=>setRebuildStatus({status: false, data:{}})} />}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -124,6 +124,14 @@ export const getProductsTemplate = (reqData) => {
|
|||||||
return getAuxEnd(`/products-templates`, postData)
|
return getAuxEnd(`/products-templates`, postData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FUNCTION TO INITIATE TEMPLATE REBUILD
|
||||||
|
export const rebuildTemplate = (reqData) => {
|
||||||
|
let postData = {
|
||||||
|
...reqData
|
||||||
|
}
|
||||||
|
return postAuxEnd('/rebuild-template', postData, false)
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION TO UPDATE TEMPLATE
|
// FUNCTION TO UPDATE TEMPLATE
|
||||||
export const updateTemplate = (reqData) => {
|
export const updateTemplate = (reqData) => {
|
||||||
let postData = {
|
let postData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user