Get Data from one component to another

There is a Component called PatientDetailsPopup. It have user agreement details, Patient details and order summary. It called in another page and have a checkout button. When clicked that button popup and show agreement patient details and order summary one by one. Here is the patient popup code.

export const PatientDetailsPopup = ({
                                        onSubmit,
                                        patientDetails,
                                        setPatientDetails,
                                        isAgreementAccepted,
                                        setIsAgreementAccepted,
                                        patientAgreement
                                    }) => {
    const [agreeStatus, setAgreeStatus] = useState(false);
    return (

        <Popup
            trigger={(isOpen) => {
                return (<Button
                    className="mt-7 self-end align-middle select-none font-sansavantri0.xyz
                        font-bold text-center uppercase transition-all disabled:opacity-50
                        disabled:shadow-none disabled:pointer-events-none text-xs py-3 px-6
                        rounded-lg bg-gray-900 text-white shadow-md shadow-gray-900/10
                        hover:shadow-lg hover:shadow-gray-900/20 focus:opacity-[0.85]
                        focus:shadow-none active:opacity-[0.85] active:shadow-none">Checkout</Button>)
            }}
            modal
            nested
            lockScroll={false}
            overlayStyle={{background: 'rgba(25,31,29,0.31)', zIndex: 10}}
            contentStyle={{height: '70%', width: '80%'}}
            onClose={() => {
                setIsAgreementAccepted(false);
                setAgreeStatus(false);
            }}


        >
            {close => (
                <Card
                    className="bg-white  mt-6 drop-shadow-xl shadow-md rounded-lg p-4  gap-4  flex flex-col  w-6/12 h-full ms-auto   me-auto ps-auto     pe-auto    ">
                    < CloseOutlinedIcon onClick={() => {
                        console.log('closing')
                        close()
                    }} className="self-end hover:cursor-pointer"/>
                    {isAgreementAccepted ? <div className="flex gap-4 flex-col justify-between h-full">
                            <div>
                                <h2 className="text-l text-center font-bold leading-7 text-gray-900 lg:truncate lg:text-xl lg:tracking-tight">
                                    Patient details

                                </h2>
                                <div className="flex gap-4 mt-6  flex-col lg:flex-row">
                                    <TextField label="First name" variant="outlined" value={patientDetails.firstName}
                                               onChange={({target: {value}}) => {
                                                   setPatientDetails({
                                                       ...patientDetails,
                                                       firstName: value
                                                   })
                                               }} className="flex-initial w-full"/>
                                    <TextField label="Last name" variant="outlined" value={patientDetails.lastName}
                                               onChange={({target: {value}}) => {
                                                   setPatientDetails({
                                                       ...patientDetails,
                                                       lastName: value
                                                   })
                                               }}
                                               className="flex-initial w-full"/>

                                </div>
                                <div className="flex gap-4 mt-6 h-12 flex-col lg:flex-row">
                                    <TextField type='email' label="Email" variant="outlined" value={patientDetails.email}
                                               onChange={({target: {value}}) => {
                                                   setPatientDetails({
                                                       ...patientDetails,
                                                       email: value
                                                   })
                                               }} className="flex-initial w-full"/>
                                    <TextField type='number' label="Mobile number" variant="outlined"
                                               value={patientDetails.cell} onChange={({target: {value}}) => {
                                        setPatientDetails({
                                            ...patientDetails,
                                            cell: value
                                        })
                                    }} className="flex-initial w-full"/>
                                </div>
                                <div className="flex gap-4 mt-6 h-12 flex-col lg:flex-row">
                                    <div className="flex-initial w-full">

                                        <Select
                                            value={patientDetails.gender}
                                            label="Gender"
                                            onChange={({target: {value}}) => {
                                                setPatientDetails({
                                                    ...patientDetails,
                                                    gender: value
                                                })
                                            }}
                                            className="flex-initial w-full"
                                        >
                                            <MenuItem value={'M'}>Male</MenuItem>
                                            <MenuItem value={'F'}>Female</MenuItem>
                                        </Select>
                                    </div>
                                    <DatePicker label="Birthday" className="flex-initial w-full" onChange={({_d}) => {
                                        setPatientDetails({
                                            ...patientDetails,
                                            dob: moment(_d).format('MM/DD/yyyy')
                                        });
                                    }}/>
                                </div>
                                <div className="flex gap-4 mt-6 h-12 flex-col lg:flex-row">
                                    <TextField label="Address" variant="outlined" value={patientDetails.address1}
                                               onChange={({target: {value}}) => {
                                                   setPatientDetails({
                                                       ...patientDetails,
                                                       address1: value
                                                   })
                                               }} className="flex-initial w-full"/>
                                    <TextField label="Zip Code" variant="outlined" value={patientDetails.postalCode}
                                               onChange={({target: {value}}) => {
                                                   setPatientDetails({
                                                       ...patientDetails,
                                                       postalCode: value
                                                   })
                                               }} className="flex-initial w-full"/>

                                </div>
                                <div className="flex gap-4 mt-6 h-12 flex-col lg:flex-row">
                                    <TextField label="City" variant="outlined" value={patientDetails.city}
                                               onChange={({target: {value}}) => {
                                                   setPatientDetails({
                                                       ...patientDetails,
                                                       city: value
                                                   })
                                               }} className="flex-initial w-full"/>
                                    <TextField label="State" variant="outlined" value={patientDetails.state}
                                               onChange={({target: {value}}) => {
                                                   setPatientDetails({
                                                       ...patientDetails,
                                                       state: value
                                                   })
                                               }} className="flex-initial w-full"/>
                                </div>
                            </div>
                            <Button
                                className="mt-7 self-end align-middle select-none font-sans
                                font-bold text-center uppercase transition-all disabled:opacity-50
                                disabled:shadow-none disabled:pointer-events-none text-xs py-3 px-6
                                rounded-lg bg-gray-900 text-white shadow-md shadow-gray-900/10
                        hover:shadow-lg hover:shadow-gray-900/20 focus:opacity-[0.85]
                        focus:shadow-none active:opacity-[0.85] active:shadow-none" onClick={onSubmit}>Continue</Button>
                        </div> :
                        patientAgreement &&
                        <div className="flex gap-4 mt-4 flex-col overflow-scroll">
                            <div className="overflow-auto h-full">{parse(patientAgreement.html)}</div>
                            <div className="flex items-center">
                                <Checkbox onChange={({target: {checked}}) => {
                                    setAgreeStatus(checked)
                                }}/>
                                <Typography
                                    className="font-semibold text-lg">I
                                    read and agreed the terms and conditions</Typography></div>
                            <Button
                                className="mt-7 self-end" disabled={!agreeStatus}
                                onClick={() => {
                                    setIsAgreementAccepted(agreeStatus)
                                }}>Continue</Button>
                        </div>}

                </Card>

            )}

        </Popup>
    )
};


I want to get that user details for one page patient details for one page and order summary for one page. I dont want to use the button. Here is the code that patientdetailspopup page calling in another page.

const [getAgreement, { data: patientAgreement }] =
    useLazyGetPatientAgreementQuery();
  const [isAgreementAccepted, setIsAgreementAccepted] = useState(false);
  const [patientDetails, setPatientDetails] = useState({
    externalID: "1",
    firstName: "",
    lastName: "",
    gender: "M",
    dob: "",
    address1: "",
    city: "",
    state: "",
    email: "",
    cell: "",
    postalCode: "",
  });

useEffect(() => {
    localStorage.setItem("token", tokenData?.access_token);
    if (tokenData?.access_token && valuesArray) {
      getTestDetails(valuesArray);
      getAgreement();
    }
  }, [tokenData]);
useEffect(() => {
    console.log("orderData", orderData);
    if (orderData?.formToken) {
      if (paymentGatewayForm.current) {
        paymentGatewayForm.current.submit();
      }
    }
  }, [orderData]);

  const onCreateOrder = () => {
    if (selectedIndex === -1) {
      alert.show("Please select patient service center");
      return;
    }

    const testItemsToBeSend = valuesArray.map((testId) => {
      return { id: testId };
    });
return (
    <>
      <CheckoutTitle />
      <div className="flex gap-1 flex-col-reverse lg:flex-row">
        <Card className="w-full mt-6 rounded-lg p-4  gap-4  flex flex-col h-screen patient-service">
          <CheckoutTitleBar/>
          <h2 className="text-xl font-bold leading-7 text-gray-900     lg:text-2xl lg:tracking-tight">
            Terms Of Service
          </h2>
          <p>Updated 3 days ago, Effective 4 weeks from now</p>
          <div className="flex gap-4 mt-4 h-12 flex-col lg:flex-row">

          {/* button for agreement, user details */}
          <PatientDetailsPopup onSubmit={onCreateOrder} patientDetails={patientDetails}
                                             setPatientDetails={setPatientDetails} patientAgreement={patientAgreement}
                                             isAgreementAccepted={isAgreementAccepted}
                                             setIsAgreementAccepted={setIsAgreementAccepted}/>
</div>
          
</>
)

New contributor

lasith amanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật