install and handle casle & prevent page dashboard & handle register and code verfication & get data in clinics page
This commit is contained in:
+15
-4
@@ -1,15 +1,26 @@
|
||||
// app/clinics/page.js
|
||||
import ClinicsPage from "@/components/clinics";
|
||||
import Layout from "@/components/layout/StLayout";
|
||||
import { getStateInfo } from "@/lib/getStateInfo";
|
||||
import axios from "axios";
|
||||
|
||||
function Clinics() {
|
||||
export default async function Clinics() {
|
||||
const { matchedCity, matchedState } = getStateInfo();
|
||||
|
||||
const response = await axios.get(
|
||||
"https://back-dev.clinic-pro.ir/api/v1/clinics?page=1&limit=10"
|
||||
);
|
||||
|
||||
const clinics = response.data.$data;
|
||||
console.log(clinics);
|
||||
|
||||
return (
|
||||
<Layout name="/clinics">
|
||||
<ClinicsPage matchedCity={matchedCity} matchedState={matchedState} />
|
||||
<ClinicsPage
|
||||
clinics={clinics}
|
||||
matchedCity={matchedCity}
|
||||
matchedState={matchedState}
|
||||
/>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export default Clinics;
|
||||
|
||||
+10
-1
@@ -1,8 +1,17 @@
|
||||
import Content from "@/components/dashboard/Content";
|
||||
import { defineAbilitiesFor } from "@/lib/ability";
|
||||
import { getUser } from "@/lib/auth";
|
||||
import { getStateInfo } from "@/lib/getStateInfo";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
function UserAccount() {
|
||||
async function UserAccount() {
|
||||
const { matchedCity } = getStateInfo();
|
||||
const user = await getUser();
|
||||
const ability = defineAbilitiesFor(user);
|
||||
|
||||
if (!ability.can("access", "Dashboard")) {
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
return <Content matchedCity={matchedCity} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user