generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from moevm/PatientPage
Added patient page
- Loading branch information
Showing
8 changed files
with
177 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
export const timeRepresentationOptions = {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import Header from "../../Widgets/Header/Header.tsx"; | ||
import ProfileButton from "../../Components/ProfileButton/ProfileButton.tsx"; | ||
import SignOutButton from "../../Components/SignOutButton/SignOutButton.tsx"; | ||
import FormInput from "../../Components/FormInput/FormInput.tsx"; | ||
import {useState} from "react"; | ||
import FilterCard from "../../Widgets/FilterCard/FilterCard.tsx"; | ||
import RecordsStand from "../../Widgets/RecordsStand/RecordsStand.tsx"; | ||
import {timeRepresentationOptions} from "../../Config/timeRepresentationConfig.ts"; | ||
|
||
|
||
const person = { | ||
name: "Patient1", | ||
appointments: [ | ||
{ | ||
id: 1, | ||
date: "22.12.2023, 15:54", | ||
doctor: "Doctor Doolittle", | ||
procedure: "Procedure 1" | ||
}, | ||
{ | ||
id: 2, | ||
date: "20.12.2012, 11:00", | ||
doctor: "Doctor Aybolit", | ||
procedure: "Procedure 2" | ||
}, | ||
{ | ||
id: 3, | ||
date: "20.12.2022, 06:00", | ||
doctor: "Doctor A", | ||
procedure: "Procedure 2" | ||
} | ||
] | ||
} | ||
|
||
function PatientPage() { | ||
const gridCol3 = "w-full grid grid-cols-3 justify-items-center" | ||
|
||
const [records, setRecords] = useState(person.appointments) | ||
|
||
const onChange = (event: any) => { | ||
const target = event.target | ||
const comparators = { | ||
'date': (x) => x.date.includes(new Date(target.value).toLocaleString('ru-RU', timeRepresentationOptions)), | ||
'procedure': (x) => x.procedure.includes(target.value), | ||
'doctor': (x) => x.doctor.includes(target.value) | ||
} | ||
setRecords(records.filter(comparators[target.name])) | ||
} | ||
|
||
const dropFilter = () => { | ||
setRecords(person.appointments) | ||
} | ||
|
||
return ( | ||
<> | ||
<Header profileButton={<ProfileButton/>} signOutButton={<SignOutButton/>} /> | ||
<div className="px-14 font-bold min-w-fit"> | ||
<h3 className="text-2xl my-7">Hello, <span className="text-base1">{person.name}</span>!</h3> | ||
<FilterCard theme="primary" onChange={onChange} dropFilter={dropFilter}> | ||
<div> | ||
<label htmlFor="" className="block ml-3">Date</label> | ||
<FormInput name={"date"} type="datetime-local"/> | ||
</div> | ||
<div> | ||
<label htmlFor="" className="block ml-3">Procedure</label> | ||
<FormInput name={"procedure"} placeholder="Name"/> | ||
</div> | ||
<div> | ||
<label htmlFor="" className="block ml-3">Doctor</label> | ||
<FormInput name={"doctor"} placeholder="Name"/> | ||
</div> | ||
</FilterCard> | ||
<RecordsStand name={"Upcoming Appointments"} theme={"primary"}> | ||
<div className={`${gridCol3} text-2xl my-4`}> | ||
<h4 >Date</h4> | ||
<h4>Procedure</h4> | ||
<h4>Doctor</h4> | ||
</div> | ||
<ul className="w-full"> | ||
{records.map((currentValue, idx) => | ||
<div key={idx} className={`${gridCol3} text-lg font-medium mb-7`}> | ||
<li>{currentValue.date}</li> | ||
<li>{currentValue.procedure}</li> | ||
<li>{currentValue.doctor}</li> | ||
</div>)} | ||
</ul> | ||
</RecordsStand> | ||
</div> | ||
|
||
</> | ||
) | ||
} | ||
|
||
export default PatientPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ReactElement, FormEventHandler, MouseEventHandler } from "react"; | ||
|
||
interface FilterCardProps { | ||
onChange: FormEventHandler<HTMLDivElement> | undefined, | ||
dropFilter: MouseEventHandler<HTMLButtonElement> | undefined, | ||
children: Array<ReactElement>, | ||
theme: "primary" | "secondary", | ||
} | ||
|
||
function FilterCard({onChange, children, dropFilter, theme}: FilterCardProps) { | ||
const bgStyle = { | ||
"primary": "bg-base2", | ||
"secondary": "bg-base3" | ||
} | ||
return ( | ||
<> | ||
<div className={`${bgStyle[theme]} rounded-3xl py-4 px-10 my-4`}> | ||
<h2 className="text-2xl">Filter by</h2> | ||
<div className="flex justify-between mt-6 mb-3 text-xl" onChange={onChange}> | ||
{children} | ||
</div> | ||
<button onClick={dropFilter} | ||
className="bg-black bg-opacity-30 p-3 rounded-3xl | ||
text-darkPurple text-opacity-80 mt-3"> | ||
Drop filter | ||
</button> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
|
||
export default FilterCard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {ReactElement} from "react"; | ||
|
||
interface RecordsStandProps { | ||
name: string, | ||
theme: "primary" | "secondary", | ||
children: Array<ReactElement> | ||
} | ||
|
||
function RecordsStand({name, theme, children}: RecordsStandProps) { | ||
|
||
const bgStyle = { | ||
"primary": "bg-base2", | ||
"secondary": "bg-base3" | ||
} | ||
|
||
return ( | ||
<> | ||
<div className={`${bgStyle[theme]} rounded-3xl flex flex-col items-center pt-4`}> | ||
<h2 className="text-2xl mb-4">{name}</h2> | ||
<hr className="w-11/12 opacity-50"/> | ||
{children} | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default RecordsStand |