refactor: update appointment handling to improve data flow and display, including status management and detail views
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import CircularLoading from "@/app/component/loading/Circular";
|
||||
import TextLoading from "@/app/component/loading/Text";
|
||||
import CalendarD from "@/components/icons/CalendarD";
|
||||
import CallD from "@/components/icons/CallD";
|
||||
@@ -6,35 +5,24 @@ import ClockClinic from "@/components/icons/ClockClinic";
|
||||
import DownloadD from "@/components/icons/DownloadD";
|
||||
import LocationClinic from "@/components/icons/LocationClinic";
|
||||
import RoutingC from "@/components/icons/RoutingC";
|
||||
import TicketD from "@/components/icons/TicketD";
|
||||
import { Button } from "@mui/material";
|
||||
import Image from "next/image";
|
||||
import React from "react";
|
||||
import { convertTimestampToJalali, convertTimestampToTime } from "@/helper";
|
||||
|
||||
function DetailLg({ user, loading }) {
|
||||
const data = user.turns.done[1];
|
||||
function DetailLg({ appointmentData, loading }) {
|
||||
|
||||
return (
|
||||
<div className="lg:mt-[18px] hidden md:block">
|
||||
<div className="flex md:mt-[24px] lg:mt-0 items-center justify-start gap-[8px] md:gap-[12px] lg:gap-[16px]">
|
||||
<CircularLoading width={95} height={95} loading={loading}>
|
||||
<Image
|
||||
width={95}
|
||||
height={95}
|
||||
alt="profile"
|
||||
src={data.image}
|
||||
className="w-[32px] h-[32px] sm:w-[53px] sm:h-[53px] md:w-[74px] md:h-[74px] lg:w-[95px] lg:h-[95px]"
|
||||
/>
|
||||
</CircularLoading>
|
||||
<div className="flex flex-col items-start justify-center gap-[20px]">
|
||||
<TextLoading loading={loading} width={70} height={18}>
|
||||
<p className="text-[#3B3B3B] text-[14px] sm:text-[16px] md:text-[18px] lg:text-[20px] font-medium">
|
||||
{data.name}
|
||||
{appointmentData?.doctor?.name}
|
||||
</p>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={80} height={18}>
|
||||
<p className="text-[#616161] text-[14px] md:text-[15px] lg:text-[16px] font-medium">
|
||||
تخصص: {data.expertise}
|
||||
تخصص: {appointmentData?.doctor?.specialty?.name}
|
||||
</p>
|
||||
</TextLoading>
|
||||
</div>
|
||||
@@ -47,7 +35,7 @@ function DetailLg({ user, loading }) {
|
||||
<p className="text-[#616161] text-[14px] lg:text-[20px] font-medium">
|
||||
تاریخ نوبت:{" "}
|
||||
<span className="text-[#2F2F2F] text-[14px] lg:text-[20px] font-bold">
|
||||
{data.date_turn}
|
||||
{convertTimestampToJalali(appointmentData?.start_time)}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
@@ -58,7 +46,7 @@ function DetailLg({ user, loading }) {
|
||||
<p className="text-[#616161] text-[14px] lg:text-[20px] font-medium">
|
||||
زمان نوبت:{" "}
|
||||
<span className="text-[#2F2F2F] text-[14px] lg:text-[20px] font-bold">
|
||||
ساعت {data.time}
|
||||
ساعت {appointmentData?.slot?.time}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
@@ -71,13 +59,17 @@ function DetailLg({ user, loading }) {
|
||||
<p className="text-[#616161] text-[14px] lg:text-[16px] font-normal">
|
||||
آدرس:{" "}
|
||||
<span className="text-[#2F2F2F] text-[14px] lg:text-[16px] font-normal">
|
||||
{data.location}
|
||||
{appointmentData?.address?.address}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={120} height={30}>
|
||||
<Button className="!py-[8px] !px-[12px] !gap-[8px]" variant="text">
|
||||
<Button
|
||||
className="!py-[8px] !px-[12px] !gap-[8px]"
|
||||
variant="text"
|
||||
onClick={() => appointmentData?.address?.map && window.open(appointmentData.address.map, '_blank')}
|
||||
>
|
||||
<RoutingC />
|
||||
<p className="text-[#5559CE] text-[14px] font-medium">
|
||||
مسیریابی آدرس
|
||||
@@ -91,23 +83,12 @@ function DetailLg({ user, loading }) {
|
||||
<p className="text-[#616161] text-[14px] lg:text-[16px] font-normal">
|
||||
تلفن:{" "}
|
||||
<span className="text-[#2F2F2F] text-[14px] lg:text-[16px] font-normal">
|
||||
{data.phone}
|
||||
{appointmentData?.address?.phone}
|
||||
</span>
|
||||
</p>
|
||||
</li>
|
||||
</TextLoading>
|
||||
</ul>
|
||||
<div className="flex items-center gap-[4px] w-fit">
|
||||
<TextLoading loading={loading} width={150} height={18}>
|
||||
<TicketD />
|
||||
<p className="text-[#616161] text-[14px] lg:text-[20px] font-medium">
|
||||
مبلغ پرداخت شده :{" "}
|
||||
<span className="text-[#2F2F2F] text-[14px] lg:text-[20px] font-bold">
|
||||
{data.amount_paid} تومان
|
||||
</span>
|
||||
</p>
|
||||
</TextLoading>
|
||||
</div>
|
||||
<Button
|
||||
className="!px-[12px] !hidden md:!flex !mt-[24px] !py-[8px] !border !border-solid !border-[#D7D7D7] !rounded-[4px] !w-fit !items-center !justify-center !gap-[4px]"
|
||||
variant="outlined"
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
import RoutingC from "@/components/icons/RoutingC";
|
||||
import TicketD from "@/components/icons/TicketD";
|
||||
import { Button } from "@mui/material";
|
||||
import Image from "next/image";
|
||||
import React from "react";
|
||||
import ButtonData from "./ButtonData";
|
||||
import CircularLoading from "@/app/component/loading/Circular";
|
||||
import TextLoading from "@/app/component/loading/Text";
|
||||
import { convertTimestampToJalali } from "@/helper";
|
||||
|
||||
function DetailSm({ user, loading }) {
|
||||
const data = user.turns.done[1];
|
||||
function DetailSm({ appointmentData, loading }) {
|
||||
|
||||
return (
|
||||
<div className="mt-[20px] block md:hidden">
|
||||
<div className="flex items-center justify-start gap-[8px]">
|
||||
<CircularLoading width={32} height={32} loading={loading}>
|
||||
<Image src={data.image} alt="profile" height={32} width={32} />
|
||||
</CircularLoading>
|
||||
<div className="flex flex-col justify-center items-start gap-[8px]">
|
||||
<TextLoading loading={loading} width={60} height={14}>
|
||||
<p className="text-[#616161] text-[14px] font-medium">
|
||||
{data.name}
|
||||
{appointmentData?.doctor?.name}
|
||||
</p>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={70} height={14}>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">
|
||||
{data.expertise}
|
||||
{appointmentData?.doctor?.specialty?.name}
|
||||
</p>
|
||||
</TextLoading>
|
||||
</div>
|
||||
@@ -38,7 +32,7 @@ function DetailSm({ user, loading }) {
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={55} height={16}>
|
||||
<p className="text-[#525252] text-[16px] font-medium">
|
||||
{data.date}
|
||||
{convertTimestampToJalali(appointmentData?.start_time)}
|
||||
</p>
|
||||
</TextLoading>
|
||||
</li>
|
||||
@@ -49,7 +43,7 @@ function DetailSm({ user, loading }) {
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={60} height={16}>
|
||||
<p className="text-[#525252] text-[16px] font-medium">
|
||||
{data.time}
|
||||
{appointmentData?.slot?.time}
|
||||
</p>
|
||||
</TextLoading>
|
||||
</li>
|
||||
@@ -57,13 +51,14 @@ function DetailSm({ user, loading }) {
|
||||
<li className="flex flex-wrap gap-x-[12px] gap-y-[12px] items-center w-full justify-between">
|
||||
<TextLoading loading={loading} width={200} height={16}>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">
|
||||
آدرس:<span className="text-[#616161]">{data.location}</span>
|
||||
آدرس:<span className="text-[#616161]">{appointmentData?.address?.address}</span>
|
||||
</p>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={130} height={40}>
|
||||
<Button
|
||||
className="!py-[8px] !border-[#EFEFEF] !px-[12px] !gap-[8px]"
|
||||
variant="outlined"
|
||||
onClick={() => appointmentData?.address?.map && window.open(appointmentData.address.map, '_blank')}
|
||||
>
|
||||
<RoutingC />
|
||||
<p className="text-[#5559CE] text-[14px] font-medium">
|
||||
@@ -74,28 +69,9 @@ function DetailSm({ user, loading }) {
|
||||
</li>
|
||||
<TextLoading loading={loading} width={100} height={18}>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal mt-[12px]">
|
||||
تلفن: <span className="text-[#616161]">{data.phone}</span>
|
||||
تلفن: <span className="text-[#616161]">{appointmentData?.address?.phone}</span>
|
||||
</p>
|
||||
</TextLoading>
|
||||
<span className="block w-full h-px bg-[#EFEFEF] mt-[12px] mb-[16px]"></span>
|
||||
<li className="flex items-center justify-between w-full">
|
||||
<TextLoading loading={loading} width={120} height={18}>
|
||||
<div className="flex items-center gap-[4px] w-fit">
|
||||
<TicketD />
|
||||
<p className="text-[#616161] text-[14px] lg:text-[20px] font-medium">
|
||||
مبلغ پرداخت شده :{" "}
|
||||
<span className="text-[#2F2F2F] text-[14px] lg:text-[20px] font-bold">
|
||||
{data.amount_paid} تومان
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={60} height={18}>
|
||||
<p className="text-[#616161] text-[14px] font-bold">
|
||||
{data.amount_paid} تومان
|
||||
</p>
|
||||
</TextLoading>
|
||||
</li>
|
||||
</ul>
|
||||
<ButtonData loading={loading} />
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ function Head({ setIsTurnsDetails }) {
|
||||
<div className="hidden md:flex flex-wrap gap-x-[24px] gap-y-[12px] items-center justify-between">
|
||||
<div className="flex items-center justify-start gap-[12px] sm:gap-[16px] md:gap-[20px] lg:gap-[24px]">
|
||||
<Button
|
||||
onClick={() => setIsTurnsDetails(false)}
|
||||
onClick={() => setIsTurnsDetails(null)}
|
||||
className="!p-[6px] !border !border-solid !border-[#EFEFEF] !rounded-[4px] !min-w-0"
|
||||
>
|
||||
<ArrowRightS />
|
||||
|
||||
@@ -2,12 +2,12 @@ import DetailLg from "./DetailLg";
|
||||
import DetailSm from "./DetailSm";
|
||||
import Head from "./Head";
|
||||
|
||||
function IsTurnsDetails({ user, setIsTurnsDetails }) {
|
||||
function IsTurnsDetails({ appointmentData, setIsTurnsDetails }) {
|
||||
return (
|
||||
<div className="md:py-[20px] md:px-[24px] opacity-page">
|
||||
<Head setIsTurnsDetails={setIsTurnsDetails} />
|
||||
<DetailLg user={user} loading={false} />
|
||||
<DetailSm user={user} loading={false} />
|
||||
<DetailLg appointmentData={appointmentData} loading={false} />
|
||||
<DetailSm appointmentData={appointmentData} loading={false} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user