fix: normaliser les URLs des connecteurs web
This commit is contained in:
@@ -7,6 +7,7 @@ import { Label } from "@/components/ui/label";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { isValidWebPortalUrl, normalizeWebPortalUrl } from "@shared/webPortalUrl";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -158,12 +159,20 @@ export default function WebImportSources() {
|
||||
toast.error("Champs requis", { description: "Nom, identifiant et mot de passe sont obligatoires." });
|
||||
return;
|
||||
}
|
||||
const portalUrl = normalizeWebPortalUrl(form.portalUrl);
|
||||
if (!isValidWebPortalUrl(portalUrl)) {
|
||||
toast.error("URL de portail invalide", {
|
||||
description: "Saisissez une adresse HTTP(S), par exemple https://espaceclient.exemple.fr.",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (editSource) {
|
||||
const updateData: any = { id: editSource.id, ...form };
|
||||
const updateData: any = { id: editSource.id, ...form, portalUrl };
|
||||
if (!form.loginPassword) delete updateData.loginPassword; // Ne pas écraser si vide
|
||||
updateMutation.mutate(updateData);
|
||||
} else {
|
||||
createMutation.mutate(form);
|
||||
createMutation.mutate({ ...form, portalUrl });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +325,7 @@ export default function WebImportSources() {
|
||||
onChange={e => setForm(f => ({ ...f, portalUrl: e.target.value }))}
|
||||
placeholder="https://..."
|
||||
/>
|
||||
<p className="mt-1 text-xs text-muted-foreground">Le préfixe https:// est ajouté automatiquement si nécessaire.</p>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Identifiant (email ou login)</Label>
|
||||
|
||||
Reference in New Issue
Block a user