Skip to content

Commit

Permalink
Merge pull request #25 from moh-kenya/swr-base-url
Browse files Browse the repository at this point in the history
Update api base url and table pagination
  • Loading branch information
CynthiaKamau authored Feb 1, 2024
2 parents 5741486 + 241652f commit a92f81c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
API_URL=http://localhost:8000/api
NEXT_PUBLIC_API_URL=http://41.89.92.186:8000
APP_DEBUG=true
USE_MOCK_API=false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
3 changes: 2 additions & 1 deletion pages/api/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import useSWR from "swr";
import { API_BASE_URL } from '../index';

export const searchConcepts = (searchParams) => {
const fetcher = (url) => fetch(url).then((res) => res.json());
Expand All @@ -10,7 +11,7 @@ export const searchConcepts = (searchParams) => {
isError,
mutate,
} = useSWR(
`https://nhdd-staging-api.health.go.ke/concepts/?q=${searchParams}&verbose=false&includeRetired=false&includeInverseMappings=false`,
`${API_BASE_URL}/concepts/?q=${searchParams}&limit=1000&verbose=false&includeRetired=false&includeInverseMappings=false`,
fetcher,
{ revalidateOnFocus: false, revalidateOnReconnect: false }
);
Expand Down
2 changes: 2 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { useRouter } from "next/router";

const inter = Inter({ subsets: ["latin"] });

export const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;

export default function Home() {
const router = useRouter();
const [activeTab, setActiveTab] = useState("1");
Expand Down
6 changes: 4 additions & 2 deletions pages/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function SearchResults() {
const columns = [
"id",
"display_name",
"type",
"concept_class",
"datatype",
"source",
"retired",
Expand Down Expand Up @@ -92,6 +92,7 @@ function SearchResults() {
<Box my={2} sx={{ width: "100%" }}>
<DataGrid
rows={Object.values(data)}
getRowId={(row) => row.uuid}
columns={columns.map((key) => {
return {
field: key.toLowerCase(),
Expand All @@ -118,8 +119,9 @@ function SearchResults() {
};
})}
initialState={{
pagination: { pageSize: 25 },
pagination: { paginationModel: { pageSize: 25 } },
}}
pageSizeOptions={[25, 50, 100, 250]}
onRowClick={(row) => {
// TODO: go to the resource's page
router.push("/" + row.row.type + "/" + row.row.id);
Expand Down
2 changes: 1 addition & 1 deletion utilities/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let debug = process.env.APP_ENV || false;
let api_url = process.env.API_URL
let api_url = process.env.NEXT_PUBLIC_API_URL
console.log("api url", api_url)
let cookie_suffix = '';

Expand Down

0 comments on commit a92f81c

Please sign in to comment.