cal/packages/app-store/_utils/getAppCategories.ts
Rob Jackson 171827f547
chore: recategorize apps (#9306)
* Remove unused code in InstalledAppsLayout

* Add new app categories "crm", "conferencing" and "messaging"

* Sort getAppCategories entries alphabetically

* Fix 404s on new category pages (and remove hardcoded category lists)

* Fix admin apps list not showing "no available apps" for new categories

* Recategorise apps

* Sync seed-app-store categories with config files

* Replace unnecessary seed-app-store.config.json with appStoreMetadata

* Copy video.svg to conferencing.svg

* Add messaging.svg

* Remove web3 from getAppCategories (used by installed apps, admin apps)

* Fix app-store-cli categories

- Add conferencing
- Add CRM
- Remove video
- Remove web3

* Remove outdated web3 comment in seed-app-store

* Update apps/web/public/static/locales/en/common.json

* Add cron script to keep db apps in sync with app metadata

* Add redirect for app category "video" to "conferencing"

* Fix up "video" category overrides to apply to conferencing

* Fix conferencing apps not showing as a location for non-team users

* Restore "installed_app" string for conferencing apps

* Make linter happier

* Remove my "installed_app_conferencing_description" as this was fixed upstream

* Quick tidy up

* Add dry-run to syncAppMeta via  CRON_ENABLE_APP_SYNC env

* Replace console.log with logger in syncAppMeta

---------

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: alannnc <alannnc@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
2023-06-28 18:22:51 +02:00

75 lines
1.8 KiB
TypeScript

import { WEBAPP_URL } from "@calcom/lib/constants";
import type { AppCategories } from "@calcom/prisma/enums";
import type { LucideIcon } from "@calcom/ui/components/icon";
import {
Calendar,
Video,
CreditCard,
Share2,
BarChart,
Grid,
Mail,
Contact,
} from "@calcom/ui/components/icon";
function getHref(baseURL: string, category: string, useQueryParam: boolean) {
const baseUrlParsed = new URL(baseURL, WEBAPP_URL);
baseUrlParsed.searchParams.set("category", category);
return useQueryParam ? `${baseUrlParsed.toString()}` : `${baseURL}/${category}`;
}
type AppCategoryEntry = {
name: AppCategories;
href: string;
icon: LucideIcon;
};
const getAppCategories = (baseURL: string, useQueryParam: boolean): AppCategoryEntry[] => {
// Manually sorted alphabetically, but leaving "Other" at the end
// TODO: Refactor and type with Record<AppCategories, AppCategoryEntry> to enforce consistency
return [
{
name: "analytics",
href: getHref(baseURL, "analytics", useQueryParam),
icon: BarChart,
},
{
name: "automation",
href: getHref(baseURL, "automation", useQueryParam),
icon: Share2,
},
{
name: "calendar",
href: getHref(baseURL, "calendar", useQueryParam),
icon: Calendar,
},
{
name: "conferencing",
href: getHref(baseURL, "conferencing", useQueryParam),
icon: Video,
},
{
name: "crm",
href: getHref(baseURL, "crm", useQueryParam),
icon: Contact,
},
{
name: "messaging",
href: getHref(baseURL, "messaging", useQueryParam),
icon: Mail,
},
{
name: "payment",
href: getHref(baseURL, "payment", useQueryParam),
icon: CreditCard,
},
{
name: "other",
href: getHref(baseURL, "other", useQueryParam),
icon: Grid,
},
];
};
export default getAppCategories;