diff --git a/app/clinics/page.js b/app/clinics/page.js
index 588d600..4074d50 100644
--- a/app/clinics/page.js
+++ b/app/clinics/page.js
@@ -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 (
-
+
);
}
-
-export default Clinics;
diff --git a/app/dashboard/page.js b/app/dashboard/page.js
index fe89cd2..bf90a72 100644
--- a/app/dashboard/page.js
+++ b/app/dashboard/page.js
@@ -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 ;
}
diff --git a/components/clinics/index.js b/components/clinics/index.js
index 498c7a9..7d0faa5 100644
--- a/components/clinics/index.js
+++ b/components/clinics/index.js
@@ -1,15 +1,13 @@
"use client";
-import { useEffect, useState } from "react";
+import { useState } from "react";
import List from "./list";
import { searchOnList } from "@/helper";
import SearchBar from "./head/SearchBar";
-import clinics from "@/data/clinics.json";
import HeadPageList from "@/app/component/head";
-function ClinicsPage({ matchedCity, matchedState }) {
- const [loading, setLoading] = useState(true);
+function ClinicsPage({ clinics, matchedCity, matchedState }) {
const [filteredClinics, setFilteredClinics] = useState(clinics);
const [selected, setSelected] = useState({
@@ -17,12 +15,6 @@ function ClinicsPage({ matchedCity, matchedState }) {
city: matchedCity?.name || "",
});
- useEffect(() => {
- setTimeout(() => {
- setLoading(false);
- }, 2000);
- }, []);
-
const handleSearch = (value) => {
const searchOnName = searchOnList(clinics, value, "title");
const searchOnLocation = searchOnList(searchOnName, selected.city, "city");
@@ -42,7 +34,7 @@ function ClinicsPage({ matchedCity, matchedState }) {
handleSearch={handleSearch}
/>
-
+
);
}
diff --git a/components/clinics/list/ItemClinic.js b/components/clinics/list/ItemClinic.js
index 410875d..0145857 100644
--- a/components/clinics/list/ItemClinic.js
+++ b/components/clinics/list/ItemClinic.js
@@ -7,20 +7,25 @@ import { Button } from "@mui/material";
import Image from "next/image";
import Link from "next/link";
-function ItemClinic({ data, loading }) {
+function ItemClinic({ data }) {
return (
-
-
+
+
-
+
- {data.title}
+ {data.label}
-
+
{data.doctors} پزشک
@@ -30,7 +35,7 @@ function ItemClinic({ data, loading }) {
-
+
{data.location}
@@ -38,7 +43,7 @@ function ItemClinic({ data, loading }) {
-
+
ساعت کاری: {data.hours_of_work}
@@ -47,13 +52,8 @@ function ItemClinic({ data, loading }) {
{/* Arrow */}
-
-