Compare commits

...

16 Commits

Author SHA1 Message Date
victorAnumudu 767a900e36 fixed default template selection 2025-09-30 08:31:37 +01:00
CHIEFSOFT\ameye 8f41dcbf35 fix endpoinst 2025-09-29 20:36:24 -04:00
ameye 11289c44fb Merge branch 'subscription-view-component' of MERMS/MermsFirstOffice into master 2025-09-29 21:07:36 +00:00
victorAnumudu 65f4aafc68 add template layout fix 2025-09-29 22:04:52 +01:00
victorAnumudu 79d5005d6b added custom template and template dropdown menu 2025-09-29 21:46:23 +01:00
ameye ba6b3a1dd0 Merge branch 'link-error-fixed' of MERMS/MermsFirstOffice into master 2025-09-29 17:39:35 +00:00
victorAnumudu ec1402f610 link error isued fixed 2025-09-29 18:36:10 +01:00
CHIEFSOFT\ameye 4481dae24e add templates 2025-09-29 11:53:25 -04:00
ameye 68eb0f9abc Merge branch 'account-profile-data' of MERMS/MermsFirstOffice into master 2025-09-29 14:02:20 +00:00
victorAnumudu b5a5452a0d bg color fix 2025-09-29 11:24:35 +01:00
victorAnumudu 0a66679950 padding fix 2025-09-29 11:11:50 +01:00
victorAnumudu fd9eb08cea fixed profile table data 2025-09-29 11:06:04 +01:00
CHIEFSOFT\ameye 1e28046093 clean up 2025-09-28 22:42:51 -04:00
CHIEFSOFT\ameye 4b39b73931 more data 2025-09-28 15:28:49 -04:00
CHIEFSOFT\ameye 54bfe7affa Fix layout 2025-09-28 14:44:26 -04:00
ameye d7cfb03550 Merge branch 'account-view-section-fix' of MERMS/MermsFirstOffice into master 2025-09-28 17:56:30 +00:00
12 changed files with 519 additions and 188 deletions
@@ -1,52 +1,61 @@
export default function AccountProfileView() {
export default function AccountProfileView({profile}) {
return <>
<div className="row" style={{paddingBottom:'20px'}}>
<div className="col-12 col-lg-12">
<div className="card card-statistics">
<div className="card-header">
<div className="card-heading">
<h4 className="card-title"><b>Account Profile</b></h4>
</div>
<div className="pb-5">
<div className="flex flex-col gap-1">
<div className="w-full">
<h4 className="font-semibold text-lg">Account Profile</h4>
</div>
<div className="card-body">
<div className="table-responsive">
<table className="table table-hover mb-0" style={{width:'100%', backgroundColor: 'aliceblue', borderRadius: '10px'}}>
<thead>
<div className="w-full overflow-x-auto">
<>
<table className="py-2 w-full text-sm bg-[aliceblue] dark:bg-transparent rounded-[10px]">
<thead className="py-2 text-sm text-slate-500 text-left">
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
<th scope="col" className="px-2 py-2">
Member ID
</th>
<th scope="col" className="px-2">
Practice/specialization
</th>
<th scope="col" className="px-2">
URL Name
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
{(profile && Object.keys(profile).length > 0) ?
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{profile?.member_id}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">Practice: {profile?.practice}</div>
<div className="text-base font-semibold">Specialization: {profile?.specialization}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{profile?.url_name}</div>
</div>
</td>
</tr>
:
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-3 py-2" colSpan={3}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
</>
</div>
</div>
</div>
</div>
</>
</>
}
@@ -14,12 +14,12 @@ import CustomerPaymentsView from "./CustomerPaymentsView";
export default function AccountViewCom() {
const {state:{memberUID}} = useLocation()
const {state} = useLocation()
const navigate = useNavigate()
useEffect(()=>{
if(!memberUID){
navigate(RouteLinks.customerPage, {replace: true})
if(!state?.memberUID){
navigate(RouteLinks.homePage, {replace: true})
}
},[])
@@ -28,7 +28,7 @@ export default function AccountViewCom() {
queryFn: () => {
// const filterData = filter?.type ? {[filter?.type]: filter.id} : {}
const reqData = {
member_uid: memberUID
member_uid: state?.memberUID
// page,
// ...filterData
}
@@ -45,7 +45,7 @@ export default function AccountViewCom() {
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title={`Account View [${memberUID}]`} paths={['Dashboard', 'Account View']}/>
<BreadcrumbCom title={`Account View [${state?.memberUID}]`} paths={['Dashboard', 'Account View']}/>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{isFetching ?
@@ -57,8 +57,8 @@ export default function AccountViewCom() {
:
<>
<CustomerAccountView accountInfo={account_info} />
<AccountProfileView />
<CustomerSubscriptionsView subscriptions={subscriptions} memberUID={memberUID} />
<AccountProfileView profile={account_profile} />
<CustomerSubscriptionsView subscriptions={subscriptions} />
<CustomerPaymentsView payments={payments} />
</>
@@ -10,13 +10,11 @@ export default function CustomerAccountView({accountInfo}) {
</div>
<div className="w-full overflow-x-auto">
<>
<table className="py-2 w-full text-sm" style={{backgroundColor: 'aliceblue', borderRadius: '10px'}}>
<table className="py-2 w-full text-sm bg-[aliceblue] dark:bg-transparent rounded-[10px]">
<thead className="py-2 text-sm text-slate-500 text-left">
<tr>
<th scope="col" className="px-2 py-2">
#
</th>
<th scope="col" className="px-2">
Firstname
</th>
<th scope="col" className="px-2">
@@ -28,6 +26,7 @@ export default function CustomerAccountView({accountInfo}) {
<th scope="col" className="px-2">
Email
</th>
<th scope="col" className="px-2 text-right">
Action
</th>
@@ -36,11 +35,11 @@ export default function CustomerAccountView({accountInfo}) {
<tbody>
{(accountInfo && Object.keys(accountInfo).length > 0) ?
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-2 py-2">
<div className="text-left">
<div className="text-base font-semibold">{1}</div>
</div>
</td>
{/*<td className="px-2 py-2">*/}
{/* <div className="text-left">*/}
{/* <div className="text-base font-semibold">{1}</div>*/}
{/* </div>*/}
{/*</td>*/}
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{accountInfo?.firstname}</div>
@@ -61,6 +60,7 @@ export default function CustomerAccountView({accountInfo}) {
<div className="text-base font-semibold">{accountInfo?.email}</div>
</div>
</td>
<td className="px-2 text-right">
<div className='flex items-center justify-end gap-3 md:gap-4'>
<div
@@ -8,20 +8,23 @@ export default function CustomerPaymentsView({payments}) {
</div>
<div className="w-full overflow-x-auto">
<>
<table className="py-2 w-full text-sm" style={{backgroundColor: 'aliceblue', borderRadius: '10px'}}>
<table className="py-2 w-full text-sm bg-[aliceblue] dark:bg-transparent rounded-[10px]">
<thead className="py-2 text-sm text-slate-500 text-left">
<tr>
<th scope="col" className="px-2 py-2">
#
</th>
<th scope="col" className="px-2">
First
Added
</th>
<th scope="col" className="px-2">
Last
Option Name
</th>
<th scope="col" className="px-2">
Handle
Amount
</th>
<th scope="col" className="px-2">
Currency
</th>
</tr>
</thead>
@@ -35,17 +38,22 @@ export default function CustomerPaymentsView({payments}) {
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.first}</div>
<div className="text-base font-semibold">{item?.added}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.last}</div>
<div className="text-base font-semibold">{item?.option_name}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.handle}</div>
<div className="text-base font-semibold">{item?.amount}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">Dollars</div>
</div>
</td>
</tr>
@@ -3,7 +3,7 @@ import RouteLinks from "../../RouteLinks";
import Icons from "../Icons";
import {Link} from 'react-router-dom'
export default function CustomerSubscriptionsView({subscriptions, memberUID}) {
export default function CustomerSubscriptionsView({subscriptions}) {
return <>
<div className="pb-5">
<div className="flex flex-col gap-1">
@@ -12,7 +12,7 @@ export default function CustomerSubscriptionsView({subscriptions, memberUID}) {
</div>
<div className="w-full overflow-x-auto">
<>
<table className="py-2 w-full text-sm" style={{backgroundColor: 'aliceblue', borderRadius: '10px'}}>
<table className="py-2 w-full text-sm bg-[aliceblue] dark:bg-transparent rounded-[10px]">
<thead className="py-2 text-sm text-slate-500 text-left">
<tr>
<th scope="col" className="px-2 py-2">
@@ -25,7 +25,7 @@ export default function CustomerSubscriptionsView({subscriptions, memberUID}) {
Product
</th>
<th scope="col" className="px-2">
URL
URL / Templates
</th>
<th scope="col" className="px-2">
Status
@@ -55,7 +55,10 @@ export default function CustomerSubscriptionsView({subscriptions, memberUID}) {
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.internal_url}</div>
<div className="text-base font-semibold">{item?.internal_url}
<br /><span>Template :</span> {item?.product_template}
<br /><span>Custom :</span> {item?.custom_template}
</div>
</div>
</td>
<td className="px-2">
@@ -67,7 +70,7 @@ export default function CustomerSubscriptionsView({subscriptions, memberUID}) {
<div className='flex items-center justify-end gap-3 md:gap-4'>
<div
className='p-2 flex justify-center items-center text-slate-500 bg-white-body dark:text-white-body dark:bg-black-body rounded-md'>
<Link to={`/subscription-view/${memberUID}`} state={{customerID: item?.id, memberUID}}>
<Link to={`/subscription-view/${item?.subscription_uid}`} state={{customerID: item?.id, subscriptionUID: item?.subscription_uid}}>
<Icons name='eye'/>
</Link>
</div>
+3 -1
View File
@@ -155,7 +155,9 @@ export default function HomeCom() {
<div className='flex items-center justify-end gap-3 md:gap-4'>
<div
className='p-2 flex justify-center items-center text-slate-500 bg-white-body dark:text-white-body dark:bg-black-body rounded-md'>
<Link to={`/subscription-view/${item?.uid}`}>
<Link to={`/subscription-view/${item?.uid}`}
state={{subscriptionUID: item?.uid}}
>
<Icons name='eye'/>
</Link>
</div>
+106
View File
@@ -0,0 +1,106 @@
import {useMutation, useQueryClient} from '@tanstack/react-query'
import {Formik, Form} from 'formik'
import * as Yup from "yup";
import InputText from '../InputText'
import {addCustomTemplate} from '../../services/siteServices'
import queryKeys from '../../services/queryKeys';
const initialValues = {
custom_id: "",
provision_name: "",
};
// To get the validation schema
const validationSchema = Yup.object().shape({
custom_id: Yup.string().required("custom_id is required").min(6, 'must be upto 6 characters').max(25, 'must not exceed 25 characters'),
provision_name: Yup.string().required("provision_name is required").min(6, 'must be upto 6 characters').max(25, 'must not exceed 25 characters'),
});
export default function AddTemplate() {
const queryClient = useQueryClient()
const customTemplate = useMutation({
mutationFn: (fields) => {
if (!fields.custom_id || !fields.provision_name) {
throw new Error('Please provide all fields marked *')
}
return addCustomTemplate(fields)
},
onSuccess: () => {
queryClient.refetchQueries({
queryKey: [...queryKeys.custom_template],
// type: 'active',
// exact: true,
})
},
})
//FUNCTION TO HANDLE ADD TEMPLATE
const handleSubmit = (values, helper) => {
customTemplate.mutate(values)
};
return (
<Formik
initialValues={initialValues}
validationSchema={validationSchema}
onSubmit={handleSubmit}
>
{(props) => (
<Form>
<div
className='flex flex-col w-full bg-white rounded-xl p-16 sm:px-20 sm:py-16 shadow'>
<div className='w-full flex flex-col gap-4'>
<div className='relative text-input flex flex-col sm:flex-row gap-2 sm:items-center'>
<label className={`text-base min-w-36 text-end sm:text-left ${(props.errors.custom_id && props.touched.custom_id) && 'text-red-500'}`}>
Custom ID
</label>
<InputText
id='custom_id'
placeholder='Custom ID'
name='custom_id'
value={props.values.custom_id}
handleChange={props.handleChange}
/>
</div>
<div className='relative text-input flex flex-col sm:flex-row gap-2 sm:items-center'>
<label className={`text-base min-w-36 text-end sm:text-left ${(props.errors.provision_name && props.touched.provision_name) && 'text-red-500'}`}>
Provision Name
</label>
<InputText
id='provision_name'
placeholder='Provision Name'
name='provision_name'
value={props.values.provision_name}
handleChange={props.handleChange}
/>
</div>
<div className='h-10 my-5 text-end'>
<button type='submit' disabled={customTemplate.isPending}
className='px-4 h-full bg-primary text-white font-bold rounded-md'>{customTemplate.isPending ? 'loading...' : 'Add'}</button>
</div>
{customTemplate.error &&
<>
<div className="w-full text-center">
<p className='text-red-500 text-sm'>{customTemplate.error.message}</p>
</div>
</>
}
{customTemplate.isSuccess &&
<>
<div className="w-full text-center">
<p className='text-emerald-500 text-sm'>{'Template Added'}</p>
</div>
</>
}
</div>
</div>
</Form>
)}
</Formik>
)
}
+9 -2
View File
@@ -7,6 +7,7 @@ import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons'
import { getCustomTemplate } from '../../services/siteServices'
import getDateTimeFromDateString from '../../helpers/getDateTimeFromDateString'
import AddTemplate from './AddTemplate'
export default function CustomTemplates() {
@@ -50,7 +51,12 @@ export default function CustomTemplates() {
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Custom Templates' paths={['Dashboard', 'Custom Templates']} />
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body' style={{backgroundColor: 'aliceblue'}}>
<div className='mb-3'>
<b>Add New Custom Template</b>
</div>
<AddTemplate />
</div>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{ isError ?
<p className='text-red-500'>{error?.message}</p>
@@ -62,7 +68,8 @@ export default function CustomTemplates() {
<div className='w-full sm:max-w-48'>
<select name='type' value={filter?.type} className='h-10 w-full p-2 rounded-md' onChange={handleFilter}>
<option value=''>All</option>
<option value='name'>Name</option>
<option value='custom_id'>Custom ID</option>
<option value='provision_name'>Provision Name</option>
</select>
</div>
<div className='w-full sm:max-w-48'>
@@ -1,32 +1,190 @@
import {useLocation, useNavigate, Link} from 'react-router-dom'
import { useQuery, useMutation } from '@tanstack/react-query'
import { FaCaretDown } from "react-icons/fa";
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import { useEffect } from 'react';
import {useEffect, useState} from 'react';
import RouteLinks from '../../RouteLinks';
import { getSubscriptionsView, updateTemplate } from '../../services/siteServices'
import queryKeys from '../../services/queryKeys'
import getDateTimeFromDateString from '../../helpers/getDateTimeFromDateString';
export default function SubscriptionViewCom() {
const subscriptionUID = "63554d40-9ba1-4afe-80c2-ca147236f7ee";
const {state:{memberUID}} = useLocation()
const {state} = useLocation()
const navigate = useNavigate()
useEffect(()=>{
if(!memberUID){
navigate(`/account-view/${memberUID}`, {replace: true, state:{memberUID}})
const [reqStatus, setReqStatus] = useState({loading: false, type: '', error: false, success: false})
const [values, setValues] = useState({custom_id: '', template_uid: ''})
const handleValueChange = ({target:{name, value}}) => {
if(name == 'custom_template'){
setValues(prev => ({...prev, custom_id: value}))
}else if (name == 'template') {
setValues(prev => ({...prev, template_uid: value}))
}else{
setValues(prev => ({...prev}))
}
},[])
}
useEffect(() => {
if (!state?.subscriptionUID) {
navigate(RouteLinks.homePage, {replace: true})
}
}, [])
const {data, isFetching, isError, error} = useQuery({
queryKey: queryKeys.subscriptions_view,
queryFn: () => {
// const filterData = filter?.type ? {[filter?.type]: filter.id} : {}
const reqData = {
subscription_uid: state?.subscriptionUID
// page,
// ...filterData
}
return getSubscriptionsView(reqData)
},
staleTime: 0 //0 mins
})
const subscriptionViewData = data?.data // ACCOUNT VIEW DATA
const customTemplates = subscriptionViewData?.available_custom_templates
const availableTemplates = subscriptionViewData?.available_templates
const selectedSubscription = subscriptionViewData?.subscription
const currentCustomTem = subscriptionViewData?.available_custom_templates?.filter(item => item?.custom_id == subscriptionViewData?.subscription?.custom_template)[0]?.custom_id
const currentTemplate = subscriptionViewData?.available_templates?.filter(item => item?.template_uid == subscriptionViewData?.subscription?.product_template)[0]?.template_uid
// // console.log('subscriptionViewData', subscriptionViewData, currentCustomTem, currentTemplate)
// useEffect(()=>{
// if(data){
// const currentCustomTem = subscriptionViewData?.available_custom_templates?.filter(item => item?.custom_id == subscriptionViewData?.subscription?.custom_template)[0]?.custom_id
// const currentTemplate = subscriptionViewData?.available_templates?.filter(item => item?.template_uid == subscriptionViewData?.subscription?.product_template)[0]?.template_uid
// setValues({custom_id: currentCustomTem || '', template_uid: currentTemplate || ''})
// }
// },[data])
const templateUpdate = useMutation({
mutationFn: (fields) => {
setReqStatus(prev => ({...prev, loading: true}))
return updateTemplate(fields)
},
onError: (error) => {
setReqStatus(prev => ({...prev, loading: false, error: true}))
},
onSuccess: (res) => {
setReqStatus(prev => ({...prev, loading: false, error: false, success: true}))
},
onSettled: () => {
setTimeout(()=>{
setReqStatus({loading: false, type: '', error: false, success: false})
}, 3000)
}
})
const handleUpdateTemplate = ({target:{name}}) => {
setReqStatus({loading: false, type: name, error: false, success: false})
const reqData = {Subscrtiption_uid: state?.subscriptionUID}
if(name == 'template'){
reqData.template_uid = values.template_uid
}else if (name == 'custom_template'){
reqData.custom_id = values.custom_id
}else{
return
}
templateUpdate.mutate(reqData)
}
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title={`Subscription View [${memberUID}]`} paths={['Dashboard', 'Subscription View']}/>
<BreadcrumbCom title={`Subscription View [${state?.subscriptionUID}]`} paths={['Dashboard', 'Subscription View']}/>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{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'>
<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">
<td className="px-2 py-2">
<div className="text-left">
<div className="text-base font-semibold">{getDateTimeFromDateString(selectedSubscription?.added)}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{selectedSubscription?.product_id}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{selectedSubscription?.internal_url}
<br /><span>Template :</span> {selectedSubscription?.product_template}
<br /><span>Custom :</span> {selectedSubscription?.custom_template}
</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="text-base font-semibold">{selectedSubscription?.status}</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<>
Show all here
</>
<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={(reqStatus.loading || !values.template_uid)} className={`rounded-md p-2 bg-primary text-white text-center ${(reqStatus.loading || !values.template_uid) && 'opacity-50'}`}>Update</button>
</div>
{(reqStatus.type == 'template' && (reqStatus.error || reqStatus.success)) &&
<p className={`p-2 mt-4 ${reqStatus.success ? 'text-emerald-500' : 'text-red-500'}`}>{reqStatus.success ? 'Template updated' : '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={handleUpdateTemplate} disabled={(reqStatus.loading || !values.custom_id)} className={`rounded-md p-2 bg-primary text-white text-center ${(reqStatus.loading || !values.custom_id) && 'opacity-50'}`}>Update</button>
</div>
{(reqStatus.type == 'custom_template' && (reqStatus.error || reqStatus.success)) &&
<p className={`p-2 mt-4 ${reqStatus.success ? 'text-emerald-500' : 'text-red-500'}`}>{reqStatus.success ? 'Template updated' : 'Unable to complete request, try again'}</p>
}
</div>
</div>
</>
}
</div>
)
}
+119 -104
View File
@@ -1,14 +1,14 @@
import { useState } from 'react'
import {useState} from 'react'
import {Link} from 'react-router-dom'
// import {Link} from 'react-router-dom'
import { useQuery } from '@tanstack/react-query'
import {useQuery} from '@tanstack/react-query'
import queryKeys from '../../services/queryKeys'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons'
import { getSubscriptions } from '../../services/siteServices'
import {getSubscriptions} from '../../services/siteServices'
import getDateTimeFromDateString from '../../helpers/getDateTimeFromDateString';
// import localImgLoader from '../../helpers/localImageLoader';
// import RouteLinks from '../../RouteLinks';
@@ -19,18 +19,18 @@ export default function SubscriptionsCom() {
const [filter, setFilter] = useState({type: '', id: ''})
const [willFilter, setWillFilter] = useState(false)
const handleFilter = ({target:{name, value}}) => {
setFilter(prev => ({...prev, [name]:value}))
const handleFilter = ({target: {name, value}}) => {
setFilter(prev => ({...prev, [name]: value}))
}
const handleFilterByParams = () => {
if(filter.type && !filter.id){
if (filter.type && !filter.id) {
return
}else if(!filter.type){
} else if (!filter.type) {
setPage(1)
setWillFilter(prev => !prev)
setFilter({type: '', id: ''})
}else{
} else {
setPage(1)
setWillFilter(prev => !prev)
}
@@ -53,108 +53,123 @@ export default function SubscriptionsCom() {
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Provisions' paths={['Dashboard', 'Provisions']} />
<BreadcrumbCom title='Provisions' paths={['Dashboard', 'Provisions']}/>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{ isError ?
{isError ?
<p className='text-red-500'>{error?.message}</p>
:
<>
{/* filter section */}
<div className='px-2 py-2 mb-4 flex flex-col sm:flex-row flex-wrap sm:items-center gap-2'>
<Icons name='filter' className='text-3xl' />
<div className='w-full sm:max-w-48'>
<select name='type' value={filter?.type} className='h-10 w-full p-2 rounded-md' onChange={handleFilter}>
<option value=''>All</option>
<option value='member_id'>Member ID</option>
<option value='product_id'>Product ID</option>
</select>
:
<>
{/* filter section */}
<div className='px-2 py-2 mb-4 flex flex-col sm:flex-row flex-wrap sm:items-center gap-2'>
<Icons name='filter' className='text-3xl'/>
<div className='w-full sm:max-w-48'>
<select name='type' value={filter?.type} className='h-10 w-full p-2 rounded-md'
onChange={handleFilter}>
<option value=''>All</option>
<option value='member_id'>Member ID</option>
<option value='product_id'>Product ID</option>
</select>
</div>
<div className='w-full sm:max-w-48'>
<input name='id' value={filter?.id} disabled={!filter.type}
className={`h-10 w-full p-2 rounded-md outline-none border border-black-aside ${!filter.type && 'opacity-30'}`}
onChange={handleFilter}/>
</div>
<button onClick={handleFilterByParams} disabled={filter.type && !filter.id}
className={`h-10 bg-primary px-2 py-1 rounded-md text-white font-medium sm:self-end ${(filter.type && !filter.id) && 'opacity-50'}`}>Submit
</button>
</div>
<div className='w-full sm:max-w-48'>
<input name='id' value={filter?.id} disabled={!filter.type} className={`h-10 w-full p-2 rounded-md outline-none border border-black-aside ${!filter.type && 'opacity-30'}`} onChange={handleFilter} />
</div>
<button onClick={handleFilterByParams} disabled={filter.type && !filter.id} className={`h-10 bg-primary px-2 py-1 rounded-md text-white font-medium sm:self-end ${(filter.type && !filter.id) && 'opacity-50'}`}>Submit</button>
</div>
{/* end of filter section */}
{/* end of filter section */}
<TablePaginatedWrapper data={subscriptionData} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination}>
{({ data }) => (
<>
<table className="py-2 w-full text-sm">
<thead className="py-2 text-sm text-slate-500 text-left">
<tr>
<th scope="col" className="px-2 py-2">
Added
</th>
<th scope="col" className="px-2">
Product
</th>
<th scope="col" className="px-2">
URL
</th>
<th scope="col" className="px-2 text-right">
Status
</th>
<th scope="col" className="px-2 text-right">
Action
</th>
</tr>
</thead>
<tbody>
{(data && data.length > 0) ? data?.map((item, index) => (
<tr key={index} className="py-2 border-t border-dashed border-slate-300">
<td className="px-2 py-2">
<div className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
{/* <img className="w-10 h-10 rounded-md" src={localImgLoader(`loan_icons/${item?.type}.png`)} alt="Icon" /> */}
<div className="text-left">
<div className="text-base font-semibold">{getDateTimeFromDateString(item?.added)}</div>
</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.product_id}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.internal_url}</div>
<div className="font-normal text-gray-500">{item?.external_url}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="text-base font-semibold">{item?.status}</div>
</div>
</td>
<td className="px-2 text-right">
<div className='flex items-center justify-end gap-3 md:gap-4'>
<div
className='p-2 flex justify-center items-center text-slate-500 bg-white-body dark:text-white-body dark:bg-black-body rounded-md'>
<Link to={`/subscription-view/${item?.subscription_uid}`}
state={{customerID: item?.id, memberUID: item?.member_uid}}>
<Icons name='eye'/>
</Link>
</div>
</div>
</td>
<TablePaginatedWrapper data={subscriptionData} isFetching={isFetching} setPage={setPage}
itemsPerPage={pagination?.limit} pagination={pagination}>
{({data}) => (
<>
<table className="py-2 w-full text-sm">
<thead className="py-2 text-sm text-slate-500 text-left">
<tr>
<th scope="col" className="px-2 py-2">
Added/Updated
</th>
<th scope="col" className="px-2">
Product
</th>
<th scope="col" className="px-2">
Internal-URL/External-URL/SubscriptionUID
</th>
<th scope="col" className="px-2 text-right">
Status
</th>
<th scope="col" className="px-2 text-right">
Action
</th>
</tr>
))
:
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-3 py-2" colSpan={4}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
)}
</TablePaginatedWrapper>
</>
</thead>
<tbody>
{(data && data.length > 0) ? data?.map((item, index) => (
<tr key={index} className="py-2 border-t border-dashed border-slate-300">
<td className="px-2 py-2">
<div
className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
{/* <img className="w-10 h-10 rounded-md" src={localImgLoader(`loan_icons/${item?.type}.png`)} alt="Icon" /> */}
<div className="text-left">
<div
className="text-base font-semibold">
{getDateTimeFromDateString(item?.added)}<br />
{getDateTimeFromDateString(item?.updated)}<br />
</div>
</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div
className="text-base font-semibold">{item?.product_id}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold ">
<span>Int :</span> {item?.internal_url}<br/>
<span>Ext :</span> {item?.external_url}<br/>
{item?.subscription_uid}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="text-base font-semibold">{item?.status}</div>
</div>
</td>
<td className="px-2 text-right">
<div className='flex items-center justify-end gap-3 md:gap-4'>
<div
className='p-2 flex justify-center items-center text-slate-500 bg-white-body dark:text-white-body dark:bg-black-body rounded-md'>
<Link to={`/subscription-view/${item?.subscription_uid}`}
state={{customerID: item?.id, subscriptionUID: item?.subscription_uid}}
>
<Icons name='eye'/>
</Link>
</div>
</div>
</td>
</tr>
))
:
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-3 py-2" colSpan={4}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
)}
</TablePaginatedWrapper>
</>
}
</div>
</div>
+1
View File
@@ -20,6 +20,7 @@ const queryKeys = {
products_template: ['products_template'],
custom_template: ['custom_template'],
account_view: ['account_view'],
subscriptions_view: ['subscriptions_view'],
users_admin: ['users_admin'],
}
+22
View File
@@ -104,6 +104,22 @@ export const getProductsTemplate = (reqData) => {
return getAuxEnd(`/products-templates`, postData)
}
// FUNCTION TO UPDATE TEMPLATE
export const updateTemplate = (reqData) => {
let postData = {
...reqData
}
return postAuxEnd('/template/set-template', postData, false)
}
// FUNCTION TO ADD CUSTOM TEMPLATE
export const addCustomTemplate = (reqData) => {
let postData = {
...reqData
}
return postAuxEnd('/template/custom-add', postData, false)
}
// FUNCTION TO GET CUSTOM TEMPLATE DATA
export const getCustomTemplate = (reqData) => {
const postData = { ...reqData }
@@ -116,6 +132,12 @@ export const getAccountView = (reqData) => {
return getAuxEnd(`/account-view`, postData)
}
// FUNCTION TO GET SUBSCRIPTIONS VIEW DATA
export const getSubscriptionsView = (reqData) => {
const postData = { ...reqData }
return getAuxEnd(`/subscription-view`, postData)
}
// FUNCTION TO GET LOANS TABLE
export const getLoans = (reqData) => {