Apply Pagination
This commit is contained in:
@@ -21,7 +21,7 @@ class BenefitController extends Controller
|
||||
$benefits = Benefit::query()
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
->paginate(999)
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
return $benefits;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Exceptions\ImportRowException;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\Exclusion;
|
||||
use App\Models\Icd;
|
||||
@@ -29,7 +30,8 @@ class DiagnosisExclusionController extends Controller
|
||||
->with(['exclusionable', 'rules'])
|
||||
->filter($request->toArray())
|
||||
->paginate();
|
||||
|
||||
// return $exclusions;
|
||||
return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions));
|
||||
return response()->json(DiagnosisExclusionResource::collection($exclusions)->response()->getData(true));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class MemberController extends Controller
|
||||
});
|
||||
}
|
||||
])
|
||||
->paginate(20)
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
return $benefits;
|
||||
|
||||
@@ -34,7 +34,7 @@ class PlanController extends Controller
|
||||
// $corporatePlan->where('corporate_id', $corporate_id);
|
||||
// })
|
||||
// ->with('corporatePlan')
|
||||
->paginate(0)
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
return $plans;
|
||||
|
||||
@@ -167,7 +167,7 @@ class MemberEnrollmentService
|
||||
"end_no_claim" => $row['end_no_claim'],
|
||||
];
|
||||
|
||||
if ($corporate->currentPolicy->code != $row['policy_number']) {
|
||||
if (!isset($corporate->currentPolicy) || $corporate->currentPolicy->code != $row['policy_number']) {
|
||||
throw new ImportRowException(__('enrollment.POLICY_NUMBER_NOT_MATCH', [
|
||||
'policy_id' => $row['policy_number']
|
||||
]), 0, null, $row);
|
||||
@@ -555,7 +555,7 @@ class MemberEnrollmentService
|
||||
throw new ImportRowException(__("enrollment.MODE_UNAVAILABLE"), 0, null, $row);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e; //new ImportRowException($e->getMessage(), (int) $e->getCode(), $e, $row);
|
||||
throw new ImportRowException($e->getMessage(), (int) $e->getCode(), $e, $row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Helper{
|
||||
public static function genderNormalization($anyGenderCode)
|
||||
{
|
||||
@@ -17,4 +19,18 @@ class Helper{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function paginateResources($resource)
|
||||
{
|
||||
return [
|
||||
'current_page' => $resource->currentPage(),
|
||||
'data' => $resource->items(),
|
||||
'first_page_url' => '',
|
||||
'from' => $resource->firstItem(),
|
||||
'last_page' => $resource->lastPage(),
|
||||
'last_page_url' => '',
|
||||
'links' => $resource->links(null, $resource->items()),
|
||||
'next_page_url' => $resource->nextPageUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@ import AddIcon from '@mui/icons-material/Add';
|
||||
import UploadIcon from '@mui/icons-material/Upload';
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
// hooks
|
||||
import React, { Component, useEffect, useRef, useState } from 'react';
|
||||
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
import { useParams, useSearchParams } from 'react-router-dom';
|
||||
// components
|
||||
import axios from '../../../utils/axios';
|
||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||
import BasePagination from '../../../components/BasePagination';
|
||||
|
||||
export default function PlanList() {
|
||||
const { themeStretch } = useSettings();
|
||||
@@ -323,11 +324,17 @@ export default function PlanList() {
|
||||
fontWeight: 'bold',
|
||||
};
|
||||
|
||||
const applyFilter = async (searchFilter) => {
|
||||
const applyFilter = async (searchFilter: string) => {
|
||||
await loadDataTableData({ "search" : searchFilter });
|
||||
setSearchParams({ "search" : searchFilter });
|
||||
}
|
||||
|
||||
const handlePageChange = (event : ChangeEvent, value: number) => {
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
|
||||
loadDataTableData(filter);
|
||||
setSearchParams(filter);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [])
|
||||
@@ -429,6 +436,8 @@ export default function PlanList() {
|
||||
)}
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -6,13 +6,14 @@ import AddIcon from '@mui/icons-material/Add';
|
||||
import UploadIcon from '@mui/icons-material/Upload';
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
// hooks
|
||||
import React, { Component, useEffect, useRef, useState } from 'react';
|
||||
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
import { useParams, useSearchParams } from 'react-router-dom';
|
||||
// components
|
||||
import axios from '../../../utils/axios';
|
||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||
import { Icd } from '../../../@types/diagnosis';
|
||||
import BasePagination from '../../../components/BasePagination';
|
||||
|
||||
export default function List() {
|
||||
const { themeStretch } = useSettings();
|
||||
@@ -265,6 +266,12 @@ export default function List() {
|
||||
setSearchParams({ "search" : searchFilter });
|
||||
}
|
||||
|
||||
const handlePageChange = (event : ChangeEvent, value: number) => {
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
|
||||
loadDataTableData(filter);
|
||||
setSearchParams(filter);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [])
|
||||
@@ -313,6 +320,8 @@ export default function List() {
|
||||
)}
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
import axios from '../../../utils/axios';
|
||||
import { CorporatePlan } from '../../../@types/corporates';
|
||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||
import BasePagination from '../../../components/BasePagination';
|
||||
|
||||
export default function PlanList() {
|
||||
const { themeStretch } = useSettings();
|
||||
@@ -161,6 +162,13 @@ export default function PlanList() {
|
||||
setSearchParams({ "search" : searchFilter });
|
||||
}
|
||||
|
||||
const handlePageChange = (event : ChangeEvent, value: number) => {
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
|
||||
loadDataTableData(filter);
|
||||
setSearchParams(filter);
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [])
|
||||
@@ -219,6 +227,7 @@ export default function PlanList() {
|
||||
)}
|
||||
</Table>
|
||||
</TableContainer>
|
||||
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ import AddIcon from '@mui/icons-material/Add';
|
||||
import UploadIcon from '@mui/icons-material/Upload';
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
// hooks
|
||||
import React, { Component, useEffect, useRef, useState } from 'react';
|
||||
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
import { useParams, useSearchParams } from 'react-router-dom';
|
||||
// components
|
||||
@@ -14,6 +14,7 @@ import axios from '../../../utils/axios';
|
||||
import { Plan } from '../../../@types/corporates';
|
||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||
import { Member } from '../../../@types/member';
|
||||
import BasePagination from '../../../components/BasePagination';
|
||||
|
||||
export default function CorporatePlanList() {
|
||||
const { themeStretch } = useSettings();
|
||||
@@ -48,11 +49,17 @@ export default function CorporatePlanList() {
|
||||
setDataTableData(response.data);
|
||||
}
|
||||
|
||||
const applyFilter = async (searchFilter) => {
|
||||
const applyFilter = async (searchFilter: string) => {
|
||||
await loadDataTableData({ "search" : searchFilter });
|
||||
setSearchParams({ "search" : searchFilter });
|
||||
}
|
||||
|
||||
const handlePageChange = (event : ChangeEvent, value: number) => {
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
|
||||
loadDataTableData(filter);
|
||||
setSearchParams(filter);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [])
|
||||
@@ -331,6 +338,8 @@ export default function CorporatePlanList() {
|
||||
)}
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -6,13 +6,14 @@ import AddIcon from '@mui/icons-material/Add';
|
||||
import UploadIcon from '@mui/icons-material/Upload';
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
// hooks
|
||||
import React, { Component, useEffect, useRef, useState } from 'react';
|
||||
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
import { useParams, useSearchParams } from 'react-router-dom';
|
||||
// components
|
||||
import axios from '../../../utils/axios';
|
||||
import { Plan } from '../../../@types/corporates';
|
||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||
import BasePagination from '../../../components/BasePagination';
|
||||
|
||||
export default function CorporatePlanList() {
|
||||
const { themeStretch } = useSettings();
|
||||
@@ -314,11 +315,17 @@ export default function CorporatePlanList() {
|
||||
fontWeight: 'bold',
|
||||
};
|
||||
|
||||
const applyFilter = async (searchFilter) => {
|
||||
const applyFilter = async (searchFilter: string) => {
|
||||
await loadDataTableData({ "search" : searchFilter });
|
||||
setSearchParams({ "search" : searchFilter });
|
||||
}
|
||||
|
||||
const handlePageChange = (event : ChangeEvent, value: number) => {
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
|
||||
loadDataTableData(filter);
|
||||
setSearchParams(filter);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, [])
|
||||
@@ -411,6 +418,8 @@ export default function CorporatePlanList() {
|
||||
)}
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -243,7 +243,7 @@ export default function List() {
|
||||
fontWeight: 'bold',
|
||||
};
|
||||
|
||||
const applyFilter = async (searchFilter: any) => {
|
||||
const applyFilter = async (searchFilter: string) => {
|
||||
await loadDataTableData({ "search" : searchFilter });
|
||||
setSearchParams({ "search" : searchFilter });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user