//next.js page to show all locatons in the database with a link to the location page import { Location, UserRole } from "@prisma/client"; import Layout from "../../../components/layout"; import LocationCard from "../../../components/location/LocationCard"; import axiosServer from '../../../src/axiosServer'; import ProtectedRoute from '../../../components/protectedRoute'; interface IProps { item: Location; } function LocationsPage({ items = [] }: IProps) { const renderLocations = () => { if (!Array.isArray(items) || items.length === 0) return

No Locations

; return items.map((item) => ( )); }; return (
{renderLocations()}
{/* add location link */}
Add Location
); } export default LocationsPage; export const getServerSideProps = async (context) => { const axios = await axiosServer(context); const { data: items } = await axios.get("/api/data/locations"); //console.log('get server props - locations:' + items.length); //console.log(items); return { props: { items, }, }; };