refact & cleanup : Sidebar, Button, card, EmptyState, Loader, ServiceObject, StatusBadge, UptameObject, BackupWidget, SecurityWidget, ServicesWidget, SupportCtaWidget, UptimeWidget, DashboardLayout
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { useState } from 'react';
|
||||
import { pb } from '@/services/pocketbase';
|
||||
|
||||
export const useEvolutionRequest = () => {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [submitSuccess, setSubmitSuccess] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const submitRequest = async (subject: string, description: string) => {
|
||||
setIsSubmitting(true);
|
||||
setError(null);
|
||||
try {
|
||||
await pb.collection('aegis_tickets').create({
|
||||
author: pb.authStore.model?.id,
|
||||
company: pb.authStore.model?.company,
|
||||
category: "Évolution",
|
||||
subject,
|
||||
description,
|
||||
status: "Ouvert"
|
||||
});
|
||||
setSubmitSuccess(true);
|
||||
} catch (err) {
|
||||
console.error("Erreur ticket d'évolution :", err);
|
||||
setError("Une erreur de communication est survenue. Nos systèmes sont alertés.");
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return { submitRequest, isSubmitting, submitSuccess, error };
|
||||
};
|
||||
Reference in New Issue
Block a user