-
Notifications
You must be signed in to change notification settings - Fork 1
Lesson 4 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Lesson 4 #5
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
78f1031
feat: Implement doctor listing page with filters and SEO optimization
alireza97d 463ff36
chore: format code with Prettier
alireza97d e94f89f
[REMOVE] items.provider.tsx
alireza97d 25d41df
[REMOVE] removed comments line in filters.provider.tsx
alireza97d c86f501
[UPDATE] Optimize filtering logic using useMemo
alireza97d 80509f9
[INSTALL] Add 'sharp' package for Image Optimization
alireza97d 448d79d
[PEETTIER] formating code
alireza97d 0f01213
[UPDATE] typeFilter --> filterName
alireza97d c3e1141
[UPDATE] sync name component with file name
alireza97d 35bdaed
[UPDATE] change remove to clear
alireza97d 2bfd978
[UPDATE] setting variable for danger color
alireza97d 2d79ec3
[UPDATE] remove unnecessary type
alireza97d d2aa3c7
[UPDATE] condition in list.component.tsx
alireza97d 56c8030
[UPDATE] list.module.css
alireza97d c1d0c6b
[UPDATE] css variable
alireza97d 248db43
[UPDATE] start color
alireza97d 3464434
[ADD] filter wraper component
alireza97d 12c8a4d
[UPDATE] fixed degrees variable name
alireza97d 0907fcd
[UPDATE] Removing duplicate typing
alireza97d aed5747
[prettier] fixed format
alireza97d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
50 changes: 50 additions & 0 deletions
50
src/app/doctors/[[...slug]]/components/filter/filter.component.tsx
This file contains hidden or 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,50 @@ | ||
"use client"; | ||
|
||
import { ReactElement, useContext } from "react"; | ||
|
||
import { FiltersContext } from "../../providers/Filters/filters.provider"; | ||
|
||
import CardComponent from "@/components/card/card.component"; | ||
import FilterButtonComponent from "@/components/filter-button/filter-button.component"; | ||
|
||
import { ResultObject } from "@/utils/convertListToObject"; | ||
import { FilterEnums } from "../../enums/filter.enum"; | ||
|
||
import styles from "./filter.module.css"; | ||
|
||
type Props = { | ||
typeFilter: FilterEnums; | ||
title: string; | ||
options?: { id: string; en: string; fa: string }[]; | ||
selectedFilters: ResultObject; | ||
}; | ||
|
||
const FilterComponent = ({ | ||
typeFilter, | ||
title, | ||
options = [], | ||
selectedFilters = {}, | ||
}: Props): ReactElement => { | ||
const { changeFilter } = useContext(FiltersContext); | ||
|
||
return ( | ||
<CardComponent> | ||
<div className={styles.filter}> | ||
<div className={styles.title}>{title}</div> | ||
<div className={styles.buttons}> | ||
{options.map((option) => ( | ||
<FilterButtonComponent | ||
key={option.id} | ||
isActive={Object.values(selectedFilters).includes(option.en)} | ||
onClick={() => changeFilter(typeFilter, option.en)} | ||
> | ||
{option.fa} | ||
</FilterButtonComponent> | ||
))} | ||
</div> | ||
</div> | ||
</CardComponent> | ||
); | ||
}; | ||
|
||
export default FilterComponent; |
17 changes: 17 additions & 0 deletions
17
src/app/doctors/[[...slug]]/components/filter/filter.module.css
This file contains hidden or 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,17 @@ | ||
.filter { | ||
.title { | ||
font-weight: 900; | ||
} | ||
|
||
.buttons { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 0.5rem; | ||
|
||
margin-block-start: 0.5rem; | ||
|
||
> * { | ||
flex: 1 0 auto; | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/doctors/[[...slug]]/components/filter/remove-filter.component.tsx
This file contains hidden or 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,25 @@ | ||
"use client"; | ||
|
||
import { ReactElement, useContext } from "react"; | ||
|
||
import { FiltersContext } from "../../providers/Filters/filters.provider"; | ||
|
||
import CardComponent from "@/components/card/card.component"; | ||
|
||
import styles from "./remove-filter.module.css"; | ||
|
||
const RemoveAllFilterComponent = (): ReactElement => { | ||
alireza97d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const { clearAll } = useContext(FiltersContext); | ||
|
||
return ( | ||
<CardComponent> | ||
<div> | ||
<button className={styles.remove} onClick={clearAll}> | ||
alireza97d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
حذف همه فیلترها | ||
</button> | ||
</div> | ||
</CardComponent> | ||
); | ||
}; | ||
|
||
export default RemoveAllFilterComponent; |
12 changes: 12 additions & 0 deletions
12
src/app/doctors/[[...slug]]/components/filter/remove-filter.module.css
This file contains hidden or 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,12 @@ | ||
.remove { | ||
width: 100%; | ||
border-radius: var(--border-radius); | ||
|
||
background-color: rgb(188, 67, 67); | ||
alireza97d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
cursor: pointer; | ||
|
||
&:hover { | ||
background-color: rgb(175, 42, 42); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/app/doctors/[[...slug]]/components/item/item.component.tsx
This file contains hidden or 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,67 @@ | ||
import { ReactElement } from "react"; | ||
|
||
import Image from "next/image"; | ||
|
||
import { MingcuteStarFill } from "@/icons/MingcuteStarFill"; | ||
|
||
import { DoctorModel } from "@/types/doctor.type"; | ||
import { GenderEnums } from "@/enums/gender"; | ||
|
||
import maleImg from "@/assets/fallback-images/portrait-3d-male-doctor.jpg"; | ||
import femaleImg from "@/assets/fallback-images/portrait-3d-female-doctor.jpg"; | ||
|
||
import styles from "./item.module.css"; | ||
import { MingcuteLocationFill } from "@/icons/MingcuteLocationFill"; | ||
import { MingcuteArrowLeftLine } from "@/icons/MingcuteArrowLeftLine"; | ||
|
||
type Props = { | ||
item: DoctorModel; | ||
}; | ||
|
||
const ItemComponent = ({ item }: Props): ReactElement => { | ||
return ( | ||
<li className={styles.item}> | ||
<div className={styles.info}> | ||
<Image | ||
src={ | ||
item?.image || | ||
(item.gender.en === GenderEnums.MALE ? maleImg : femaleImg) | ||
} | ||
width={80} | ||
height={80} | ||
alt={item.name} | ||
className={styles.image} | ||
/> | ||
<div className=""> | ||
<h2 className={styles.name}>{item.name}</h2> | ||
<p className={styles.brief}>{item.brief}</p> | ||
<span className={styles.rate}> | ||
<MingcuteStarFill color="#FFF200" /> | ||
alireza97d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<span>{item.averageRating}</span> | ||
({item.totalVotes} نظر) | ||
</span> | ||
</div> | ||
</div> | ||
<div className={styles.badge}> | ||
{item.badges.map((item: string, index: number) => ( | ||
alireza97d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<span className={styles.badge_item} key={index}> | ||
{item} | ||
</span> | ||
))} | ||
</div> | ||
<div className={styles.address}> | ||
<address> | ||
<MingcuteLocationFill /> | ||
{item.address} | ||
</address> | ||
</div> | ||
|
||
<button> | ||
<span>دریافت نوبت</span> | ||
<MingcuteArrowLeftLine /> | ||
</button> | ||
</li> | ||
); | ||
}; | ||
|
||
export default ItemComponent; |
111 changes: 111 additions & 0 deletions
111
src/app/doctors/[[...slug]]/components/item/item.module.css
This file contains hidden or 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,111 @@ | ||
.item { | ||
position: relative; | ||
|
||
padding: 1rem; | ||
height: auto; | ||
|
||
background-color: var(--color-gray-20); | ||
|
||
border-radius: 0.5rem; | ||
|
||
.info { | ||
display: flex; | ||
justify-content: start; | ||
align-items: start; | ||
gap: 0.8rem; | ||
} | ||
|
||
.image { | ||
border-radius: 0.7rem; | ||
border: 0.24rem solid var(--color-gray-98); | ||
} | ||
|
||
.name { | ||
font-size: var(--fz-400); | ||
} | ||
|
||
.brief { | ||
margin-top: 0.2rem; | ||
font-size: var(--fz-200); | ||
} | ||
|
||
.rate { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.15rem; | ||
|
||
background-color: var(--color-gray-30); | ||
|
||
width: fit-content; | ||
|
||
padding-block: 0.1rem; | ||
padding-inline: 0.2rem; | ||
margin-top: 0.4rem; | ||
border-radius: 0.2rem; | ||
|
||
font-size: var(--fz-100); | ||
} | ||
|
||
.badge { | ||
display: flex; | ||
justify-content: start; | ||
gap: 0.4rem; | ||
|
||
margin-block-start: 2rem; | ||
|
||
.badge_item { | ||
background-color: var(--color-gray-40); | ||
width: fit-content; | ||
|
||
font-size: var(--fz-100); | ||
|
||
padding-block: 0.1rem; | ||
padding-inline: 0.2rem; | ||
border-radius: 0.2rem; | ||
} | ||
} | ||
|
||
.address { | ||
margin-block-start: 1.5rem; | ||
|
||
address { | ||
font-style: normal; | ||
font-size: var(--fz-200); | ||
|
||
display: flex; | ||
align-items: start; | ||
gap: 0.3rem; | ||
|
||
svg { | ||
flex-shrink: 0; | ||
margin-top: 0.25rem; | ||
} | ||
} | ||
} | ||
|
||
button { | ||
position: absolute; | ||
top: 1rem; | ||
left: 1rem; | ||
|
||
display: flex; | ||
align-items: center; | ||
gap: 0.15rem; | ||
|
||
background-color: var(--color-primary); | ||
|
||
border: none; | ||
border-radius: 0.2rem; | ||
|
||
padding: 0.3rem; | ||
cursor: pointer; | ||
|
||
transition: 0.2s ease-in-out; | ||
transition-property: background-color, color; | ||
|
||
&:hover { | ||
background-color: var(--color-primary-fade); | ||
color: var(--color-primary-opposite); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/app/doctors/[[...slug]]/components/list/list.component.tsx
This file contains hidden or 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,32 @@ | ||
import { ReactElement } from "react"; | ||
|
||
import ItemComponent from "../item/item.component"; | ||
|
||
import { DoctorModel } from "@/types/doctor.type"; | ||
|
||
import styles from "./list.module.css"; | ||
import Link from "next/link"; | ||
|
||
const ListComponent = ({ | ||
doctors, | ||
}: { | ||
doctors: DoctorModel[]; | ||
}): ReactElement => { | ||
return ( | ||
<> | ||
{doctors.length !== 0 ? ( | ||
alireza97d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<ul className={styles.container}> | ||
{doctors.map((item: DoctorModel) => ( | ||
<Link key={item.id} href={{ pathname: `/doctor/${item.id}` }}> | ||
<ItemComponent item={item} /> | ||
</Link> | ||
))} | ||
</ul> | ||
) : ( | ||
<p>متاسفیم. درحال حاظر پزشکی وجود ندارد!</p> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ListComponent; |
This file contains hidden or 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 @@ | ||
.container > a:not(:last-child) { | ||
margin-bottom: 1rem; | ||
display: block; | ||
} | ||
alireza97d marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,7 @@ | ||
export enum FilterEnums { | ||
GENDER = "gender", | ||
SPECIALTY = "specialty", | ||
CITY = "city", | ||
DEGREE = "degree", | ||
NEXT_APPOINTMENT = "nextAppointments", | ||
} |
This file contains hidden or 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,19 @@ | ||
.page { | ||
display: grid; | ||
grid-template-columns: 1.5fr 4fr; | ||
align-items: start; | ||
gap: 1rem; | ||
|
||
margin-block-end: 2rem; | ||
|
||
.filters { | ||
display: grid; | ||
gap: 1rem; | ||
} | ||
} | ||
|
||
.search { | ||
display: flex; | ||
justify-content: center; | ||
margin-block-end: 3rem; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.