Skip to content

Commit

Permalink
Merge pull request activist-org#940 from t3azr/combine-index-menu-defs
Browse files Browse the repository at this point in the history
Combine index menu defs
  • Loading branch information
andrewtavis authored Sep 2, 2024
2 parents ce20869 + 1925814 commit f4608bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 117 deletions.
3 changes: 2 additions & 1 deletion frontend/composables/useMenuEntriesState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { IconMap } from "~/types/icon-map";
const createMenuEntry = (label: string, basePath: string, iconURL: string) => {
const { locale } = useI18n();
const router = useRouter();
const id = Number(router.currentRoute.value.params.id);

const { id } = router.currentRoute.value.params;
const routeURL = `/${locale.value}/${basePath}/${id}/${label
.split(".")
.pop()!
Expand Down
52 changes: 8 additions & 44 deletions frontend/pages/events/[id]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,56 +72,20 @@ import { BreakpointMap } from "~/types/breakpoint-map";
import { IconMap } from "~/types/icon-map";
import type { MenuSelector } from "~/types/menu/menu-selector";
import { testClimateEvent } from "~/utils/testEntities";
import useMenuEntriesState from "~/composables/useMenuEntriesState";
const event = testClimateEvent;
const { id } = useRoute().params;
const localPath = useLocalePath();
const eventButtons: MenuSelector[] = [
{
id: 1,
label: "_global.about",
routeURL: "/events/" + id + "/about",
iconURL: `${IconMap.ABOUT}`,
selected: useRoute().path.split("/").pop() === "about" ? true : true,
},
{
id: 2,
label: "_global.team",
routeURL: "/events/" + id + "/team",
iconURL: `${IconMap.PEOPLE}`,
selected: useRoute().path.split("/").pop() === "team" ? true : true,
},
{
id: 3,
label: "_global.resources",
routeURL: "/events/" + id + "/resources",
iconURL: `${IconMap.RESOURCE}`,
selected: useRoute().path.split("/").pop() === "resources" ? true : true,
},
{
id: 4,
label: "_global.tasks",
routeURL: "/events/" + id + "/tasks",
iconURL: `${IconMap.TASK}`,
selected: useRoute().path.split("/").pop() === "tasks" ? true : true,
},
{
id: 5,
label: "_global.discussions",
routeURL: "/events/" + id + "/discussions",
iconURL: `${IconMap.DISCUSSION}`,
selected: useRoute().path.split("/").pop() === "discussions" ? true : true,
},
{
id: 6,
label: "_global.settings",
routeURL: "/events/" + id + "/settings",
iconURL: `${IconMap.SETTINGS}`,
selected: useRoute().path.split("/").pop() === "settings" ? true : true,
},
];
const { eventEntry } = useMenuEntriesState();
const eventButtons: MenuSelector[] = [];
eventEntry.value.forEach((entry) => {
eventButtons.push(entry);
});
const windowWidth = ref(window.innerWidth);
Expand Down
80 changes: 8 additions & 72 deletions frontend/pages/organizations/[id]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,84 +71,20 @@ import { BreakpointMap } from "~/types/breakpoint-map";
import { IconMap } from "~/types/icon-map";
import type { MenuSelector } from "~/types/menu/menu-selector";
import { testTechOrg } from "~/utils/testEntities";
import useMenuEntriesState from "~/composables/useMenuEntriesState";
const organization = testTechOrg;
const { id } = useRoute().params;
const localePath = useLocalePath();
const organizationButtons: MenuSelector[] = [
{
id: 1,
label: "_global.about",
routeURL: "/organizations/" + id + "/about",
iconURL: `${IconMap.ABOUT}`,
selected: useRoute().path.split("/").pop() === "about" ? true : true,
},
{
id: 2,
label: "_global.events",
routeURL: "/organizations/" + id + "/events",
iconURL: `${IconMap.EVENT}`,
selected: useRoute().path.split("/").pop() === "events" ? true : true,
},
{
id: 3,
label: "_global.groups",
routeURL: "/organizations/" + id + "/groups",
iconURL: `${IconMap.GROUP}`,
selected: useRoute().path.split("/").pop() === "groups" ? true : true,
},
{
id: 4,
label: "_global.resources",
routeURL: "/organizations/" + id + "/resources",
iconURL: `${IconMap.RESOURCE}`,
selected: useRoute().path.split("/").pop() === "resources" ? true : true,
},
{
id: 5,
label: "_global.faq",
routeURL: "/organizations/" + id + "/faq",
iconURL: `${IconMap.FAQ}`,
selected: useRoute().path.split("/").pop() === "faq" ? true : true,
},
// {
// id: X,
// label: "_global.team",
// routeURL: "/organizations/" + id + "/team",
// iconURL: `${IconMap.PEOPLE}`,
// selected: useRoute().path.split("/").pop() === "team" ? true : true,
// },
{
id: 6,
label: "_global.affiliates",
routeURL: "/organizations/" + id + "/affiliates",
iconURL: `${IconMap.SUPPORT}`,
selected: useRoute().path.split("/").pop() === "affiliates" ? true : true,
},
{
id: 7,
label: "_global.tasks",
routeURL: "/organizations/" + id + "/tasks",
iconURL: `${IconMap.TASK}`,
selected: useRoute().path.split("/").pop() === "tasks" ? true : true,
},
{
id: 8,
label: "_global.discussions",
routeURL: "/organizations/" + id + "/discussions",
iconURL: `${IconMap.DISCUSSION}`,
selected: useRoute().path.split("/").pop() === "discussions" ? true : true,
},
{
id: 9,
label: "_global.settings",
routeURL: "/organizations/" + id + "/settings",
iconURL: `${IconMap.SETTINGS}`,
selected: useRoute().path.split("/").pop() === "settings" ? true : true,
},
];
const { organizationEntry } = useMenuEntriesState();
const organizationButtons: MenuSelector[] = [];
organizationEntry.value.forEach((entry) => {
organizationButtons.push(entry);
});
const windowWidth = ref(window.innerWidth);
Expand Down

0 comments on commit f4608bb

Please sign in to comment.