Skip to content

Commit

Permalink
Add Delete button to organizers when permission is there
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen committed Sep 19, 2023
1 parent 171d1a8 commit b2242b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/layouts/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ import { useCookiesWithOptions } from '@/hooks/useCookiesWithOptions';
import { FeatureFlags, useFeatureFlag } from '@/hooks/useFeatureFlag';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { useMatchBreakpoint } from '@/hooks/useMatchBreakpoint';
import {
Features,
NewFeatureTooltip,
QuestionCircleIcon,
} from '@/pages/NewFeatureTooltip';
import { QuestionCircleIcon } from '@/pages/NewFeatureTooltip';
import type { Values } from '@/types/Values';
import { Badge } from '@/ui/Badge';
import { Button, ButtonVariants } from '@/ui/Button';
Expand Down Expand Up @@ -641,4 +637,4 @@ const Sidebar = () => {
];
};

export { Sidebar };
export { PermissionTypes, Sidebar };
10 changes: 10 additions & 0 deletions src/pages/dashboard/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import {
useGetPlacesByCreatorQuery,
} from '@/hooks/api/places';
import {
useGetPermissionsQuery,
useGetUserQuery,
useGetUserQueryServerSide,
User,
} from '@/hooks/api/user';
import { FeatureFlags, useFeatureFlag } from '@/hooks/useFeatureFlag';
import { PermissionTypes } from '@/layouts/Sidebar';
import { Footer } from '@/pages/Footer';
import type { Event } from '@/types/Event';
import { Offer } from '@/types/Offer';
Expand Down Expand Up @@ -361,6 +363,7 @@ const OrganizerRow = ({
const { t, i18n } = useTranslation();

const getUserQuery = useGetUserQuery();
const getPermissionsQuery = useGetPermissionsQuery();
// @ts-expect-error
const userId = getUserQuery.data?.sub;
// @ts-expect-error
Expand All @@ -373,6 +376,8 @@ const OrganizerRow = ({
const formattedAddress = address ? formatAddressInternal(address) : '';
const editUrl = `/organizer/${parseOfferId(organizer['@id'])}/edit`;
const previewUrl = `/organizer/${parseOfferId(organizer['@id'])}/preview`;
// @ts-expect-error
const permissions = getPermissionsQuery?.data ?? [];

return (
<Row
Expand All @@ -385,6 +390,11 @@ const OrganizerRow = ({
<Link href={editUrl} variant={LinkVariants.BUTTON_SECONDARY} key="edit">
{t('dashboard.actions.edit')}
</Link>,
permissions?.includes(PermissionTypes.ORGANISATIES_BEHEREN) && (
<Dropdown.Item onClick={() => onDelete(organizer)} key="delete">
{t('dashboard.actions.delete')}
</Dropdown.Item>
),
]}
status={{
isExternalCreator,
Expand Down

0 comments on commit b2242b8

Please sign in to comment.