0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

refactor(console): get real time email service usage (#4258)

This commit is contained in:
Darcy Ye 2023-07-31 17:35:29 +08:00 committed by GitHub
parent 8a0725938c
commit 2e4cd0b817
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 6 deletions

View file

@ -116,7 +116,7 @@ function ConnectorContent({ isDeleted, connectorData, onConnectorUpdated }: Prop
if (connectorData.usage === undefined) { if (connectorData.usage === undefined) {
return; return;
} }
onConnectorUpdated({ ...connectorData, usage: connectorData.usage + 1 }); onConnectorUpdated();
}, [connectorData, onConnectorUpdated]); }, [connectorData, onConnectorUpdated]);
return ( return (

View file

@ -16,6 +16,7 @@ import * as styles from './index.module.scss';
type Props = { type Props = {
usage: number; usage: number;
}; };
function EmailUsage({ usage }: Props) { function EmailUsage({ usage }: Props) {
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });

View file

@ -51,12 +51,9 @@ function ConnectorDetails() {
const [isReadMeOpen, setIsReadMeOpen] = useState(false); const [isReadMeOpen, setIsReadMeOpen] = useState(false);
const [isSetupOpen, setIsSetupOpen] = useState(false); const [isSetupOpen, setIsSetupOpen] = useState(false);
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
/**
* TODO: Can add `keepPreviousData` option to useSWR to avoid the flash on `Skeleton`
* component when manually trigger `mutate` function. This change is available in `swr@v2.0` or above.
*/
const { data, error, mutate } = useSWR<ConnectorResponse, RequestError>( const { data, error, mutate } = useSWR<ConnectorResponse, RequestError>(
connectorId && `api/connectors/${connectorId}` connectorId && `api/connectors/${connectorId}`,
{ keepPreviousData: true }
); );
const { const {
data: connectorFactory, data: connectorFactory,