import React, { useEffect } from 'react'; import { Helmet } from 'react-helmet'; import Spinner from '@/components/elements/Spinner'; import useServer from '@/plugins/useServer'; import useFlash from '@/plugins/useFlash'; import Can from '@/components/elements/Can'; import CreateBackupButton from '@/components/server/backups/CreateBackupButton'; import FlashMessageRender from '@/components/FlashMessageRender'; import BackupRow from '@/components/server/backups/BackupRow'; import PageContentBlock from '@/components/elements/PageContentBlock'; import tw from 'twin.macro'; import getServerBackups from '@/api/swr/getServerBackups'; export default () => { const { clearFlashes, clearAndAddHttpError } = useFlash(); const { featureLimits, name: serverName } = useServer(); const { data: backups, error, isValidating } = getServerBackups(); useEffect(() => { if (!error) { clearFlashes('backups'); return; } clearAndAddHttpError({ error, key: 'backups' }); }, [ error ]); if (!backups || (error && isValidating)) { return ; } return ( {serverName} | Backups {!backups.items.length ?

There are no backups stored for this server.

:
{backups.items.map((backup, index) => 0 ? tw`mt-2` : undefined} />)}
} {featureLimits.backups === 0 &&

Backups cannot be created for this server.

} {(featureLimits.backups > 0 && backups.items.length > 0) &&

{backups.items.length} of {featureLimits.backups} backups have been created for this server.

} {featureLimits.backups > 0 && featureLimits.backups !== backups.items.length &&
}
); };