From 9e9ce28a8f3d1a78531da0a78fcf6674de083f33 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Mon, 22 Jul 2024 13:06:31 +0200 Subject: [PATCH] Allow license deletion in Licenses.jsx --- .../states/Dashboard/pages/Licenses/Licenses.jsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dashboard/src/states/Dashboard/pages/Licenses/Licenses.jsx b/dashboard/src/states/Dashboard/pages/Licenses/Licenses.jsx index bcc586c..a846552 100644 --- a/dashboard/src/states/Dashboard/pages/Licenses/Licenses.jsx +++ b/dashboard/src/states/Dashboard/pages/Licenses/Licenses.jsx @@ -1,6 +1,6 @@ import {DataGrid} from '@mui/x-data-grid'; import {useContext, useEffect, useState} from "react"; -import {getRequest} from "@/common/utils/RequestUtil.js"; +import {deleteRequest, getRequest} from "@/common/utils/RequestUtil.js"; import {ProjectContext} from "@/states/Dashboard/contexts/Project"; import {Button, Stack, TextField} from "@mui/material"; import {Search} from "@mui/icons-material"; @@ -43,13 +43,22 @@ export const Licenses = () => { localStorage.setItem(LOCAL_STORAGE_KEY_COLUMNS, JSON.stringify(columnSettings)); }, [columnSettings]); + const deleteLicense = async (licenseKey) => { + try { + await deleteRequest(`/license/${currentProject.id}/${encodeURIComponent(licenseKey)}`); + fetchLicenses(); + } catch (e) { + console.error(e); + } + } + const handlePaginationModelChange = (model) => setPaginationModel(prev => ({...prev, page: model.page, pageSize: model.pageSize})); const handleColumnWidthChange = (params) => setColumnSettings((prev) => ({...prev, [params.colDef.field]: params.width})); - const getColumnsWithWidth = () => columns.map(column => ({...column, + const getColumnsWithWidth = () => columns(deleteLicense).map(column => ({...column, width: columnSettings[column.field] || column.width})); const updateDisplayedColumns = (columns) => {