Files
nobat724_front/components/appointment/detail/index.js
T
hamedandClaude Opus 5 51c21938eb feat(booking): give the booking flow a dark palette derived from its own colours
components/appointment/ had every colour hard-coded, so the flow rendered
identically in either theme even after the wiring was fixed. It now reads from
CSS custom properties.

These are not new colours. The :root values are byte-for-byte the hex codes
that were already in the components — twenty-one files, mapped one to one — so
light mode is unchanged. The dark values are derived from those same colours:
surfaces and borders darkened, text inverted, and the two brand colours (the
indigo and the orange) lightened rather than replaced, because both lose
contrast against a dark surface at their original values.

Verified in a headless browser with prefers-color-scheme forced dark:
data-theme lands on <html> and --ap-surface resolves to #1b1b20 rather than
white. Six one-off colours remain hard-coded — a success green, an error red
and similar — each used exactly once and none of them a surface.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:33:39 +03:30

134 lines
3.9 KiB
JavaScript

import { useEffect, useState } from "react";
import { Button } from "@mui/material";
import AddCircleBlueA from "@/components/icons/AddCircleBlueA";
import ArrowRightS from "@/components/icons/ArrowRightS";
import Form from "./Form";
import { request } from "@/services/response";
import SubmitData from "./SubmitData";
function Detail({
isForAnother,
setStep,
setIsForAnother,
data,
setData,
prevData,
fadeElement,
setIsPay,
doctor,
selectedSlot,
selectedDate,
setAppointmentId,
setAppointmentExpiresAt,
selectedServiceUuids = [],
clinicUuid = null,
}) {
const [insurance, setInsurance] = useState();
const [supplementaryInsurance, setSupplementaryInsurance] = useState();
const [errors, setErrors] = useState({});
const [selfData, setSelfData] = useState(null);
const changeData = (value, type, name) =>
setData({
...data,
[name]: {
...data[name],
[type]: value,
},
});
const emptyPatientData = () => ({
phone: { value: "", isEdit: true },
national_code: { value: "", isEdit: true },
name: { value: "", isEdit: true },
family: { value: "", isEdit: true },
gender: { value: "", isEdit: true },
patient_reason: { value: "", isEdit: true },
});
const switchToAnother = () => {
setSelfData(data);
setIsForAnother(true);
setErrors({});
setData(emptyPatientData());
};
const switchToSelf = () => {
setIsForAnother(false);
setErrors({});
if (selfData) setData(selfData);
};
useEffect(() => {
// دریافت لیست بیمه پایه
request.getInsuranceType().then((res) => {
const items = res?.data?.data;
if (Array.isArray(items)) {
setInsurance(items);
}
});
// دریافت لیست بیمه تکمیلی
request.getSupplementaryInsurance().then((res) => {
const items = res?.data?.data;
if (Array.isArray(items)) {
setSupplementaryInsurance(items);
}
});
}, []);
return (
// ${typePay === 'success' || typePay === 'failed' ? 'bg-transparent border-transparent md:bg-[var(--ap-surface)] md:border-[var(--ap-border)]' : ''}
<div className="w-full lg:w-[59%]">
<div
className={`opacity-page bg-[var(--ap-surface)] border border-solid border-[var(--ap-border)] rounded-[8px] p-[12px] sm:p-[16px] md:p-[20px] lg:p-[24px] `}
>
{/* دکمه برگشت */}
<div
className="cursor-pointer mb-[16px]"
onClick={() => setStep(0)}
>
<ArrowRightS />
</div>
<p className="text-[var(--ap-text)] text-[20px] font-bold">
{isForAnother ? "اطلاعات کاربر جدید" : "اطلاعات حساب کاربری"}
</p>
<Form
data={data}
insurance={insurance}
supplementaryInsurance={supplementaryInsurance}
changeData={changeData}
isForAnother={isForAnother}
errors={errors}
/>
<Button
className="!flex !items-center !justify-start !gap-[8px] !mt-[12px] sm:!mt-[16px] md:!mt-[20px] lg:!mt-[24px] !p-1"
onClick={() => (isForAnother ? switchToSelf() : switchToAnother())}
>
<AddCircleBlueA />
<p className="text-[var(--ap-primary)] text-[16px] font-medium">
{isForAnother ? "نوبت برای خودم است" : "نوبت برای شخص دیگری است"}
</p>
</Button>
<SubmitData
setStep={setStep}
data={data}
prevData={prevData}
setErrors={setErrors}
doctor={doctor}
isForAnother={isForAnother}
selectedSlot={selectedSlot}
selectedDate={selectedDate}
setAppointmentId={setAppointmentId}
setAppointmentExpiresAt={setAppointmentExpiresAt}
selectedServiceUuids={selectedServiceUuids}
clinicUuid={clinicUuid}
/>
</div>
</div>
);
}
export default Detail;