[License module] Fix casing in licenses, allow multiple uploads properly handle dirty states in frontend

This commit is contained in:
2026-07-23 14:24:26 +02:00
parent 35853171cb
commit d38ab2c2fc
5 changed files with 254 additions and 126 deletions
+20 -4
View File
@@ -1,5 +1,5 @@
import axios, { AxiosError } from 'axios';
import { License } from '@/types';
import { License, LicenseValidationInfo } from '@/types';
import { toast } from 'vue-sonner';
const API_URL = '/api/licenses';
@@ -53,7 +53,7 @@ export default {
},
/**
* Updates an existing license
* Updates one existing license
* @param license - The license data to update
* @returns Promise<License | null>
*/
@@ -68,6 +68,22 @@ export default {
}
},
/**
* Updates multiple licenses in one request.
* @param licenses - The dirty license data to update
* @returns Promise<License[] | null>
*/
async updateLicenses(licenses: License[]): Promise<License[] | null> {
try {
const response = await axios.put(API_URL, licenses);
return response.data;
} catch (error) {
toast.error('Fehler beim Aktualisieren der Lizenzen', { description: (error as AxiosError).message });
console.error(error);
return null;
}
},
/**
* Deletes a license by ID
* @param id - The ID of the license to delete
@@ -113,9 +129,9 @@ export default {
* @param licenseId - The ID of the license to validate
* @returns Promise<{ is_valid: boolean, is_signature_valid: boolean, is_expired: boolean } | null>
*/
async validateLicense(license: License): Promise<{ isValid: boolean, isSignatureValid: boolean, isExpired: boolean } | null> {
async validateLicense(license: License): Promise<LicenseValidationInfo | null> {
try {
const response = await axios.post('/api/licenses/validate', { license });
const response = await axios.post('/api/licenses/validate', license);
return response.data;
} catch (error) {
toast.error('Fehler beim Validieren der Lizenz', { description: (error as AxiosError).message });