last update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import BlogPage from "@/components/blog";
|
||||
import Layout from "@/components/layout/StLayout";
|
||||
import { fetchReq } from "@/lib/ability";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
|
||||
async function Blog({ params: { slug } }) {
|
||||
const blog = await fetchReq(
|
||||
@@ -8,12 +8,9 @@ async function Blog({ params: { slug } }) {
|
||||
);
|
||||
const blogs = await fetchReq("https://back-dev.clinic-pro.ir/api/v1/blogs");
|
||||
|
||||
const resBlog = blog;
|
||||
const resBlogs = blogs;
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<BlogPage blog={resBlog} blogs={resBlogs.blogs} />
|
||||
<BlogPage blog={blog} blogs={blogs.blogs} />
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import BlogsPage from "@/components/blogs";
|
||||
import Layout from "@/components/layout/StLayout";
|
||||
import { fetchReq } from "@/lib/ability";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
|
||||
export default async function Blogs() {
|
||||
const response = await fetchReq(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import ClinicPage from "@/components/clinic";
|
||||
import Layout from "@/components/layout/StLayout";
|
||||
import { fetchReq } from "@/lib/ability";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
|
||||
async function Clinic({ params: { slug } }) {
|
||||
const reqClinics = await fetchReq(
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// app/clinics/page.js
|
||||
import ClinicsPage from "@/components/clinics";
|
||||
import Layout from "@/components/layout/StLayout";
|
||||
import { fetchReq } from "@/lib/ability";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
import { getStateInfo } from "@/lib/getStateInfo";
|
||||
|
||||
export default async function Clinics() {
|
||||
|
||||
+16
-21
@@ -1,8 +1,8 @@
|
||||
import Content from "@/components/dashboard/Content";
|
||||
import { defineAbilitiesFor, fetchReq } from "@/lib/ability";
|
||||
import { defineAbilitiesFor } from "@/lib/ability";
|
||||
import { getUser } from "@/lib/auth";
|
||||
import { getStateInfo } from "@/lib/getStateInfo";
|
||||
import axios from "axios";
|
||||
import { fetchReq } from "@/lib/req";
|
||||
import { cookies, headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
@@ -12,36 +12,31 @@ export default async function Dashboard({ searchParams }) {
|
||||
const ability = defineAbilitiesFor(user);
|
||||
const cookieStore = cookies();
|
||||
const token = cookieStore.get("access_token");
|
||||
const uuid = cookieStore.get("uuid");
|
||||
|
||||
let dashboard = null;
|
||||
try {
|
||||
const response = await fetchReq(
|
||||
`https://back-dev.clinic-pro.ir/api/v1/user-profile/${uuid}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
dashboard = response.data;
|
||||
} catch (error) {
|
||||
// console.error("problem with req:", error.message);
|
||||
// return redirect("/unauthorized");
|
||||
}
|
||||
const userInfo = cookieStore.get("userInfo");
|
||||
console.log(userInfo.value.uuid);
|
||||
|
||||
if (!ability.can("access", "Dashboard")) {
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
const response = await fetchReq(
|
||||
`https://back-dev.clinic-pro.ir/api/v1/user-profile/${userInfo.value.uuid}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token.value}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => console.log(res))
|
||||
.catch((err) => console.log(err));
|
||||
|
||||
const userAgent = headers().get("user-agent") || "";
|
||||
const isMobile = /Mobi|Android/i.test(userAgent);
|
||||
|
||||
return (
|
||||
<Content
|
||||
dataUser={response}
|
||||
logged={token.value}
|
||||
dataUser={dashboard}
|
||||
params={searchParams}
|
||||
matchedCity={matchedCity}
|
||||
initialTurnsDetails={isMobile}
|
||||
|
||||
@@ -11,8 +11,6 @@ async function Doctors({ searchParams }) {
|
||||
const response = await axios.get(
|
||||
"https://back-dev.clinic-pro.ir/api/v1/doctors"
|
||||
);
|
||||
console.log(response);
|
||||
|
||||
doctors = response.data.$data;
|
||||
} catch (error) {
|
||||
// console.error("problem with req:", error.message);
|
||||
|
||||
+11
-1
@@ -1,6 +1,16 @@
|
||||
import ContentLogin from "@/components/register/ContentLogin";
|
||||
import { defineAbilitiesFor } from "@/lib/ability";
|
||||
import { getUser } from "@/lib/auth";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
async function LogIn() {
|
||||
const user = await getUser();
|
||||
const ability = defineAbilitiesFor(user);
|
||||
|
||||
if (!ability.can("access", "Login")) {
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
function LogIn() {
|
||||
return <ContentLogin />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user