import { Head, router } from '@inertiajs/react' import StyledTable from '~/components/StyledTable' import SettingsLayout from '~/layouts/SettingsLayout' import StyledButton from '~/components/StyledButton' import { useModals } from '~/context/ModalContext' import StyledModal from '~/components/StyledModal' import { FileEntry } from '../../../types/files' import MissingBaseAssetsAlert from '~/components/layout/MissingBaseAssetsAlert' import { useNotifications } from '~/context/NotificationContext' import { useState } from 'react' import api from '~/lib/api' import DownloadURLModal from '~/components/DownloadURLModal' export default function MapsManager(props: { maps: { baseAssetsExist: boolean; regionFiles: FileEntry[] } }) { const { openModal, closeAllModals } = useModals() const { addNotification } = useNotifications() const [downloading, setDownloading] = useState(false) async function downloadBaseAssets() { try { setDownloading(true) const res = await api.downloadBaseMapAssets() if (res.success) { addNotification({ type: 'success', message: 'Base map assets downloaded successfully.', }) router.reload() } } catch (error) { console.error('Error downloading base assets:', error) addNotification({ type: 'error', message: 'An error occurred while downloading the base map assets. Please try again.', }) } finally { setDownloading(false) } } async function confirmDeleteFile(file: FileEntry) { openModal( { closeAllModals() }} onCancel={closeAllModals} open={true} confirmText="Delete" cancelText="Cancel" confirmVariant="danger" >

Are you sure you want to delete {file.name}? This action cannot be undone.

, 'confirm-delete-file-modal' ) } async function openDownloadModal() { openModal( closeAllModals()} />, 'download-map-file-modal' ) } return (

Maps Manager

Manage your stored map data files.

Download New Map File
{!props.maps.baseAssetsExist && ( )} className="font-semibold mt-4" rowLines={true} loading={false} compact columns={[ { accessor: 'name', title: 'Name' }, { accessor: 'actions', title: 'Actions', render: (record) => (
{ confirmDeleteFile(record) }} > Delete
), }, ]} data={props.maps.regionFiles || []} />
) }