sendou.ink/app/components/layout/AnythingAdder.tsx
Kalle b4cc185d1d
Some checks are pending
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
Scrims (#2211)
* Initial

* Progress

* Initial UI

* Can submit request

* Progress

* Show text if no scrims

* Can cancel request, tabs

* Delete post

* Popover if can't delete

* Request rows

* Progress

* Scrim page initial

* Fix migration order

* Progress

* Progress

* Works again

* Make it compile

* Make it compile again

* Work

* Progress

* Progress

* Progress

* Associations initial

* Association visibility work

* notFoundVisibility form fields initial

* Progress

* Association leave/join + reset invite code

* Progress

* Select test

* Merge branch 'rewrite' into scrims

* Remeda for groupBy

* Select with search

* Outline styling for select

* Select done?

* Fix prop names

* Paginated badges

* Less important

* Select no results

* Handle limiting select width

* UserSearch non-working

* Fix problem from merge

* Remove UserSearch for now

* Remove todo

* Flaggable

* Remove TODOs

* i18n start + styling

* Progress

* i18n done

* Add association e2e test

* E2E tests

* Done?

* Couple leftovers
2025-04-20 22:51:23 +03:00

116 lines
2.7 KiB
TypeScript

import { useNavigate } from "@remix-run/react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { useUser } from "~/features/auth/core/user";
import { FF_SCRIMS_ENABLED } from "~/features/scrims/scrims-constants";
import {
CALENDAR_NEW_PAGE,
NEW_TEAM_PAGE,
TOURNAMENT_NEW_PAGE,
lfgNewPostPage,
navIconUrl,
newArtPage,
newAssociationsPage,
newScrimPostPage,
newVodPage,
plusSuggestionsNewPage,
userNewBuildPage,
} from "~/utils/urls";
import { Menu, type MenuProps } from "../Menu";
import { PlusIcon } from "../icons/Plus";
const FilterMenuButton = React.forwardRef<
HTMLButtonElement,
React.ButtonHTMLAttributes<HTMLButtonElement>
>((props, ref) => {
return (
<button
className="layout__header__button"
{...props}
ref={ref}
data-testid="anything-adder-menu-button"
>
<PlusIcon className="layout__header__button__icon" />
</button>
);
});
export function AnythingAdder() {
const { t } = useTranslation(["common"]);
const user = useUser();
const navigate = useNavigate();
if (!user) {
return null;
}
const items: MenuProps["items"] = [
{
id: "tournament",
text: t("header.adder.tournament"),
imagePath: navIconUrl("medal"),
onClick: () => navigate(TOURNAMENT_NEW_PAGE),
},
{
id: "calendarEvent",
text: t("header.adder.calendarEvent"),
imagePath: navIconUrl("calendar"),
onClick: () => navigate(CALENDAR_NEW_PAGE),
},
{
id: "builds",
text: t("header.adder.build"),
imagePath: navIconUrl("builds"),
onClick: () => navigate(userNewBuildPage(user)),
},
{
id: "team",
text: t("header.adder.team"),
imagePath: navIconUrl("t"),
onClick: () => navigate(NEW_TEAM_PAGE),
},
FF_SCRIMS_ENABLED
? {
id: "scrimPost",
text: t("header.adder.scrimPost"),
imagePath: navIconUrl("scrims"),
onClick: () => navigate(newScrimPostPage()),
}
: null,
FF_SCRIMS_ENABLED
? {
id: "association",
text: t("header.adder.association"),
imagePath: navIconUrl("associations"),
onClick: () => navigate(newAssociationsPage()),
}
: null,
{
id: "lfgPost",
text: t("header.adder.lfgPost"),
imagePath: navIconUrl("lfg"),
onClick: () => navigate(lfgNewPostPage()),
},
{
id: "art",
text: t("header.adder.art"),
imagePath: navIconUrl("art"),
onClick: () => navigate(newArtPage()),
},
{
id: "vods",
text: t("header.adder.vod"),
imagePath: navIconUrl("vods"),
onClick: () => navigate(newVodPage()),
},
{
id: "plus",
text: t("header.adder.plusSuggestion"),
imagePath: navIconUrl("plus"),
onClick: () => navigate(plusSuggestionsNewPage()),
},
].filter((item) => item !== null);
return <Menu items={items} button={FilterMenuButton} opensLeft />;
}