Skip to content
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

Add dropdown to recruitment header #1629

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions frontend/src/Components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import type { RecruitmentDto } from '~/dto';
import { useDesktop, useScrollY } from '~/hooks';
import { STATUS } from '~/http_status_codes';
import { KEY } from '~/i18n/constants';
import { reverse } from '~/named-urls';
import { ROUTES } from '~/routes';
import { dbT } from '~/utils';
import styles from './Navbar.module.scss';
import { HamburgerMenu, LanguageButton, NavbarItem } from './components';

Expand Down Expand Up @@ -106,6 +108,23 @@ export function Navbar() {
</a>
</>
);
const recruitmentLinks = (
<>
{activeRecruitments?.map((recruitment) => (
<Link
key={recruitment.id}
url={reverse({
pattern: ROUTES.frontend.organization_recruitment,
urlParams: { recruitmentId: recruitment?.id },
})}
className={styles.navbar_dropdown_link}
onAfterClick={() => setExpandedDropdown('')}
>
{dbT(recruitment, 'name')} {recruitment.organization.toString()}
</Link>
))}
</>
);

const navbarHeaders = (
<div className={isDesktop ? styles.navbar_main_links : styles.navbar_main_links_mobile}>
Expand Down Expand Up @@ -134,6 +153,8 @@ export function Navbar() {
route={ROUTES.frontend.recruitment}
label={t(KEY.common_volunteer)}
labelClassName={activeRecruitments && styles.active_recruitment}
dropdownLinks={recruitmentLinks}
showDropDownIcon={false}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type NavbarItemProps = {
labelClassName?: string;
dropdownLinks?: Children;
expandedDropdown?: string;
showDropDownIcon?: boolean;
setExpandedDropdown: SetState<string>;
};

Expand All @@ -26,6 +27,7 @@ export function NavbarItem({
setExpandedDropdown,
dropdownLinks,
labelClassName,
showDropDownIcon = true,
}: NavbarItemProps) {
const { setIsMobileNavigation } = useGlobalContext();
const isDesktop = useDesktop();
Expand Down Expand Up @@ -67,7 +69,7 @@ export function NavbarItem({
<Link to={route} className={isDesktop ? styles.navbar_link : styles.popup_link_mobile} onClick={handleClick}>
{icon && <Icon icon={icon} className={styles.navbar_item_icon} />}
<span className={labelClassName}>{label}</span>
{dropdownLinks && (
{dropdownLinks && showDropDownIcon && (
<Icon
icon={iconDown}
width={18}
Expand Down
Loading