Skip to content

Commit

Permalink
Update the button and endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasdeluna committed Nov 6, 2024
1 parent 23a4c9e commit c226165
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/actions/MeetingTemplateActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Dateish, MeetingTemplate } from 'app/models';
export const fetchAllMeetingTemplates = () =>
callAPI<MeetingTemplate[]>({
types: MeetingTemplates.FETCH_ALL,
endpoint: '/meetingtemplates/',
endpoint: '/meetings/templates/',
schema: [meetingTemplatesSchema],
meta: {
errorMessage: 'Henting av møte-maler feilet',
Expand All @@ -28,7 +28,7 @@ export function createMeetingTemplate(data: {
}) {
return callAPI<MeetingTemplate>({
types: MeetingTemplates.CREATE,
endpoint: '/meetingtemplates/',
endpoint: '/meetings/templates/',
method: 'POST',
body: data,
schema: meetingTemplatesSchema,
Expand All @@ -46,7 +46,7 @@ export function editMeetingTemplate(data: {
}) {
return callAPI<MeetingTemplate>({
types: MeetingTemplates.UPDATE,
endpoint: `/meetingtemplates/${data.meetingTemplateId}/`,
endpoint: `/meetings/templates/${data.meetingTemplateId}/`,
method: 'PATCH',
body: data,
schema: meetingTemplatesSchema,
Expand All @@ -57,10 +57,10 @@ export function editMeetingTemplate(data: {
});
}

export function deletePoll(id: EntityId) {
export function deleteMeetingTemplate(id: EntityId) {
return callAPI({
types: MeetingTemplates.DELETE,
endpoint: `/meetingtemplates/${id}/`,
endpoint: `/meetings/templates/${id}/`,
method: 'DELETE',
meta: {
id,
Expand Down
9 changes: 7 additions & 2 deletions app/routes/meetings/components/MeetingEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@webkom/lego-bricks';
import { usePreparedEffect } from '@webkom/react-prepare';
import { unionBy } from 'lodash';
import { Trash2 } from 'lucide-react';
import { Trash2, X } from 'lucide-react';
import moment from 'moment-timezone';
import { useState } from 'react';
import { Field, FormSpy } from 'react-final-form';
Expand All @@ -24,6 +24,7 @@ import {
} from 'app/actions/MeetingActions';
import {
createMeetingTemplate,
deleteMeetingTemplate,
fetchAllMeetingTemplates,
} from 'app/actions/MeetingTemplateActions';
import Dropdown from 'app/components/Dropdown';
Expand Down Expand Up @@ -314,6 +315,10 @@ const MeetingEditor = () => {
}}
>
{template.name}
<Icon
iconNode={<X />}
onClick={dispatch(deleteMeetingTemplate(template.id))}
/>
</button>
</Dropdown.ListItem>
</>
Expand All @@ -330,7 +335,7 @@ const MeetingEditor = () => {
label: `${isEditPage ? 'Tilbake' : 'Dine møter'}`,
href: `/meetings/${isEditPage ? meetingId : ''}`,
}}
actionButtons={actionButtons}
actionButtons={actionButtons && allMeetingTemplates.length > 0}
>
<Helmet title={title} />
<LegoFinalForm
Expand Down

0 comments on commit c226165

Please sign in to comment.