Skip to content

Commit

Permalink
feat: improve modal consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmith123 committed Feb 5, 2025
1 parent 42871d6 commit d8db3a0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
4 changes: 3 additions & 1 deletion apps/router/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@
"helper-text": "Will be wss:// for guardian or https:// for gateway",
"service-type-label": "Service Type",
"service-name-label": "Service Name",
"sync-status-label": "Sync Status"
"sync-status-label": "Sync Status",
"service-exists-error": "Service already exists",
"no-gateways-error": "Only Guardians can be added right now"
},
"remove-service-modal": {
"title": "Remove {{type}}",
Expand Down
23 changes: 14 additions & 9 deletions apps/router/src/modals/ConnectServiceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ModalContent,
ModalHeader,
ModalOverlay,
ModalFooter,
Text,
Badge,
Flex,
Expand Down Expand Up @@ -54,7 +55,7 @@ export const ConnectServiceModal: React.FC<ConnectServiceModalProps> = ({
try {
const exists = await checkServiceExists(configUrl);
if (exists) {
throw new Error('Service already exists');
throw new Error(t('home.connect-service-modal.service-exists-error'));
}

const id = await sha256Hash(configUrl);
Expand All @@ -69,10 +70,13 @@ export const ConnectServiceModal: React.FC<ConnectServiceModalProps> = ({
payload: { id, guardian: { config: { id, baseUrl: configUrl } } },
});
} else {
dispatch({
type: APP_ACTION_TYPE.ADD_GATEWAY,
payload: { id, gateway: { config: { id, baseUrl: configUrl } } },
});
// When Gateway UI is production ready, the dispatch can be reinstated
throw new Error(t('home.connect-service-modal.no-gateways-error'));

// dispatch({
// type: APP_ACTION_TYPE.ADD_GATEWAY,
// payload: { id, gateway: { config: { id, baseUrl: configUrl } } },
// });
}

resetForm();
Expand All @@ -84,7 +88,7 @@ export const ConnectServiceModal: React.FC<ConnectServiceModalProps> = ({
} finally {
setIsLoading(false);
}
}, [configUrl, dispatch, resetForm, onClose, checkServiceExists]);
}, [configUrl, dispatch, resetForm, onClose, checkServiceExists, t]);

return (
<Modal
Expand All @@ -101,7 +105,7 @@ export const ConnectServiceModal: React.FC<ConnectServiceModalProps> = ({
{t('home.connect-service-modal.title', 'Connect a Service')}
</ModalHeader>
<ModalCloseButton />
<ModalBody pb={6}>
<ModalBody>
{error && (
<Text color='red.500' mb={4}>
{error}
Expand All @@ -120,15 +124,16 @@ export const ConnectServiceModal: React.FC<ConnectServiceModalProps> = ({
}}
/>
</FormControl>
</ModalBody>
<ModalFooter>
<Button
mt={4}
colorScheme='blue'
onClick={handleConfirm}
isLoading={isLoading}
>
{t('common.confirm')}
</Button>
</ModalBody>
</ModalFooter>
</ModalContent>
</Modal>
);
Expand Down
9 changes: 6 additions & 3 deletions apps/router/src/modals/EditServiceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ModalContent,
ModalHeader,
ModalOverlay,
ModalFooter,
useToast,
} from '@chakra-ui/react';
import { sha256Hash, useTranslation } from '@fedimint/utils';
Expand Down Expand Up @@ -103,18 +104,20 @@ export const EditServiceModal: React.FC<EditServiceModalProps> = ({
})}
</ModalHeader>
<ModalCloseButton />
<ModalBody pb={6}>
<ModalBody>
<FormControl>
<FormLabel>{t('home.edit-service-modal.url-label')}</FormLabel>
<Input
value={configUrl}
onChange={(e) => setConfigUrl(e.target.value)}
/>
</FormControl>
<Button mt={4} colorScheme='blue' onClick={handleSubmit}>
</ModalBody>
<ModalFooter>
<Button colorScheme='blue' onClick={handleSubmit}>
{t('common.save')}
</Button>
</ModalBody>
</ModalFooter>
</ModalContent>
</Modal>
);
Expand Down

0 comments on commit d8db3a0

Please sign in to comment.