diff --git a/src/app/_components/AllCountries.tsx b/src/app/_components/AllCountries.tsx index 5fdbd62..e7744a0 100644 --- a/src/app/_components/AllCountries.tsx +++ b/src/app/_components/AllCountries.tsx @@ -1,9 +1,9 @@ import { Delete } from "lucide-react"; import { deleteCountry } from "~/server/actions/deleteCountry"; -import { db } from "~/server/db"; +import getAllCountries from "~/server/actions/getAllCountries"; export default async function AllCountries() { - const countries = await db.query.countries.findMany(); + const countries = await getAllCountries(); return (

All Countries:

diff --git a/src/app/_components/AllRegions.tsx b/src/app/_components/AllRegions.tsx index 4eb73b8..30015c2 100644 --- a/src/app/_components/AllRegions.tsx +++ b/src/app/_components/AllRegions.tsx @@ -1,8 +1,9 @@ -import { db } from "~/server/db"; +import getAllCountries from "~/server/actions/getAllCountries"; +import getAllRegions from "~/server/actions/getAllRegions"; export default async function AllRegions() { - const allRegions = await db.query.regions.findMany(); - const allCountries = await db.query.countries.findMany(); + const allRegions = await getAllRegions(); + const allCountries = await getAllCountries(); return (

All Regions:

diff --git a/src/server/actions/getAllCountries.ts b/src/server/actions/getAllCountries.ts new file mode 100644 index 0000000..43e7763 --- /dev/null +++ b/src/server/actions/getAllCountries.ts @@ -0,0 +1,6 @@ +import { db } from "../db"; + +export default async function getAllCountries() { + const allCountries = await db.query.countries.findMany(); + return allCountries; +} diff --git a/src/server/actions/getAllRegions.ts b/src/server/actions/getAllRegions.ts new file mode 100644 index 0000000..a478386 --- /dev/null +++ b/src/server/actions/getAllRegions.ts @@ -0,0 +1,6 @@ +import { db } from "../db"; + +export default async function getAllRegions() { + const allRegions = await db.query.regions.findMany(); + return allRegions; +}