Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6927d53c59 | |||
| e24df8e744 |
@@ -3,36 +3,13 @@ import { useQuery } from '@tanstack/react-query'
|
|||||||
import queryKeys from '../../services/queryKeys'
|
import queryKeys from '../../services/queryKeys'
|
||||||
import BreadcrumbCom from "../breadcrumb/BreadcrumbCom";
|
import BreadcrumbCom from "../breadcrumb/BreadcrumbCom";
|
||||||
import { getCountry } from "../../services/siteServices";
|
import { getCountry } from "../../services/siteServices";
|
||||||
import TablePaginatedWrapper from "../tableWrapper/TablePaginatedWrapper";
|
import TableWrapper from "../tableWrapper/TableWrapper";
|
||||||
|
|
||||||
export default function CountrySettings(){
|
export default function CountrySettings(){
|
||||||
|
|
||||||
const [page, setPage] = useState(1)
|
|
||||||
const [filter, setFilter] = useState({type: '', id: ''})
|
|
||||||
const [willFilter, setWillFilter] = useState(false)
|
|
||||||
|
|
||||||
const handleFilter = ({target:{name, value}}) => {
|
|
||||||
setFilter(prev => ({...prev, [name]:value}))
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleFilterByParams = () => {
|
|
||||||
if(filter.type && !filter.id){
|
|
||||||
return
|
|
||||||
}else if(!filter.type){
|
|
||||||
setPage(1)
|
|
||||||
setWillFilter(prev => !prev)
|
|
||||||
setFilter({type: '', id: ''})
|
|
||||||
}else{
|
|
||||||
setPage(1)
|
|
||||||
setWillFilter(prev => !prev)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const {data, isFetching, isError, error} = useQuery({
|
const {data, isFetching, isError, error} = useQuery({
|
||||||
// queryKey: [...queryKeys.country_list, page, willFilter],
|
|
||||||
queryKey: queryKeys.country_list,
|
queryKey: queryKeys.country_list,
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
// const filterData = filter?.type ? {[filter?.type]: filter.id} : {}
|
|
||||||
const reqData = {
|
const reqData = {
|
||||||
// page,
|
// page,
|
||||||
// ...filterData
|
// ...filterData
|
||||||
@@ -41,9 +18,8 @@ export default function CountrySettings(){
|
|||||||
},
|
},
|
||||||
staleTime: 0 //0 mins
|
staleTime: 0 //0 mins
|
||||||
})
|
})
|
||||||
const countryData = data?.data?.templates // PRODUCTS TEMPLATE LIST
|
const countryData = data?.data?.country_data // COUNTRY LIST
|
||||||
const pagination = data?.data?.pagination
|
|
||||||
console.log('DATA', data?.data)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full flex flex-col gap-8'>
|
<div className='w-full flex flex-col gap-8'>
|
||||||
@@ -52,135 +28,71 @@ export default function CountrySettings(){
|
|||||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||||
|
|
||||||
<>
|
<>
|
||||||
{/* <table className="py-2 w-full text-sm">
|
{isFetching ?
|
||||||
<thead className="py-2 text-sm text-slate-500 text-left">
|
<p className='text-slate-800'>Loading...</p>
|
||||||
<tr>
|
: isError ?
|
||||||
<th scope="col" className="px-2 py-2">
|
<p className='text-red-500'>{error.message}</p>
|
||||||
Code
|
:
|
||||||
</th>
|
<TableWrapper data={countryData} itemsPerPage={20}>
|
||||||
<th scope="col" className="px-8">
|
{({ data }) => (
|
||||||
Country
|
<>
|
||||||
</th>
|
<table className="py-2 w-full text-sm">
|
||||||
<th scope="col" className="px-2 text-right">
|
<thead className="py-2 text-sm text-slate-500 text-left">
|
||||||
Status
|
<tr>
|
||||||
</th>
|
<th scope="col" className="px-2 py-2">
|
||||||
<th scope="col" className="px-2 text-right">
|
Code
|
||||||
Signup
|
</th>
|
||||||
</th>
|
<th scope="col" className="px-8">
|
||||||
</tr>
|
Country
|
||||||
</thead>
|
</th>
|
||||||
<tbody>
|
<th scope="col" className="px-2 text-right">
|
||||||
<tr className="py-2 border-t border-dashed border-slate-300">
|
Status
|
||||||
<td className="px-2 py-2">
|
</th>
|
||||||
<div className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
|
<th scope="col" className="px-2 text-right">
|
||||||
<div className="text-left">
|
Signup
|
||||||
<div className="text-base font-semibold">US</div>
|
</th>
|
||||||
</div>
|
</tr>
|
||||||
</div>
|
</thead>
|
||||||
</td>
|
<tbody>
|
||||||
<td className="px-8">
|
{(data && data.length > 0) ? data?.map((item, index) => (
|
||||||
<div className="text-left">
|
<tr key={index} className="py-2 border-t border-dashed border-slate-300">
|
||||||
<div className="text-base font-semibold">United States</div>
|
<td className="px-2 py-2">
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-8">
|
|
||||||
<div className="text-left">
|
|
||||||
<div className="text-base font-semibold">[chkbox]</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-8">
|
|
||||||
<div className="text-left">
|
|
||||||
<div className="text-base font-semibold">[chkbox]</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr 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'>
|
|
||||||
<div className="text-left">
|
|
||||||
<div className="text-base font-semibold">NG</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-8">
|
|
||||||
<div className="text-left">
|
|
||||||
<div className="text-base font-semibold">Nigeria</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-8">
|
|
||||||
<div className="text-left">
|
|
||||||
<div className="text-base font-semibold">[chkbox]</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-8">
|
|
||||||
<div className="text-left">
|
|
||||||
<div className="text-base font-semibold">[chkbox]</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table> */}
|
|
||||||
<TablePaginatedWrapper data={countryData} 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">
|
|
||||||
Code
|
|
||||||
</th>
|
|
||||||
<th scope="col" className="px-8">
|
|
||||||
Country
|
|
||||||
</th>
|
|
||||||
<th scope="col" className="px-2 text-right">
|
|
||||||
Status
|
|
||||||
</th>
|
|
||||||
<th scope="col" className="px-2 text-right">
|
|
||||||
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='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
|
|
||||||
<div className="text-left">
|
<div className="text-left">
|
||||||
<div className="text-base font-semibold">US</div>
|
<div className="text-base font-semibold">{item?.code}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
<td className="px-8">
|
||||||
<td className="px-8">
|
<div className="text-left">
|
||||||
<div className="text-left">
|
<div className="text-base font-semibold">{item?.description}</div>
|
||||||
<div className="text-base font-semibold">United States</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
<td className="px-8">
|
||||||
<td className="px-8">
|
<div className="text-right">
|
||||||
<div className="text-left">
|
<div className="text-base font-semibold">{item?.status}</div>
|
||||||
<div className="text-base font-semibold">[chkbox]</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
<td className="px-8">
|
||||||
<td className="px-8">
|
<div className="text-right">
|
||||||
<div className="text-left">
|
<div className="text-base font-semibold">{item?.signup}</div>
|
||||||
<div className="text-base font-semibold">[chkbox]</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
))
|
||||||
))
|
:
|
||||||
:
|
<tr className="py-2 border-t border-dashed border-slate-300">
|
||||||
<tr className="py-2 border-t border-dashed border-slate-300">
|
<td className="px-3 py-2" colSpan={4}>
|
||||||
<td className="px-3 py-2" colSpan={4}>
|
<div className="flex justify-center items-center">
|
||||||
<div className="flex justify-center items-center">
|
No Record Found
|
||||||
No Record Found
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
}
|
||||||
}
|
</tbody>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
</>
|
||||||
</>
|
)}
|
||||||
)}
|
</TableWrapper>
|
||||||
</TablePaginatedWrapper>
|
}
|
||||||
</>
|
</>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user