diff --git a/src/renderer/src/components/error-dialog.tsx b/src/renderer/src/components/error-dialog.tsx index d4872f1e..64678757 100644 --- a/src/renderer/src/components/error-dialog.tsx +++ b/src/renderer/src/components/error-dialog.tsx @@ -1,9 +1,8 @@ -import { useState, type MouseEventHandler } from 'react' +import { useState } from 'react' import Box from '@mui/material/Box' import Button from '@mui/material/Button' import ButtonBase from '@mui/material/ButtonBase' import Collapse from '@mui/material/Collapse' -import Dialog from '@mui/material/Dialog' import Stack from '@mui/material/Stack' import Typography from '@mui/material/Typography' import { alpha } from '@mui/material/styles' @@ -12,119 +11,6 @@ import { defineMessages, useIntl } from 'react-intl' import { BLUE_GREY, DARK_GREY, LIGHT_GREY } from '../colors.ts' import { Icon } from './icon.tsx' -export type Props = { - errorMessage?: string - onClose: MouseEventHandler - open: boolean -} - -/** - * @deprecated Use `DecentDialog` with `ErrorDialogContent` - */ -export function ErrorDialog({ errorMessage, onClose, open }: Props) { - const { formatMessage: t } = useIntl() - - const [advancedExpanded, setAdvancedExpanded] = useState(false) - - return ( - - - - - - - - {t(m.somethingWentWrong)} - - - - {errorMessage ? ( - - { - setAdvancedExpanded((prev) => !prev) - }} - sx={{ - ':hover, :focus': { - backgroundColor: alpha(BLUE_GREY, 0.2), - transition: (theme) => - theme.transitions.create('background-color'), - }, - padding: 2, - borderRadius: 2, - }} - > - - {t(m.advanced)} - - - - - - - - {errorMessage} - - - - - ) : null} - - - - - - - - ) -} - export function ErrorDialogContent({ errorMessage, onClose, diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/download.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/download.tsx index c5936f54..9f257394 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/download.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/download.tsx @@ -17,7 +17,8 @@ import { defineMessages, useIntl } from 'react-intl' import * as v from 'valibot' import { BLUE_GREY, DARK_GREY, GREEN } from '../../../../../colors.ts' -import { ErrorDialog } from '../../../../../components/error-dialog.tsx' +import { DecentDialog } from '../../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../../components/error-dialog.tsx' import { Icon } from '../../../../../components/icon.tsx' import { useAppForm } from '../../../../../hooks/forms.ts' import { getLocaleStateQueryOptions } from '../../../../../lib/queries/app-settings.ts' @@ -384,13 +385,20 @@ function DownloadForm({ - { - downloadData.reset() - }} - /> + + {(error) => ( + { + downloadData.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/exchange/index.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/exchange/index.tsx index 431e260a..7d23e1b0 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/exchange/index.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/exchange/index.tsx @@ -27,7 +27,8 @@ import { DARKER_ORANGE, GREEN, } from '../../../../../../colors.ts' -import { ErrorDialog } from '../../../../../../components/error-dialog.tsx' +import { DecentDialog } from '../../../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../../../components/error-dialog.tsx' import { Icon } from '../../../../../../components/icon.tsx' import { ButtonLink } from '../../../../../../components/link.tsx' import { useIconSizeBasedOnTypography } from '../../../../../../hooks/icon.ts' @@ -97,25 +98,6 @@ function RouteComponent() { const startSync = useStartSync({ projectId }) const stopSync = useStopSync({ projectId }) - const errorDialogProps = - startSync.status === 'error' - ? { - open: true, - errorMessage: startSync.error.message, - onClose: () => { - startSync.reset() - }, - } - : stopSync.status === 'error' - ? { - open: true, - errorMessage: stopSync.error.message, - onClose: () => { - stopSync.reset() - }, - } - : { open: false, onClose: () => {} } - const connectedPeersCount = syncState ? getConnectedPeersCount(syncState.remoteDeviceSyncState) : 0 @@ -282,7 +264,32 @@ function RouteComponent() { } - + { + startSync.reset() + }, + } + : stopSync.status === 'error' + ? { + open: true, + errorMessage: stopSync.error.toString(), + onClose: () => { + stopSync.reset() + }, + } + : null + } + > + {({ errorMessage, onClose }) => ( + + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-edit-category-panel.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-edit-category-panel.tsx index 758c6066..89ed91f5 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-edit-category-panel.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-edit-category-panel.tsx @@ -20,15 +20,16 @@ import { } from '@tanstack/react-query' import { defineMessages, useIntl } from 'react-intl' -import { BLUE_GREY } from '../../../../../../../colors' +import { BLUE_GREY } from '../../../../../../../colors.ts' import { CategoryIconContainer, CategoryIconImage, -} from '../../../../../../../components/category-icon' -import { ErrorDialog } from '../../../../../../../components/error-dialog' -import { Icon } from '../../../../../../../components/icon' -import { getLocaleStateQueryOptions } from '../../../../../../../lib/queries/app-settings' -import { createGlobalMutationsKey } from '../../../../../../../lib/queries/global-mutations' +} from '../../../../../../../components/category-icon.tsx' +import { DecentDialog } from '../../../../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../../../../components/error-dialog.tsx' +import { Icon } from '../../../../../../../components/icon.tsx' +import { getLocaleStateQueryOptions } from '../../../../../../../lib/queries/app-settings.ts' +import { createGlobalMutationsKey } from '../../../../../../../lib/queries/global-mutations.ts' const UPDATE_OBSERVATION_CATEGORY_MUTATION_KEY = createGlobalMutationsKey([ 'observations', @@ -266,13 +267,24 @@ function CategoriesList({ })} - { - updateObservationCategory.reset() - }} - /> + + {(error) => ( + { + updateObservationCategory.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-field-sections.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-field-sections.tsx index afbcdacf..3f902c7b 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-field-sections.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-field-sections.tsx @@ -6,21 +6,22 @@ import { captureException } from '@sentry/react' import { useMutation, useSuspenseQuery } from '@tanstack/react-query' import { defineMessages, useIntl } from 'react-intl' -import { ErrorDialog } from '../../../../../../../components/error-dialog' -import { - type ObservationTagValue, - type TagValue, -} from '../../../../../../../lib/comapeo' -import { getLocaleStateQueryOptions } from '../../../../../../../lib/queries/app-settings' -import { createGlobalMutationsKey } from '../../../../../../../lib/queries/global-mutations' -import { EditableSection } from './-components/editable-section' +import { DecentDialog } from '../../../../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../../../../components/error-dialog.tsx' +import type { + ObservationTagValue, + TagValue, +} from '../../../../../../../lib/comapeo.ts' +import { getLocaleStateQueryOptions } from '../../../../../../../lib/queries/app-settings.ts' +import { createGlobalMutationsKey } from '../../../../../../../lib/queries/global-mutations.ts' +import { EditableSection } from './-components/editable-section.tsx' import { MultiSelectFieldEditor, NumberFieldEditor, SingleSelectFieldEditor, TextFieldEditor, -} from './-field-editors' -import { getDisplayedTagValue, type EditableField } from './-shared' +} from './-field-editors.tsx' +import { getDisplayedTagValue, type EditableField } from './-shared.ts' export function ReadOnlyFieldSection({ label, @@ -155,9 +156,9 @@ export function EditableFieldSection({ updateEditState('success') } catch (err) { captureException(err) - } finally { - onStopEditMode() } + + onStopEditMode() }} /> ) @@ -187,9 +188,9 @@ export function EditableFieldSection({ updateEditState('success') } catch (err) { captureException(err) - } finally { - onStopEditMode() } + + onStopEditMode() }} /> ) @@ -219,9 +220,9 @@ export function EditableFieldSection({ updateEditState('success') } catch (err) { captureException(err) - } finally { - onStopEditMode() } + + onStopEditMode() }} /> ) @@ -251,9 +252,9 @@ export function EditableFieldSection({ updateEditState('success') } catch (err) { captureException(err) - } finally { - onStopEditMode() } + + onStopEditMode() }} /> ) @@ -300,13 +301,24 @@ export function EditableFieldSection({ }} /> - { - updateObservationField.reset() - }} - /> + + {(error) => ( + { + updateObservationField.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-notes-section.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-notes-section.tsx index 289b3c38..f166a63f 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-notes-section.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/-notes-section.tsx @@ -9,12 +9,13 @@ import { useMutation, useSuspenseQuery } from '@tanstack/react-query' import { defineMessages, useIntl } from 'react-intl' import * as v from 'valibot' -import { ErrorDialog } from '../../../../../../../components/error-dialog' -import { Icon } from '../../../../../../../components/icon' -import { useAppForm } from '../../../../../../../hooks/forms' -import { getLocaleStateQueryOptions } from '../../../../../../../lib/queries/app-settings' -import { createGlobalMutationsKey } from '../../../../../../../lib/queries/global-mutations' -import { EditableSection } from './-components/editable-section' +import { DecentDialog } from '../../../../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../../../../components/error-dialog.tsx' +import { Icon } from '../../../../../../../components/icon.tsx' +import { useAppForm } from '../../../../../../../hooks/forms.ts' +import { getLocaleStateQueryOptions } from '../../../../../../../lib/queries/app-settings.ts' +import { createGlobalMutationsKey } from '../../../../../../../lib/queries/global-mutations.ts' +import { EditableSection } from './-components/editable-section.tsx' export function ReadOnlyNotesSection({ notes }: { notes?: string }) { const { formatMessage: t } = useIntl() @@ -120,9 +121,9 @@ export function EditableNotesSection({ updateEditState('success') } catch (err) { captureException(err) - } finally { - onStopEditMode() } + + onStopEditMode() }} /> )} @@ -150,13 +151,24 @@ export function EditableNotesSection({ /> - { - updateObservationNotes.reset() - }} - /> + + {(error) => ( + { + updateObservationNotes.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/attachments/$driveId.$type.$variant.$name.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/attachments/$driveId.$type.$variant.$name.tsx index aad772de..a752de5f 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/attachments/$driveId.$type.$variant.$name.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/attachments/$driveId.$type.$variant.$name.tsx @@ -22,19 +22,20 @@ import { createFileRoute, useRouter } from '@tanstack/react-router' import { defineMessages, useIntl } from 'react-intl' import * as v from 'valibot' -import { PhotoAttachmentImage } from '../-components/photo-attachment-image' -import { BLUE_GREY, GREEN, LIGHT_GREY } from '../../../../../../../../colors' -import { ErrorBoundary } from '../../../../../../../../components/error-boundary' -import { ErrorDialog } from '../../../../../../../../components/error-dialog' -import { Icon } from '../../../../../../../../components/icon' +import { PhotoAttachmentImage } from '../-components/photo-attachment-image.tsx' +import { BLUE_GREY, GREEN, LIGHT_GREY } from '../../../../../../../../colors.ts' +import { DecentDialog } from '../../../../../../../../components/decent-dialog.tsx' +import { ErrorBoundary } from '../../../../../../../../components/error-boundary.tsx' +import { ErrorDialogContent } from '../../../../../../../../components/error-dialog.tsx' +import { Icon } from '../../../../../../../../components/icon.tsx' import { COMAPEO_CORE_REACT_ROOT_QUERY_KEY, COORDINATOR_ROLE_ID, CREATOR_ROLE_ID, -} from '../../../../../../../../lib/comapeo' -import { getLocaleStateQueryOptions } from '../../../../../../../../lib/queries/app-settings' -import { createGlobalMutationsKey } from '../../../../../../../../lib/queries/global-mutations' -import { downloadURLMutationOptions } from '../../../../../../../../lib/queries/system' +} from '../../../../../../../../lib/comapeo.ts' +import { getLocaleStateQueryOptions } from '../../../../../../../../lib/queries/app-settings.ts' +import { createGlobalMutationsKey } from '../../../../../../../../lib/queries/global-mutations.ts' +import { downloadURLMutationOptions } from '../../../../../../../../lib/queries/system.ts' // TODO: Support video type const BlobIdSchema = v.variant('type', [ @@ -530,13 +531,22 @@ function DeleteButton({ type={blobId.type} /> - { - deleteAttachment.reset() - }} - /> + + {(error) => ( + { + deleteAttachment.reset() + }} + /> + )} + ) } @@ -650,13 +660,20 @@ function DownloadButton({ {t(m.download)} - { - downloadUrl.reset() - }} - /> + + {(error) => ( + { + downloadUrl.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/index.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/index.tsx index b35ed1ac..6dbd7dee 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/index.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/observations/$observationDocId/index.tsx @@ -26,19 +26,20 @@ import { DARKER_ORANGE, GREEN, WHITE, -} from '../../../../../../../colors' +} from '../../../../../../../colors.ts' import { CategoryIconContainer, CategoryIconImage, -} from '../../../../../../../components/category-icon' -import { ErrorBoundary } from '../../../../../../../components/error-boundary' -import { ErrorDialog } from '../../../../../../../components/error-dialog' -import { GenericRouteNotFoundComponent } from '../../../../../../../components/generic-route-not-found-component' -import { Icon } from '../../../../../../../components/icon' +} from '../../../../../../../components/category-icon.tsx' +import { DecentDialog } from '../../../../../../../components/decent-dialog.tsx' +import { ErrorBoundary } from '../../../../../../../components/error-boundary.tsx' +import { ErrorDialogContent } from '../../../../../../../components/error-dialog.tsx' +import { GenericRouteNotFoundComponent } from '../../../../../../../components/generic-route-not-found-component.tsx' +import { Icon } from '../../../../../../../components/icon.tsx' import { useGlobalEditingState, useGlobalEditingStateActions, -} from '../../../../../../../contexts/global-editing-state-store-context' +} from '../../../../../../../contexts/global-editing-state-store-context.ts' import { COMAPEO_CORE_REACT_ROOT_QUERY_KEY, COORDINATOR_ROLE_ID, @@ -47,25 +48,31 @@ import { isAudioAttachment, isPhotoAttachment, type ObservationTagValue, -} from '../../../../../../../lib/comapeo' -import { formatCoords } from '../../../../../../../lib/coordinate-format' -import { customNotFound } from '../../../../../../../lib/navigation' +} from '../../../../../../../lib/comapeo.ts' +import { formatCoords } from '../../../../../../../lib/coordinate-format.ts' +import { customNotFound } from '../../../../../../../lib/navigation.ts' import { getCoordinateFormatQueryOptions, getLocaleStateQueryOptions, -} from '../../../../../../../lib/queries/app-settings' -import { createGlobalMutationsKey } from '../../../../../../../lib/queries/global-mutations' -import { EditCategoryPanel } from './-edit-category-panel' -import { EditableFieldSection, ReadOnlyFieldSection } from './-field-sections' -import { EditableNotesSection, ReadOnlyNotesSection } from './-notes-section' +} from '../../../../../../../lib/queries/app-settings.ts' +import { createGlobalMutationsKey } from '../../../../../../../lib/queries/global-mutations.ts' +import { EditCategoryPanel } from './-edit-category-panel.tsx' +import { + EditableFieldSection, + ReadOnlyFieldSection, +} from './-field-sections.tsx' +import { + EditableNotesSection, + ReadOnlyNotesSection, +} from './-notes-section.tsx' import { ObservationAttachmentError, ObservationAttachmentPending, ObservationAudioAttachmentPreview, ObservationPhotoAttachmentPreview, ObservationUnsupportedAttachmentPreview, -} from './-observation-attachment' -import { getDisplayedTagValue, type EditableField } from './-shared' +} from './-observation-attachment.tsx' +import { getDisplayedTagValue, type EditableField } from './-shared.ts' const SearchParamsSchema = v.object({ fromTrackDocId: v.optional(v.string()), @@ -990,13 +997,22 @@ function ObservationDetailsPanel({ ) : null} - { - deleteObservation.reset() - }} - /> + + {(error) => ( + { + deleteObservation.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/settings/categories.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/settings/categories.tsx index 50be0123..4a6ed879 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/settings/categories.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/settings/categories.tsx @@ -15,12 +15,13 @@ import { useMutation } from '@tanstack/react-query' import { createFileRoute, useRouter } from '@tanstack/react-router' import { defineMessages, useIntl } from 'react-intl' -import { BLUE_GREY, DARK_GREY, DARK_ORANGE } from '../../../../../../colors' -import { ErrorDialog } from '../../../../../../components/error-dialog' -import { Icon } from '../../../../../../components/icon' -import { COMAPEO_CORE_REACT_ROOT_QUERY_KEY } from '../../../../../../lib/comapeo' -import { selectFileMutationOptions } from '../../../../../../lib/queries/file-system' -import { createGlobalMutationsKey } from '../../../../../../lib/queries/global-mutations' +import { BLUE_GREY, DARK_GREY, DARK_ORANGE } from '../../../../../../colors.ts' +import { DecentDialog } from '../../../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../../../components/error-dialog.tsx' +import { Icon } from '../../../../../../components/icon.tsx' +import { COMAPEO_CORE_REACT_ROOT_QUERY_KEY } from '../../../../../../lib/comapeo.ts' +import { selectFileMutationOptions } from '../../../../../../lib/queries/file-system.ts' +import { createGlobalMutationsKey } from '../../../../../../lib/queries/global-mutations.ts' export const Route = createFileRoute( '/app/projects/$projectId/_main-tabs/settings/categories', @@ -259,13 +260,24 @@ function RouteComponent() { - { - selectAndImportMutation.reset() - }} - /> + + {(error) => ( + { + selectAndImportMutation.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/settings/info.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/settings/info.tsx index 46f29070..e1d950f3 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/settings/info.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/settings/info.tsx @@ -26,20 +26,21 @@ import { PROJECT_GREY, PROJECT_ORANGE, PROJECT_RED, -} from '../../../../../../colors' -import { ErrorDialog } from '../../../../../../components/error-dialog' -import { Icon } from '../../../../../../components/icon' -import { useAppForm } from '../../../../../../hooks/forms' -import { COMAPEO_CORE_REACT_ROOT_QUERY_KEY } from '../../../../../../lib/comapeo' +} from '../../../../../../colors.ts' +import { DecentDialog } from '../../../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../../../components/error-dialog.tsx' +import { Icon } from '../../../../../../components/icon.tsx' +import { useAppForm } from '../../../../../../hooks/forms.ts' +import { COMAPEO_CORE_REACT_ROOT_QUERY_KEY } from '../../../../../../lib/comapeo.ts' import { PROJECT_DESCRIPTION_MAX_LENGTH_GRAPHEMES, PROJECT_NAME_MAX_LENGTH_GRAPHEMES, -} from '../../../../../../lib/constants' +} from '../../../../../../lib/constants.ts' import { createProjectColorSchema, createProjectDescriptionSchema, createProjectNameSchema, -} from '../../../../../../lib/validators/project' +} from '../../../../../../lib/validators/project.ts' export const Route = createFileRoute( '/app/projects/$projectId/_main-tabs/settings/info', @@ -476,13 +477,24 @@ function RouteComponent() { - { - setProjectSettings.reset() - }} - /> + + {(error) => ( + { + setProjectSettings.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/team/invite/devices/$deviceId/send.tsx b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/team/invite/devices/$deviceId/send.tsx index b1c6b671..952ff4ed 100644 --- a/src/renderer/src/routes/app/projects/$projectId/_main-tabs/team/invite/devices/$deviceId/send.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/_main-tabs/team/invite/devices/$deviceId/send.tsx @@ -26,7 +26,8 @@ import { GREEN, WHITE, } from '../../../../../../../../../colors.ts' -import { ErrorDialog } from '../../../../../../../../../components/error-dialog.tsx' +import { DecentDialog } from '../../../../../../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../../../../../../components/error-dialog.tsx' import { GenericRoutePendingComponent } from '../../../../../../../../../components/generic-route-pending-component.tsx' import { Icon } from '../../../../../../../../../components/icon.tsx' import { ButtonLink } from '../../../../../../../../../components/link.tsx' @@ -75,14 +76,13 @@ function RouteComponent() { const { role } = Route.useSearch() - const sendInvite = useSendInvite({ projectId }) - - const invite = useMutation({ + const _sendInvite = useSendInvite({ projectId }) + const sendInvite = useMutation({ mutationKey: SEND_INVITE_GLOBAL_MUTATIONS_KEY, mutationFn: async ( - variables: Parameters<(typeof sendInvite)['mutateAsync']>[0], + variables: Parameters<(typeof _sendInvite)['mutateAsync']>[0], ) => { - return sendInvite.mutateAsync(variables) + return _sendInvite.mutateAsync(variables) }, }) @@ -112,36 +112,49 @@ function RouteComponent() { [deviceId, cancelInvite], ) - const deferredInviteStatus = useDeferredValue(invite.status) + const deferredInviteStatus = useDeferredValue(sendInvite.status) if (deferredInviteStatus === 'idle' || deferredInviteStatus === 'error') { return ( - { - invite.reset() - }} - onSendInvite={() => { - invite.mutate({ - deviceId, - roleId: - role === 'coordinator' ? COORDINATOR_ROLE_ID : MEMBER_ROLE_ID, - }) - }} - /> + <> + { + sendInvite.mutate({ + deviceId, + roleId: + role === 'coordinator' ? COORDINATOR_ROLE_ID : MEMBER_ROLE_ID, + }) + }} + /> + + + {(error) => ( + { + sendInvite.reset() + }} + /> + )} + + ) } if (deferredInviteStatus === 'pending') { return ( { cancelInvite.mutate( { deviceId }, { onSettled: () => { - invite.reset() + sendInvite.reset() }, }, ) @@ -150,11 +163,11 @@ function RouteComponent() { ) } - switch (invite.data) { + switch (sendInvite.data) { case 'REJECT': { return ( ) @@ -164,7 +177,7 @@ function RouteComponent() { return ( }> @@ -183,15 +196,7 @@ function RouteComponent() { } } -function ReviewInvitation({ - error, - onDismissError, - onSendInvite, -}: { - error: Error | null - onDismissError: () => void - onSendInvite: () => void -}) { +function ReviewInvitation({ onSendInvite }: { onSendInvite: () => void }) { const { formatMessage: t } = useIntl() const router = useRouter() @@ -209,115 +214,105 @@ function ReviewInvitation({ const peer = updatedPeer || peerOnLoad return ( - <> - - + + { + router.navigate({ + to: '/app/projects/$projectId/team/invite/devices/$deviceId/role', + params: { projectId, deviceId }, + replace: true, + }) + }} > - { - router.navigate({ - to: '/app/projects/$projectId/team/invite/devices/$deviceId/role', - params: { projectId, deviceId }, - replace: true, - }) - }} + + + + + {t(m.navTitle)} + + + + + + - - + - - {t(m.navTitle)} - - + {peer.status === 'disconnected' ? : null} - - - - - - {peer.status === 'disconnected' ? ( - - ) : null} - - - {t(m.deviceBeingInvited, { - name: ( - theme.typography.h1.fontSize} - fontWeight={500} - > - {peer.name} - - ), - role: ( - theme.typography.h2.fontSize} - fontWeight={500} - > - {role === 'coordinator' - ? t(m.coordinator) - : t(m.participant)} - - ), - })} - - - + + {t(m.deviceBeingInvited, { + name: ( + theme.typography.h1.fontSize} + fontWeight={500} + > + {peer.name} + + ), + role: ( + theme.typography.h2.fontSize} + fontWeight={500} + > + {role === 'coordinator' + ? t(m.coordinator) + : t(m.participant)} + + ), + })} + + + - + - - + {t(m.sendInvite)} + + - - - + ) } diff --git a/src/renderer/src/routes/app/projects/$projectId/test-data.tsx b/src/renderer/src/routes/app/projects/$projectId/test-data.tsx index 23c4d04e..d369d1b4 100644 --- a/src/renderer/src/routes/app/projects/$projectId/test-data.tsx +++ b/src/renderer/src/routes/app/projects/$projectId/test-data.tsx @@ -29,10 +29,8 @@ import * as v from 'valibot' import { TwoPanelLayout } from '../../-components/two-panel-layout.tsx' import { BLACK, BLUE_GREY } from '../../../../colors.ts' -import { - ErrorDialog, - type Props as ErrorDialogProps, -} from '../../../../components/error-dialog.tsx' +import { DecentDialog } from '../../../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../../../components/error-dialog.tsx' import { GenericRoutePendingComponent } from '../../../../components/generic-route-pending-component.tsx' import { Map } from '../../../../components/map.tsx' import { useAppForm } from '../../../../hooks/forms.ts' @@ -214,25 +212,6 @@ function RouteComponent() { }) }, [boundedDistance, coordinates]) - const errorDialogProps: ErrorDialogProps = - createTestObservations.status === 'error' - ? { - errorMessage: createTestObservations.error.toString(), - onClose: () => { - createTestObservations.reset() - }, - open: true, - } - : createTestTrack.status === 'error' - ? { - open: true, - errorMessage: createTestTrack.error.toString(), - onClose: () => { - createTestTrack.reset() - }, - } - : { open: false, onClose: () => {} } - return ( <> - + { + createTestObservations.reset() + }, + } + : createTestTrack.status === 'error' + ? { + errorMessage: createTestTrack.error.toString(), + onClose: () => { + createTestTrack.reset() + }, + } + : null + } + > + {({ errorMessage, onClose }) => ( + + )} + ) } diff --git a/src/renderer/src/routes/onboarding/device-name.tsx b/src/renderer/src/routes/onboarding/device-name.tsx index f243d372..5ecaa4d9 100644 --- a/src/renderer/src/routes/onboarding/device-name.tsx +++ b/src/renderer/src/routes/onboarding/device-name.tsx @@ -12,7 +12,8 @@ import { defineMessages, useIntl } from 'react-intl' import * as v from 'valibot' import { DARKER_ORANGE, LIGHT_GREY, WHITE } from '../../colors.ts' -import { ErrorDialog } from '../../components/error-dialog.tsx' +import { DecentDialog } from '../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../components/error-dialog.tsx' import { Icon } from '../../components/icon.tsx' import { useAppForm } from '../../hooks/forms.ts' import { COMAPEO_CORE_REACT_ROOT_QUERY_KEY } from '../../lib/comapeo.ts' @@ -205,13 +206,22 @@ function RouteComponent() { - { - setOwnDeviceInfo.reset() - }} - /> + + {(error) => ( + { + setOwnDeviceInfo.reset() + }} + /> + )} + ) } diff --git a/src/renderer/src/routes/onboarding/privacy-policy.tsx b/src/renderer/src/routes/onboarding/privacy-policy.tsx index 9dd760c2..e73c7112 100644 --- a/src/renderer/src/routes/onboarding/privacy-policy.tsx +++ b/src/renderer/src/routes/onboarding/privacy-policy.tsx @@ -16,13 +16,14 @@ import { useMutation, useSuspenseQuery } from '@tanstack/react-query' import { createFileRoute } from '@tanstack/react-router' import { defineMessages, useIntl } from 'react-intl' -import { BLUE_GREY, DARK_GREY, LIGHT_GREY } from '../../colors' -import { ErrorDialog } from '../../components/error-dialog' -import { Icon } from '../../components/icon' +import { BLUE_GREY, DARK_GREY, LIGHT_GREY } from '../../colors.ts' +import { DecentDialog } from '../../components/decent-dialog.tsx' +import { ErrorDialogContent } from '../../components/error-dialog.tsx' +import { Icon } from '../../components/icon.tsx' import { getDiagnosticsEnabledQueryOptions, setDiagnosticsEnabledMutationOptions, -} from '../../lib/queries/app-settings' +} from '../../lib/queries/app-settings.ts' export const Route = createFileRoute('/onboarding/privacy-policy')({ loader: async ({ context }) => { @@ -238,13 +239,24 @@ function RouteComponent() { - { - setDiagnosticsEnabledMutation.reset() - }} - /> + + {(error) => ( + { + setDiagnosticsEnabledMutation.reset() + }} + /> + )} + ) }