feat: intégration Microsoft Graph pour export SharePoint - helper uploadToSharePoint, champs Azure AD en DB et UI
This commit is contained in:
@@ -46,6 +46,10 @@ export default function ImportSettings() {
|
||||
const [exportFolderType, setExportFolderType] = useState<"local" | "teams" | "sharepoint">("local");
|
||||
// Compat. ancienne valeur
|
||||
const [bapExportMode, setBapExportMode] = useState<"browser" | "folder" | "both">("browser");
|
||||
// Azure AD credentials for SharePoint
|
||||
const [azureTenantId, setAzureTenantId] = useState("");
|
||||
const [azureClientId, setAzureClientId] = useState("");
|
||||
const [azureClientSecret, setAzureClientSecret] = useState("");
|
||||
|
||||
// Initialize form with settings from database
|
||||
useEffect(() => {
|
||||
@@ -66,10 +70,19 @@ export default function ImportSettings() {
|
||||
setBapExportBrowser(savedMode === "browser" || savedMode === "both");
|
||||
setBapExportFolder(savedMode === "folder" || savedMode === "both");
|
||||
setBapExportMode(savedMode as "browser" | "folder" | "both");
|
||||
// Lire le type de dossier depuis exportFolder (préfixe teams:// ou sharepoint://)
|
||||
if ((settings.exportFolder || "").startsWith("teams://")) setExportFolderType("teams");
|
||||
else if ((settings.exportFolder || "").startsWith("sharepoint://")) setExportFolderType("sharepoint");
|
||||
else setExportFolderType("local");
|
||||
// Lire le type de dossier depuis le champ dédié exportFolderType
|
||||
if ((settings as any).exportFolderType) {
|
||||
setExportFolderType((settings as any).exportFolderType as "local" | "teams" | "sharepoint");
|
||||
} else {
|
||||
// Compat. ancienne logique préfixe
|
||||
if ((settings.exportFolder || "").startsWith("teams://")) setExportFolderType("teams");
|
||||
else if ((settings.exportFolder || "").startsWith("sharepoint://")) setExportFolderType("sharepoint");
|
||||
else setExportFolderType("local");
|
||||
}
|
||||
// Azure AD
|
||||
setAzureTenantId((settings as any).azureTenantId || "");
|
||||
setAzureClientId((settings as any).azureClientId || "");
|
||||
setAzureClientSecret((settings as any).azureClientSecret || "");
|
||||
}
|
||||
}, [settings]);
|
||||
|
||||
@@ -94,7 +107,11 @@ export default function ImportSettings() {
|
||||
emailImportPort: emailImportPort,
|
||||
emailImportFrequency: emailImportFrequency,
|
||||
exportFolder: exportFolder || null,
|
||||
bapExportMode: computedExportMode() as "browser" | "folder",
|
||||
exportFolderType: exportFolderType,
|
||||
bapExportMode: computedExportMode() as "browser" | "folder" | "both",
|
||||
azureTenantId: azureTenantId || null,
|
||||
azureClientId: azureClientId || null,
|
||||
azureClientSecret: azureClientSecret || null,
|
||||
});
|
||||
|
||||
toast.success("Paramètres enregistrés avec succès");
|
||||
@@ -620,6 +637,52 @@ export default function ImportSettings() {
|
||||
{exportFolderType === "sharepoint" && "URL complète du dossier SharePoint de destination"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Champs Azure AD — visibles uniquement pour SharePoint */}
|
||||
{exportFolderType === "sharepoint" && (
|
||||
<div className="mt-4 p-4 bg-cyan-50 dark:bg-cyan-950/20 rounded-xl border border-cyan-200 dark:border-cyan-800 space-y-4">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<div className="w-2 h-2 rounded-full bg-cyan-500" />
|
||||
<span className="text-sm font-semibold text-cyan-700 dark:text-cyan-300">Configuration Microsoft Azure AD</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-3">
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="azureTenantId" className="text-sm font-medium">ID de l'annuaire (Tenant ID) <span className="text-red-500">*</span></Label>
|
||||
<Input
|
||||
id="azureTenantId"
|
||||
type="text"
|
||||
placeholder="487d0a81-de35-44ce-8847-03bb74ec553e"
|
||||
value={azureTenantId}
|
||||
onChange={(e) => setAzureTenantId(e.target.value)}
|
||||
className="h-10 font-mono text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="azureClientId" className="text-sm font-medium">ID d'application (Client ID) <span className="text-red-500">*</span></Label>
|
||||
<Input
|
||||
id="azureClientId"
|
||||
type="text"
|
||||
placeholder="e6c2f351-16a6-4659-9b04-de3ea90194f0"
|
||||
value={azureClientId}
|
||||
onChange={(e) => setAzureClientId(e.target.value)}
|
||||
className="h-10 font-mono text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="azureClientSecret" className="text-sm font-medium">Secret client <span className="text-red-500">*</span></Label>
|
||||
<Input
|
||||
id="azureClientSecret"
|
||||
type="password"
|
||||
placeholder="Valeur du secret Azure AD"
|
||||
value={azureClientSecret}
|
||||
onChange={(e) => setAzureClientSecret(e.target.value)}
|
||||
className="h-10 font-mono text-sm"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">Stocké de façon sécurisée. Permissions requises : <code>Files.ReadWrite.All</code> et <code>Sites.ReadWrite.All</code></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user