Compare commits

..

44 Commits

Author SHA1 Message Date
victorAnumudu b142833901 set country endpoint added 2025-10-07 08:46:52 +01:00
victorAnumudu 50551f1c7d Checkbox added 2025-10-06 21:21:05 +01:00
ameye a87a0a58db Merge branch 'country-endpoint-fix' of MERMS/MermsFirstOffice into master 2025-10-06 19:25:22 +00:00
victorAnumudu 6927d53c59 fixed endpoint 2025-10-06 20:01:48 +01:00
ameye e24df8e744 Merge branch 'country-endpoint' of MERMS/MermsFirstOffice into master 2025-10-06 17:43:23 +00:00
victorAnumudu 20c224b625 added country endpoint 2025-10-06 17:50:38 +01:00
CHIEFSOFT\ameye 54a0361620 country page 2025-10-06 06:07:21 -04:00
CHIEFSOFT\ameye a9721991de Added links 2025-10-06 05:05:14 -04:00
CHIEFSOFT\ameye e15e9f271c Fid URL 2025-10-01 05:46:45 -04:00
CHIEFSOFT\ameye c9ad818370 added urls 2025-10-01 04:42:10 -04:00
CHIEFSOFT\ameye 466d10c0fc added ips 2025-09-30 18:28:42 -04:00
ameye 7a7149de0c Merge branch 'payload-fix' of MERMS/MermsFirstOffice into master 2025-09-30 17:54:11 +00:00
victorAnumudu 34ef37c905 fixed payload issue 2025-09-30 18:38:53 +01:00
ameye 52249ae3a2 Merge branch 'update-custom-template-fix' of MERMS/MermsFirstOffice into master 2025-09-30 17:01:32 +00:00
victorAnumudu 183a6ce903 fixed custom update endpoint 2025-09-30 17:49:42 +01:00
ameye e65371e41b Merge branch 'template-current-selection' of MERMS/MermsFirstOffice into master 2025-09-30 08:50:08 +00:00
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
victorAnumudu 2324980cf4 account view subscription table data fixed 2025-09-28 14:31:40 +01:00
victorAnumudu ebcde80a3d account view subscription table data fixed 2025-09-28 14:31:22 +01:00
CHIEFSOFT\ameye 9a0ed2d78c home lnk 2025-09-28 08:08:36 -04:00
CHIEFSOFT\ameye 5783dfd521 Office subscription 2025-09-28 07:40:48 -04:00
CHIEFSOFT\ameye b26df44c19 Details pages 2025-09-27 16:47:13 -04:00
CHIEFSOFT\ameye 2a92649eec Adding Customer page details 2025-09-27 14:02:30 -04:00
ameye 52193f0baa Merge branch 'custom-template-fix' of MERMS/MermsFirstOffice into master 2025-09-23 16:19:26 +00:00
victorAnumudu a118adac65 fixed custom endpoint data 2025-09-23 17:16:31 +01:00
CHIEFSOFT\ameye de114904d2 remove spaces 2025-09-23 11:28:13 -04:00
ameye 82123bf254 Merge branch 'product-template-fix' of MERMS/MermsFirstOffice into master 2025-09-23 14:12:02 +00:00
victorAnumudu f70d39ab38 product template endpoint fixed 2025-09-22 17:17:54 +01:00
ameye 2b1c499cca Merge branch 'account-view-endpoint' of MERMS/MermsFirstOffice into master 2025-09-22 15:54:32 +00:00
19 changed files with 1261 additions and 284 deletions
+2
View File
@@ -3,11 +3,13 @@ const RouteLinks = {
homePage: '/',
customerPage: '/customer',
accountDetails: '/account-view/*',
subscriptionDetails: '/subscription-view/*',
subscriptions: '/subscriptions',
billings: '/billings',
recentSignup: '/recent-signup',
loansPage: '/loans',
transactionsPage: '/transactions',
countrySettings: '/country',
products: '/products',
usersAdmin: '/users-admin',
productTemplates: '/products-template',
+5 -1
View File
@@ -19,7 +19,9 @@ import LoansPage from './pages/LoansPage' // SELECTED LOANS PAGE
import TransactionDetailsPage from './pages/TransactionDetailsPage'
import AccountDetailsPage from "./pages/AccountDetailsPage";
import ProductTemplatePage from "./pages/ProductTemplatePage";
import CustomTemplatePage from "./pages/CustomTemplatePage"; // TRANSACTION DETAILS PAGE
import CustomTemplatePage from "./pages/CustomTemplatePage";
import SubscriptionDetailsPage from "./pages/SubscriptionDetailsPage";
import CountrySettingsPage from "./pages/CountrySettingsPage"; // TRANSACTION DETAILS PAGE
// const Home = lazy(() => import('./pages/Home'));
@@ -39,12 +41,14 @@ export default function SiteRoutes() {
<Route path={RouteLinks.products} element={<ProductsPage/>}/> {`*/PRODUCTS PAGE*/`}
<Route path={RouteLinks.usersAdmin} element={<UsersAdminPage/>}/> {`*/ADMIN USERS PAGE*/`}
<Route path={RouteLinks.countrySettings} element={<CountrySettingsPage/>}/> {`*/PRODUCTS TEMPLATE PAGE*/`}
<Route path={RouteLinks.productTemplates} element={<ProductTemplatePage/>}/> {`*/PRODUCTS TEMPLATE PAGE*/`}
<Route path={RouteLinks.customTemplates} element={<CustomTemplatePage/>}/> {`*/CUSTOM TEMPLATES PAGE*/`}
<Route path={RouteLinks.loansPage} element={<LoansPage/>}/> {`*/LOANS PAGE*/`}
<Route path={RouteLinks.transaction_details_page}
element={<TransactionDetailsPage/>}/> {`*/TRANSACTION PAGE*/`}
<Route path={RouteLinks.subscriptionDetails} element={<SubscriptionDetailsPage/>} />
</Route>
{/* ERROR PAGE */}
@@ -0,0 +1,61 @@
export default function AccountProfileView({profile}) {
return <>
<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="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" 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>
{(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>
</>
}
+22 -9
View File
@@ -7,15 +7,19 @@ import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import RouteLinks from '../../RouteLinks'
import { getAccountView } from '../../services/siteServices'
import queryKeys from '../../services/queryKeys'
import CustomerAccountView from "./CustomerAccountView";
import AccountProfileView from "./AccountProfileView";
import CustomerSubscriptionsView from "./CustomerSubscriptionsView";
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})
}
},[])
@@ -24,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
}
@@ -32,13 +36,16 @@ export default function AccountViewCom() {
},
staleTime: 0 //0 mins
})
const accountsViewData = data?.data?.products // ACCOUNT VIEW DATA
const pagination = data?.data?.pagination
console.log('DATA', data?.data)
const accountsViewData = data?.data // ACCOUNT VIEW DATA
const account_info = accountsViewData?.account
const account_profile = accountsViewData?.account_profile
const subscriptions = accountsViewData?.subscriptions
const payments = accountsViewData?.payments
// console.log('DATA', payments, subscriptions)
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 ?
@@ -48,7 +55,13 @@ export default function AccountViewCom() {
: isError ?
<p className='text-red-500'>{error.message}</p>
:
<p className='text-slate-800'>coming soon</p>
<>
<CustomerAccountView accountInfo={account_info} />
<AccountProfileView profile={account_profile} />
<CustomerSubscriptionsView subscriptions={subscriptions} />
<CustomerPaymentsView payments={payments} />
</>
}
</div>
@@ -0,0 +1,93 @@
import {Link} from 'react-router-dom'
import Icons from "../Icons";
export default function CustomerAccountView({accountInfo}) {
return <>
<div className="pb-5">
<div className="flex flex-col gap-1">
<div className="w-full">
<h4 className="font-semibold text-lg">Account Info</h4>
</div>
<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" className="px-2 py-2">
Firstname
</th>
<th scope="col" className="px-2">
Lastname
</th>
<th scope="col" className="px-2">
Username
</th>
<th scope="col" className="px-2">
Email
</th>
<th scope="col" className="px-2 text-right">
Action
</th>
</tr>
</thead>
<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">
<div className="text-left">
<div className="text-base font-semibold">{accountInfo?.firstname}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{accountInfo?.lastname}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{accountInfo?.username}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<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
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/63554d40-9ba1-4afe-80c2-ca147236f7ee`}
>
<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={6}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
</div>
</div>
</div>
</>
}
@@ -0,0 +1,77 @@
export default function CustomerPaymentsView({payments}) {
return <>
<div className="pb-5">
<div className="flex flex-col gap-1">
<div className="w-full">
<h4 className="font-semibold text-lg">Payments</h4>
</div>
<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" className="px-2 py-2">
#
</th>
<th scope="col" className="px-2">
Added
</th>
<th scope="col" className="px-2">
Option Name
</th>
<th scope="col" className="px-2">
Amount
</th>
<th scope="col" className="px-2">
Currency
</th>
</tr>
</thead>
<tbody>
{(payments && payments.length > 0) ? payments?.map((item, index) => (
<tr key={index} 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">{index+1}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<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?.option_name}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<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>
))
:
<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>
</>
</div>
</div>
</div>
</>
}
@@ -0,0 +1,121 @@
import getDateTimeFromDateString from "../../helpers/getDateTimeFromDateString";
import RouteLinks from "../../RouteLinks";
import Icons from "../Icons";
import {Link} from 'react-router-dom'
export default function CustomerSubscriptionsView({subscriptions}) {
return <>
<div className="pb-5">
<div className="flex flex-col gap-1">
<div className="w-full">
<h4 className="font-semibold text-lg">Subscriptions</h4>
</div>
<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" className="px-2 py-2">
#
</th>
<th scope="col" className="px-2">
Added/Updated
</th>
<th scope="col" className="px-2">
Product/Server
</th>
<th scope="col" className="px-2">
URL / EXT/ Templates
</th>
<th scope="col" className="px-2">
Status
</th>
<th scope="col" className="px-2 text-right">
Action
</th>
</tr>
</thead>
<tbody>
{(subscriptions && subscriptions.length > 0) ? subscriptions?.map((item, index) => (
<tr key={index} 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">{index + 1}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div
className="text-base font-semibold">{getDateTimeFromDateString(item?.added)}</div>
<div
className="text-base font-semibold">{getDateTimeFromDateString(item?.updated)}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.product_id}</div>
<div><a href={`http://${item?.primary_server}:${item?.provision_port}`}
target='_blank'
rel="noreferrer">{item?.primary_server}:{item?.provision_port}</a>
</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base">
<span className="badge badge-pill badge-primary-inverse">
<a href={`https://${item?.internal_url}`}
target='_blank'
rel="noreferrer">{item?.internal_url}</a>
</span>
<br/>
<span className="badge badge-warning">
<a href={`https://${item?.external_url}`}
target='_blank'
rel="noreferrer">{item?.external_url}</a>
</span>
<br/>
<span>Template :</span> {item?.product_template}
<br/><span>Custom :</span> {item?.custom_template}
</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={6}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
</div>
</div>
</div>
</>
}
+182
View File
@@ -0,0 +1,182 @@
import { useEffect, useState } from "react";
import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query'
import queryKeys from '../../services/queryKeys'
import BreadcrumbCom from "../breadcrumb/BreadcrumbCom";
import { getCountry, setCountry } from "../../services/siteServices";
import TableWrapper from "../tableWrapper/TableWrapper";
export default function CountrySettings(){
const [selected, setSelected] = useState('')
const queryClient = useQueryClient()
const {data, isFetching, status, isError, error} = useQuery({
queryKey: queryKeys.country_list,
queryFn: () => {
const reqData = {
// page,
// ...filterData
}
return getCountry(reqData)
},
// placeholderData: (previousData, previousQuery) => previousData,
staleTime: 0 // 0 mins
})
const countryData = data?.data?.country_data // COUNTRY LIST
const statusChange = useMutation({
mutationFn: (fields) => {
return setCountry(fields)
},
onError: (error) => {
},
onSuccess: (res) => {
queryClient.refetchQueries({
queryKey: [...queryKeys.country_list],
// type: 'active',
// exact: true,
})
},
onSettled: () => {
setSelected('')
}
})
//FUNCTION TO CHANGE STATUS OR SIGNUP
const handleStatusChange = (event, details) => {
setSelected(event.target.id)
const name = event.target.name
const val = name.toLowerCase() == 'STATUS' ? details.status : details.signup
const reqData = {
'val_type': name.toUpperCase(),
'country_uid': details?.country_uid,
'code': details?.code,
'val': val == 0 ? 1 : 0
}
statusChange.mutate(reqData)
};
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Country Settings' paths={['Dashboard', 'Country']} />
<div className='relative box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<>
{status === 'pending' ?
<p className='text-slate-800'>Loading...</p>
: isError ?
<p className='text-red-500'>{error.message}</p>
:
<TableWrapper data={countryData} itemsPerPage={20}>
{({ 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">
Code
</th>
<th scope="col" className="px-8">
Country
</th>
<th scope="col" className="px-2 text-center">
Status
</th>
<th scope="col" className="px-2 text-center">
Signup
</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="text-left">
<div className="text-base font-semibold">{item?.code}</div>
</div>
</td>
<td className="px-8">
<div className="text-left">
<div className="text-base font-semibold">{item?.description}</div>
</div>
</td>
<td className="px-8">
<div className="flex justify-center">
<>
{selected == 'status' + index ?
<div role="status" className="text-center">
<svg aria-hidden="true" class="w-4 h-4 text-gray-200 animate-spin dark:text-gray-600 fill-primary" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
<span class="sr-only">Loading...</span>
</div>
:
<input
className="w-4 h-4 cursor-pointer text-primary bg-gray-100 border-gray-300 rounded-sm focus:ring-primary/80 dark:focus:ring-primary dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
onChange={(e)=>handleStatusChange(e, item)}
type="checkbox"
checked={item?.status}
name="status"
id={'status' + index}
/>
}
</>
</div>
</td>
<td className="px-8">
<div className="flex justify-center">
<>
{selected == `signup${index}`
?
<div role="status" className="text-center">
<svg aria-hidden="true" class="w-4 h-4 text-gray-200 animate-spin dark:text-gray-600 fill-primary" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
<span class="sr-only">Loading...</span>
</div>
:
<input
className="w-4 h-4 cursor-pointer text-primary bg-gray-100 border-gray-300 rounded-sm focus:ring-primary/80 dark:focus:ring-primary dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
onChange={(e)=>handleStatusChange(e, item)}
type="checkbox"
checked={item?.signup}
name="signup"
id={'signup' + index }
/>
}
</>
</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>
</>
)}
</TableWrapper>
}
{/* {(isFetching && status != 'pending') &&
<div className="w-full absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[991] inset-0 flex justify-center items-center">
<p className="rounded-md shadow-md p-4 bg-white/90 dark:bg-gray-900 text-brown dark:text-white">Loading...</p>
</div>
} */}
</>
</div>
</div>
);
}
+174 -162
View File
@@ -1,13 +1,13 @@
import React from 'react'
import {Link} from 'react-router-dom'
import { useQuery } from "@tanstack/react-query";
import {Link} from 'react-router-dom'
import {useQuery} from "@tanstack/react-query";
import BreadcrumbCom from '../../components/breadcrumb/BreadcrumbCom'
import CustomCounter from '../../components/CustomCounter'
import Icons from '../../components/Icons'
import formatNumber from '../../helpers/formatNumber'
import queryKeys from '../../services/queryKeys'
import { getDashData } from '../../services/siteServices'
import {getDashData} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
import localImgLoader from '../../helpers/localImageLoader';
@@ -15,176 +15,188 @@ import RouteLinks from '../../RouteLinks';
export default function HomeCom() {
const {data, isFetching, isError, error} = useQuery({
queryKey: queryKeys.dashboard,
queryFn: () => getDashData(),
})
const {data, isFetching, isError, error} = useQuery({
queryKey: queryKeys.dashboard,
queryFn: () => getDashData(),
})
const dashData = data?.data // DASHBOARD DATA
const dashData = data?.data // DASHBOARD DATA
// console.log('dashData', dashData)
// loans, payments, recent_transactions [], request_summary
// console.log('dashData', dashData)
// loans, payments, recent_transactions [], request_summary
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Dashboard' paths={['Home', 'Dashboard']} />
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Dashboard' paths={['Home', 'Dashboard']}/>
{(isFetching || isError) ?
<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> : <p className='text-slate-800'>Loading...</p>}
</div>
:
<div className='grid grid-cols-1 gap-8'>
<div className='w-full grid grid-cols-1 xl:grid-cols-3 gap-8'>
<div className='box min-h-[230] justify-between bg-[#F7D9E3] dark:bg-black-box text-black-body dark:text-white-body'>
<p className='text-base sm:text-lg font-bold hover:text-primary'>Subscriptions</p>
<div className='flex flex-wrap gap-2 items-end font-bold'>
{/* <p className='text-3xl sm:text-[39px]'><span className='text-xl sm:text-2xl'>{dashData?.loans?.currency_text}</span><CustomCounter targetNumber={dashData?.loans?.value} timeInSeconds='1' /></p> */}
<p className='text-xl sm:text-[30px]'><span className='text-lg sm:text-xl'>
{(isFetching || isError) ?
<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> :
<p className='text-slate-800'>Loading...</p>}
</div>
:
<div className='grid grid-cols-1 gap-8'>
<div className='w-full grid grid-cols-1 xl:grid-cols-3 gap-8'>
<div
className='box min-h-[230] justify-between bg-[#F7D9E3] dark:bg-black-box text-black-body dark:text-white-body'>
<p className='text-base sm:text-lg font-bold hover:text-primary'>Subscriptions</p>
<div className='flex flex-wrap gap-2 items-end font-bold'>
{/* <p className='text-3xl sm:text-[39px]'><span className='text-xl sm:text-2xl'>{dashData?.loans?.currency_text}</span><CustomCounter targetNumber={dashData?.loans?.value} timeInSeconds='1' /></p> */}
<p className='text-xl sm:text-[30px]'><span className='text-lg sm:text-xl'>
{/*{dashData?.loans?.currency_text}*/}
</span><CustomCounter targetNumber={formatNumber(dashData?.loans?.value)} timeInSeconds='1' />
</p>
<p className='sm:text-[13.9px]'>{dashData?.loans?.text}</p>
</div>
</div>
<div className='box min-h-[230] justify-between bg-[#CBF0F5] dark:bg-black-box text-black-body dark:text-white-body'>
<p className='text-base sm:text-lg font-bold hover:text-primary'>Payments</p>
<div className='flex flex-wrap gap-2 items-end font-bold'>
<p className='text-xl sm:text-[30px]'><span className='text-lg sm:text-xl'>
</span><CustomCounter targetNumber={formatNumber(dashData?.signups?.value)} timeInSeconds='1'/>
</p>
<p className='sm:text-[13.9px]'>{dashData?.signups?.text.toString()}</p>
</div>
</div>
<div
className='box min-h-[230] justify-between bg-[#CBF0F5] dark:bg-black-box text-black-body dark:text-white-body'>
<p className='text-base sm:text-lg font-bold hover:text-primary'>Payments</p>
<div className='flex flex-wrap gap-2 items-end font-bold'>
<p className='text-xl sm:text-[30px]'><span className='text-lg sm:text-xl'>
{dashData?.payments?.currency_text}
</span><CustomCounter targetNumber={formatNumber(dashData?.payments?.value)} timeInSeconds='1' />
</p>
<p className='sm:text-[13.9px]'>{dashData?.payments?.text}</p>
</div>
</div>
<div className='box min-h-[230] justify-between bg-[#CBD4F4] dark:bg-black-box text-black-body dark:text-white-body'>
<p className='mb-4 text-base sm:text-lg font-bold hover:text-primary'>Provision Summary</p>
<div className='grid grid-cols-2 gap-4 font-bold'>
{
Object.values(dashData?.request_summary).map((item, index) => {
return (
<div key={index} className='flex items-center gap-2'>
<div className='min-w-10 min-h-10 bg-white-body dark:bg-black-box dark:shadow-[0_0_0_1px_#f9f9f9] rounded-md flex justify-center items-center'>
<Icons name='sales' />
</span><CustomCounter targetNumber={formatNumber(dashData?.payments?.value)} timeInSeconds='1'/>
</p>
<p className='sm:text-[13.9px]'>{dashData?.payments?.text}</p>
</div>
</div>
<div
className='box min-h-[230] justify-between bg-[#CBD4F4] dark:bg-black-box text-black-body dark:text-white-body'>
<p className='mb-4 text-base sm:text-lg font-bold hover:text-primary'>Provision Summary</p>
<div className='grid grid-cols-2 gap-4 font-bold'>
{
Object.values(dashData?.request_summary).map((item, index) => {
return (
<div key={index} className='flex items-center gap-2'>
<div
className='min-w-10 min-h-10 bg-white-body dark:bg-black-box dark:shadow-[0_0_0_1px_#f9f9f9] rounded-md flex justify-center items-center'>
<Icons name='sales'/>
</div>
<div>
<p className='font-bold text-base'><CustomCounter
targetNumber={Object.values(item)[0]} timeInSeconds='1'/></p>
<p className='text-12 text-slate-500'>{Object.keys(item)[0]}</p>
</div>
</div>
)
})
}
</div>
</div>
</div>
<div>
<p className='font-bold text-base'><CustomCounter targetNumber={Object.values(item)[0]} timeInSeconds='1' /></p>
<p className='text-12 text-slate-500'>{Object.keys(item)[0]}</p>
</div>
</div>
)
})
}
</div>
</div>
</div>
<div className='w-full'>
<div className='box gap-8 bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<div className='grid grid-cols-1 xs:grid-cols-2 gap-4'>
<div className='flex flex-col gap-1 order-2 xs:order-1'>
<p className='font-bold text-base'>Recent Subscriptions</p>
{/* <p className='text-12'>Over 500 members</p> */}
</div>
{/* <div className='order-1 xs:order-2 text-left xs:text-right'>
<div className='w-full'>
<div className='box gap-8 bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<div className='grid grid-cols-1 xs:grid-cols-2 gap-4'>
<div className='flex flex-col gap-1 order-2 xs:order-1'>
<p className='font-bold text-base'>Recent Subscriptions</p>
{/* <p className='text-12'>Over 500 members</p> */}
</div>
{/* <div className='order-1 xs:order-2 text-left xs:text-right'>
<button className='font-bold bg-white-aside text-black-body text-12 px-4 py-2 hover:text-primary hover:bg-sky-50 dark:hover:text-white dark:hover:bg-primary dark:text-white-body dark:bg-black-body rounded-md'>+ New Member</button>
</div> */}
</div>
<table className="py-2 w-full text-sm">
<thead className="py-2 text-sm text-slate-500 text-left font-semibold">
<tr>
<th scope="col" className="px-2 py-2">
Subscription
</th>
<th scope="col" className="px-2">
Status
</th>
<th scope="col" className="px-2">
Activity
</th>
<th scope="col" className="px-2 text-right">
Action
</th>
</tr>
</thead>
<tbody>
{(dashData?.subscription && dashData?.subscription.length > 0) ? dashData?.subscription?.map((item, index) => {
if(index <= 10) {
return (
<tr key={item?.id} 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/select_offer.png`)} alt="Icon" />
<div className="text-left">
<div className="text-base font-semibold">{item?.product_id}</div>
<div className="font-normal text-gray-500">{getDateFromDateString(item?.added)} {getTimeFromDateString(item?.added)}</div>
</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold"><a href={`https://${item?.internal_url}`} target='_blank' rel="noreferrer">{item?.internal_url}</a></div>
<div className="font-normal text-gray-500">{item?.status}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="font-normal text-gray-500">50%</div>
<div className="relative h-[6px] w-full bg-white-body dark:bg-black-body rounded-full overflow-hidden">
<div className={`absolute left-0 h-full w-1/2 bg-emerald-600`}></div>
</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'>
<Icons name='edit' />
</div> */}
<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={RouteLinks.transaction_details_page} state={{transactionID: item?.transaction_id}}>
<Icons name='eye' />
</Link>
</div>
{/* <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'>
<Icons name='trash' />
</div> */}
</div>
</td>
</tr>
)
}else{
return null
}
}
)
:
<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>
}
<>
{dashData?.subscription.length > 10 &&
<tr className="py-2 border-t border-dashed text-right text-primary border-slate-300">
<td className="px-3 py-2" colSpan={4}>
<Link to={RouteLinks.transactionsPage} className="flex justify-end items-center">
More ...
</Link>
</td>
</tr>
}
</>
</tbody>
</table>
</div>
<table className="py-2 w-full text-sm">
<thead className="py-2 text-sm text-slate-500 text-left font-semibold">
<tr>
<th scope="col" className="px-2 py-2">
Subscription
</th>
<th scope="col" className="px-2">
URL
</th>
<th scope="col" className="px-2">
Status
</th>
<th scope="col" className="px-2 text-right">
Action
</th>
</tr>
</thead>
<tbody>
{(dashData?.subscription && dashData?.subscription.length > 0) ? dashData?.subscription?.map((item, index) => {
if (index <= 10) {
return (
<tr key={item?.id} 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/select_offer.png`)}
alt="Icon"/>
<div className="text-left">
<div
className="text-base font-semibold">{item?.product_id}</div>
<div
className="font-normal text-gray-500">{getDateFromDateString(item?.added)} {getTimeFromDateString(item?.added)}</div>
</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold"><a
href={`https://${item?.internal_url}`} target='_blank'
rel="noreferrer">{item?.internal_url}</a></div>
<div className="font-normal text-gray-500">
<a href={`http://${item?.primary_server}:${item?.provision_port}`}
target='_blank'
rel="noreferrer">
{item?.primary_server}:{item?.provision_port} </a></div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="font-normal text-gray-500">{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?.uid}`}
state={{subscriptionUID: item?.uid}}
>
<Icons name='eye'/>
</Link>
</div>
</div>
</td>
</tr>
)
} else {
return null
}
}
)
:
<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>
}
<>
{dashData?.subscription.length > 10 &&
<tr className="py-2 border-t border-dashed text-right text-primary border-slate-300">
<td className="px-3 py-2" colSpan={4}>
<Link to={RouteLinks.transactionsPage}
className="flex justify-end items-center">
More ...
</Link>
</td>
</tr>
}
</>
</tbody>
</table>
</div>
</div>
</div>
}
</div>
</div>
}
</div>
)
)
}
@@ -157,6 +157,7 @@ const asideNavLinks = [
{name: 'Billings', status: 1, icon: 'dot', to: RouteLinks.billings},
{
name: 'Configurations', status: 1, icon: 'arrow-right', subLinks: [
{name: 'Country', status: 1, icon: 'dot', to: RouteLinks.countrySettings},
{name: 'Product Settings', status: 1, icon: 'dot', to: RouteLinks.products},
{name: 'Product Templates', status: 1, icon: 'dot', to: RouteLinks.productTemplates},
{name: 'Custom Templates', status: 1, icon: 'dot', to: RouteLinks.customTemplates},
+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(200, 'must not exceed 200 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>
)
}
+12 -5
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() {
@@ -43,14 +44,19 @@ export default function CustomTemplates() {
},
staleTime: 0 //0 mins
})
const customTemData = data?.data?.products // CUSTOM TEMPLATE LIST
const customTemData = data?.data?.templates // CUSTOM TEMPLATE LIST
const pagination = data?.data?.pagination
// console.log('DATA', data?.data)
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'>
@@ -104,12 +111,12 @@ export default function CustomTemplates() {
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.name}</div>
<div className="text-base font-semibold">{item?.custom_id}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.product_id}</div>
<div className="text-base font-semibold">{item?.provision_name}</div>
</div>
</td>
<td className="px-2">
+6 -14
View File
@@ -6,7 +6,7 @@ import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons'
import { getProductsTemplate } from '../../services/siteServices'
import getDateTimeFromDateString from '../../helpers/getDateTimeFromDateString'
// import getDateTimeFromDateString from '../../helpers/getDateTimeFromDateString'
export default function ProductTemplates() {
@@ -43,7 +43,7 @@ export default function ProductTemplates() {
},
staleTime: 0 //0 mins
})
const productsTemData = data?.data?.products // PRODUCTS TEMPLATE LIST
const productsTemData = data?.data?.templates // PRODUCTS TEMPLATE LIST
const pagination = data?.data?.pagination
// console.log('DATA', data?.data)
@@ -81,10 +81,7 @@ export default function ProductTemplates() {
<th scope="col" className="px-2 py-2">
Product ID
</th>
<th scope="col" className="px-2">
Name
</th>
<th scope="col" className="px-2">
<th scope="col" className="px-8">
Provision Name
</th>
<th scope="col" className="px-2 text-right">
@@ -98,18 +95,13 @@ export default function ProductTemplates() {
<td className="px-2 py-2">
<div className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
<div className="text-left">
<div className="text-base font-semibold">{getDateTimeFromDateString(item?.added)}</div>
<div className="text-base font-semibold">{item?.product_id}</div>
</div>
</div>
</td>
<td className="px-2">
<td className="px-8">
<div className="text-left">
<div className="text-base font-semibold">{item?.name}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.product_id}</div>
<div className="text-base font-semibold">{item?.provision_name}</div>
</div>
</td>
<td className="px-2">
@@ -0,0 +1,201 @@
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, useState} from 'react';
import RouteLinks from '../../RouteLinks';
import { getSubscriptionsView, updateTemplate, updateCustomTemplate } from '../../services/siteServices'
import queryKeys from '../../services/queryKeys'
import getDateTimeFromDateString from '../../helpers/getDateTimeFromDateString';
export default function SubscriptionViewCom() {
const {state} = useLocation()
const navigate = useNavigate()
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) => {
return updateTemplate(fields)
},
// onError: (error) => {
// },
// onSuccess: (res) => {
// },
onSettled: () => {
setTimeout(()=>{
templateUpdate.reset()
}, 3000)
}
})
const customTemplateUpdate = useMutation({
mutationFn: (fields) => {
return updateCustomTemplate(fields)
},
// onError: (error) => {
// },
// onSuccess: (res) => {
// },
onSettled: () => {
setTimeout(()=>{
customTemplateUpdate.reset()
}, 3000)
}
})
const handleUpdateTemplate = () => {
const reqData = {
subscrtiption_uid: state?.subscriptionUID,
template_uid: values.template_uid
}
templateUpdate.mutate(reqData)
}
const handleUpdateCustomTemplate = () => {
const reqData = {
subscrtiption_uid: state?.subscriptionUID,
custom_id: values.custom_id
}
customTemplateUpdate.mutate(reqData)
}
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title={`Subscription View [${state?.subscriptionUID}]`} paths={['Dashboard', 'Subscription View']}/>
{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>
<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 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>
</>
}
</div>
)
}
+136 -90
View File
@@ -1,12 +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';
@@ -17,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)
}
@@ -51,94 +53,138 @@ 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>
</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>
<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/Server
</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}
<br/>
<a href={`http://${item?.primary_server}:${item?.provision_port}`}
target='_blank'
rel="noreferrer">{item?.primary_server}:{item?.provision_port}</a>
</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base">
<span>Int :</span><a href={`https://${item?.internal_url}`}
target='_blank'
rel="noreferrer"> {item?.internal_url}</a>
<br/>
<span>Ext :</span><a href={`https://${item?.external_url}`}
target='_blank'
rel="noreferrer"> {item?.external_url}</a>
<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>
+8
View File
@@ -0,0 +1,8 @@
import React from 'react'
import CountrySettings from "../components/country/CountrySettings";
export default function CountrySettingsPage() {
return (
<CountrySettings />
)
}
+7
View File
@@ -0,0 +1,7 @@
import React from 'react'
import SubscriptionViewCom from "../components/subscription_view/SubscriptionViewCom";
export default function SubscriptionDetailsPage() {
return (
<SubscriptionViewCom />
)
}
+2
View File
@@ -20,7 +20,9 @@ const queryKeys = {
products_template: ['products_template'],
custom_template: ['custom_template'],
account_view: ['account_view'],
subscriptions_view: ['subscriptions_view'],
users_admin: ['users_admin'],
country_list: ['country_list'],
}
export default queryKeys
+45 -3
View File
@@ -62,6 +62,20 @@ export const getCustomers = (reqData) => {
return getAuxEnd(`/customers`, postData)
}
// FUNCTION TO GET COUNTRY
export const getCountry = (reqData) => {
const postData = { ...reqData }
return getAuxEnd(`/country`, postData)
}
// FUNCTION TO SET COUNTRY
export const setCountry = (reqData) => {
let postData = {
...reqData
}
return postAuxEnd('/set-country', postData, false)
}
// FUNCTION TO GET BILLINGS
export const getBillings = (reqData) => {
const postData = { ...reqData }
@@ -101,13 +115,37 @@ export const getUsers = (reqData) => {
// FUNCTION TO GET PRODUCTS TEMPLATE DATA
export const getProductsTemplate = (reqData) => {
const postData = { ...reqData }
return getAuxEnd(`/products-template`, postData)
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 UPDATE CUSTOM TEMPLATE
export const updateCustomTemplate = (reqData) => {
let postData = {
...reqData
}
return postAuxEnd('/template/set-custom', 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 }
return getAuxEnd(`/custom-template`, postData)
return getAuxEnd(`/custom-templates`, postData)
}
// FUNCTION TO VIEW SELECTED ACCOUNT DATA
@@ -116,7 +154,11 @@ 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