notistack#VariantType TypeScript Examples
The following examples show how to use
notistack#VariantType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: notify.tsx From wallet-adapter with Apache License 2.0 | 6 votes |
export function useNotify() {
const { enqueueSnackbar } = useSnackbar();
return useCallback(
(variant: VariantType, message: string, signature?: string) => {
enqueueSnackbar(
<Notification>
{message}
{signature && (
<StyledLink href={`https://explorer.solana.com/tx/${signature}?cluster=devnet`} target="_blank">
Transaction
<StyledLaunchIcon />
</StyledLink>
)}
</Notification>,
{ variant }
);
},
[enqueueSnackbar]
);
}
Example #2
Source File: SubscriptionStatusNotifier.tsx From clearflask with Apache License 2.0 | 5 votes |
SubscriptionStatusNotifier = (props: {
account: Admin.AccountAdmin
}) => {
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const history = useHistory();
if (lastShown === props.account.subscriptionStatus) return null;
lastShown = props.account.subscriptionStatus;
closeSnackbar(lastKey);
var persist: boolean = true;
var variant: VariantType = 'info';
var content: string | undefined;
var billingButtonTitle = 'Billing';
switch (props.account.subscriptionStatus) {
case Admin.SubscriptionStatus.Active:
case Admin.SubscriptionStatus.ActiveTrial:
break;
case Admin.SubscriptionStatus.ActivePaymentRetry:
variant = 'warning';
content = 'We cannot process your payment';
break;
case Admin.SubscriptionStatus.ActiveNoRenewal:
variant = 'warning';
content = 'Your account will soon expire';
persist = false;
break;
case Admin.SubscriptionStatus.Limited:
variant = 'warning';
content = 'You have reached your plan limit, please delete some posts';
billingButtonTitle = 'Check again';
break;
case Admin.SubscriptionStatus.NoPaymentMethod:
variant = 'warning';
content = 'Please add a payment method';
billingButtonTitle = 'Add';
break;
case Admin.SubscriptionStatus.Blocked:
variant = 'error';
content = 'Your account is blocked, contact support';
break;
case Admin.SubscriptionStatus.Cancelled:
variant = 'error';
content = 'Your account is cancelled, update your billing to continue';
break;
}
if (content) {
lastKey = enqueueSnackbar(content, {
variant,
preventDuplicate: true,
persist,
action: (key) => (
<Button
color='inherit'
onClick={async () => {
await ServerAdmin.get().getStore().dispatch({ type: 'billingClear' });
history.push('/dashboard/settings/account/billing');
!persist && closeSnackbar(key);
}}
>{billingButtonTitle}</Button>
),
});
}
return null;
}