// app/admin/upload/_components/map/StylingLayers.tsx "use client"; import React, { useState } from "react"; import { Button } from "@/shared/components/ui/button"; import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/shared/components/ui/tabs"; import CustomLayerStyle from "./CustomLayerStyle"; // ⬅️ Import Komponen Baru function normalizeBase64(xmlString:any) { return xmlString.replace( /xlink:href="base64:([^"?]+)(\?[^"]*)?"/g, (_: any, base64Content: any) => { return `xlink:href="data:image/svg+xml;base64,${base64Content}"`; } ); } const StylingLayers = ({ data, geometryType, onSubmit, geosStyle }: { data: any, geometryType: string, onSubmit: (val: any) => void, geosStyle: any[] }) => { // Ubah default tab ke 'custom' agar user langsung bisa edit warna const [activeTab, setActiveTab] = useState("custom"); const [parsedSld, setParsedSld] = useState(null); return (
{/* 🔥 Aktifkan Tab Custom */} Custom Upload SLD {/* List Style */} {/* 🔥 Tambahkan Content Tab Custom */}

Upload File SLD

Unggah file .sld untuk mengganti style layer.

{ const file = e.target.files?.[0]; if (!file) return; const reader = new FileReader(); reader.onload = () => { const sld = normalizeBase64(reader.result) setParsedSld(sld) onSubmit({ styleType: "sld", sldContent: sld, }); }; reader.readAsText(file); }} />
{/* ... (Konten List Style tetap sama) ... */}
); }; export default StylingLayers;