diff --git a/packages/web/lib/networking/useCreateExport.tsx b/packages/web/lib/networking/useCreateExport.tsx new file mode 100644 index 000000000..853cd1101 --- /dev/null +++ b/packages/web/lib/networking/useCreateExport.tsx @@ -0,0 +1,11 @@ +import { apiFetcher } from './networkHelpers' + +export const createExport = async (): Promise => { + try { + const response = await apiFetcher(`/api/export/`) + return true + } catch (error) { + console.log('error scheduling export. ') + return false + } +} diff --git a/packages/web/pages/settings/account.tsx b/packages/web/pages/settings/account.tsx index a863a1543..e49e50616 100644 --- a/packages/web/pages/settings/account.tsx +++ b/packages/web/pages/settings/account.tsx @@ -27,6 +27,7 @@ import { useGetViewerQuery } from '../../lib/networking/queries/useGetViewerQuer import { useValidateUsernameQuery } from '../../lib/networking/queries/useValidateUsernameQuery' import { applyStoredTheme } from '../../lib/themeUpdater' import { showErrorToast, showSuccessToast } from '../../lib/toastHelpers' +import { createExport } from '../../lib/networking/useCreateExport' const ACCOUNT_LIMIT = 50_000 @@ -283,6 +284,8 @@ export default function Account(): JSX.Element { + + - - + {/* + */} Upgrade */} - + {/* */} { + const doExport = useCallback(async () => { + const result = await createExport() + if (result) { + showSuccessToast('Your export has started.') + } else { + showErrorToast('There was an error creating your export.') + } + }, []) + + return ( + + Export + + Export all of your data. This can be done once per day and will be + delivered to your registered email address. Once your export has started + you should receive an email with a link to your data within an hour. The + download link will be available for 24 hours. + + + + ) +} + const BetaFeaturesSection = (): JSX.Element => { const { viewerData } = useGetViewerQuery() return (