Skip to content

Commit

Permalink
Updated facilities/index.js lines 107 - 117
Browse files Browse the repository at this point in the history
  • Loading branch information
ertush committed Oct 4, 2024
1 parent 4adb178 commit e318567
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pages/facilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ function FacilityHome(props) {

const router = useRouter()


console.log({props})

// const facilities = props?.data?.results
const filters = props?.filters
Expand Down Expand Up @@ -102,17 +104,17 @@ function FacilityHome(props) {
})()

// FilterOptions
const countyFilterOptions = filters['county']?.map(({ id, name }) => ({ value: id, label: name }))
const subCountyFilterOptions = filters['sub_county']?.map(({ id, name }) => ({ value: id, label: name }))
const constituencyFilterOptions = filters['constituency']?.map(({ id, name }) => ({ value: id, label: name }))
const wardFilterOptions = filters['ward']?.map(({ id, name }) => ({ value: id, label: name }))
const facilityTypeFilterOptions = filters['facility_type']?.map(({ id, name }) => ({ value: id, label: name }))
const facilityTypeDetailsFilterOptions = filters['facility_type_details']?.map(({ id, name }) => ({ value: id, label: name }))
const kephLevelFilterOptions = filters['keph_level']?.map(({ id, name }) => ({ value: id, label: name }))
const ownerTypeFilterOptions = filters['owner_type']?.map(({ id, name }) => ({ value: id, label: name }))
const ownerFilterOptions = filters['owner']?.map(({ id, name }) => ({ value: id, label: name }))
const countyFilterOptions = filters?.county?.map(({ id, name }) => ({ value: id, label: name }))
const subCountyFilterOptions = filters?.sub_county?.map(({ id, name }) => ({ value: id, label: name }))
const constituencyFilterOptions = filters?.constituency?.map(({ id, name }) => ({ value: id, label: name }))
const wardFilterOptions = filters?.ward?.map(({ id, name }) => ({ value: id, label: name }))
const facilityTypeFilterOptions = filters?.facility_type?.map(({ id, name }) => ({ value: id, label: name }))
const facilityTypeDetailsFilterOptions = filters?.facility_type_details?.map(({ id, name }) => ({ value: id, label: name }))
const kephLevelFilterOptions = filters?.keph_level?.map(({ id, name }) => ({ value: id, label: name }))
const ownerTypeFilterOptions = filters?.owner_type?.map(({ id, name }) => ({ value: id, label: name }))
const ownerFilterOptions = filters?.owner?.map(({ id, name }) => ({ value: id, label: name }))
// const serviceFilterOptions = filters['service']?.map(({ id, name }) => ({ value: id, label: name }))
const operationStatusFilterOptions = filters['operation_status']?.map(({ id, name }) => ({ value: id, label: name }))
const operationStatusFilterOptions = filters?.operation_status?.map(({ id, name }) => ({ value: id, label: name }))



Expand Down Expand Up @@ -1358,6 +1360,7 @@ export async function getServerSideProps(ctx) {
const page = ctx?.query?.page



const { response: user } = await getUserDetails(token, `${process.env.NEXT_PUBLIC_API_URL}/rest-auth/user/`)

const userGroup = user?.groups[0]?.id
Expand All @@ -1373,7 +1376,7 @@ export async function getServerSideProps(ctx) {

let url = nextURL ?? previousURL ?? defaultURL

const filters = await fetchFilters(token)
// const filters = await fetchFilters(token)

// console.log({filters})

Expand Down Expand Up @@ -1461,7 +1464,7 @@ export async function getServerSideProps(ctx) {
facilities: facilities?.results ?? null,
next: facilities?.next ?? null,
previous: facilities?.previous ?? null,
filters,
filters: await fetchFilters(token),
path: ctx.asPath || '/facilities',
current_url,
current_page: facilities?.current_page ?? null,
Expand Down

0 comments on commit e318567

Please sign in to comment.