Files
pybricks-code/src/ble/alerts/MissingService.tsx
T
David Lechner fa27649fe3 toasterTypes: change toaster to ref
Instead of rendering the toaster separate from the main index, add it
there so we can inherit all of the context providers. This requires
passing the ref object instead of the toaster instance itself, so
sagas have to be updated.
2022-10-19 18:26:37 -05:00

36 lines
987 B
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
import { Intent } from '@blueprintjs/core';
import React from 'react';
import type { CreateToast } from '../../toasterTypes';
import { useI18n } from './i18n';
type MissingServiceProps = {
serviceName: string;
hubName: string;
};
const MissingService: React.VoidFunctionComponent<MissingServiceProps> = ({
serviceName,
hubName,
}) => {
const i18n = useI18n();
return (
<>
<p>{i18n.translate('missingService.message', { serviceName })}</p>
<p>{i18n.translate('missingService.suggestion1')}</p>
<p>{i18n.translate('missingService.suggestion2', { hubName })}</p>
</>
);
};
export const missingService: CreateToast<MissingServiceProps> = (onAction, props) => {
return {
message: <MissingService {...props} />,
icon: 'error',
intent: Intent.DANGER,
onDismiss: () => onAction('dismiss'),
};
};