From c22616534699ea40958d8596e2a76ab7e0e00618 Mon Sep 17 00:00:00 2001 From: Jonas de Luna Skulberg Date: Wed, 6 Nov 2024 20:14:14 +0100 Subject: [PATCH] Update the button and endpoints --- app/actions/MeetingTemplateActions.ts | 10 +++++----- app/routes/meetings/components/MeetingEditor.tsx | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/actions/MeetingTemplateActions.ts b/app/actions/MeetingTemplateActions.ts index 42493fbb87..0dd83de3ad 100644 --- a/app/actions/MeetingTemplateActions.ts +++ b/app/actions/MeetingTemplateActions.ts @@ -7,7 +7,7 @@ import type { Dateish, MeetingTemplate } from 'app/models'; export const fetchAllMeetingTemplates = () => callAPI({ types: MeetingTemplates.FETCH_ALL, - endpoint: '/meetingtemplates/', + endpoint: '/meetings/templates/', schema: [meetingTemplatesSchema], meta: { errorMessage: 'Henting av møte-maler feilet', @@ -28,7 +28,7 @@ export function createMeetingTemplate(data: { }) { return callAPI({ types: MeetingTemplates.CREATE, - endpoint: '/meetingtemplates/', + endpoint: '/meetings/templates/', method: 'POST', body: data, schema: meetingTemplatesSchema, @@ -46,7 +46,7 @@ export function editMeetingTemplate(data: { }) { return callAPI({ types: MeetingTemplates.UPDATE, - endpoint: `/meetingtemplates/${data.meetingTemplateId}/`, + endpoint: `/meetings/templates/${data.meetingTemplateId}/`, method: 'PATCH', body: data, schema: meetingTemplatesSchema, @@ -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, diff --git a/app/routes/meetings/components/MeetingEditor.tsx b/app/routes/meetings/components/MeetingEditor.tsx index 6dc2d10072..604ed4c16c 100644 --- a/app/routes/meetings/components/MeetingEditor.tsx +++ b/app/routes/meetings/components/MeetingEditor.tsx @@ -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'; @@ -24,6 +24,7 @@ import { } from 'app/actions/MeetingActions'; import { createMeetingTemplate, + deleteMeetingTemplate, fetchAllMeetingTemplates, } from 'app/actions/MeetingTemplateActions'; import Dropdown from 'app/components/Dropdown'; @@ -314,6 +315,10 @@ const MeetingEditor = () => { }} > {template.name} + } + onClick={dispatch(deleteMeetingTemplate(template.id))} + /> @@ -330,7 +335,7 @@ const MeetingEditor = () => { label: `${isEditPage ? 'Tilbake' : 'Dine møter'}`, href: `/meetings/${isEditPage ? meetingId : ''}`, }} - actionButtons={actionButtons} + actionButtons={actionButtons && allMeetingTemplates.length > 0} >