From 3c4dbed16b12ac89e3caf62d2709b5191604887e Mon Sep 17 00:00:00 2001 From: Cats Juice Date: Mon, 6 Nov 2023 10:40:52 +0800 Subject: [PATCH] fix(core): payment UI fix (#4839) --- .../components/notification-center/icons.tsx | 23 +++++++++++++++++++ .../components/notification-center/index.tsx | 9 +++++++- .../general-setting/plans/index.tsx | 1 + .../general-setting/plans/plan-card.tsx | 12 ++++++++-- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 packages/frontend/component/src/components/notification-center/icons.tsx diff --git a/packages/frontend/component/src/components/notification-center/icons.tsx b/packages/frontend/component/src/components/notification-center/icons.tsx new file mode 100644 index 000000000..f2e1da732 --- /dev/null +++ b/packages/frontend/component/src/components/notification-center/icons.tsx @@ -0,0 +1,23 @@ +import type { SVGProps } from 'react'; + +export const SuccessIcon = ({ + width = 24, + height = 24, +}: SVGProps) => { + return ( + + + + ); +}; diff --git a/packages/frontend/component/src/components/notification-center/index.tsx b/packages/frontend/component/src/components/notification-center/index.tsx index 3a1c79db2..b83903c02 100644 --- a/packages/frontend/component/src/components/notification-center/index.tsx +++ b/packages/frontend/component/src/components/notification-center/index.tsx @@ -17,6 +17,7 @@ import { useState, } from 'react'; +import { SuccessIcon } from './icons'; import * as styles from './index.css'; import type { Notification } from './index.jotai'; import { @@ -47,21 +48,25 @@ const typeColorMap = { light: styles.lightInfoStyle, dark: styles.darkInfoStyle, default: '', + icon: , }, success: { light: styles.lightSuccessStyle, dark: styles.darkSuccessStyle, default: '', + icon: , }, warning: { light: styles.lightWarningStyle, dark: styles.darkWarningStyle, default: '', + icon: , }, error: { light: styles.lightErrorStyle, dark: styles.darkErrorStyle, default: '', + icon: , }, }; @@ -286,7 +291,9 @@ function NotificationCard(props: NotificationCardProps): ReactElement { [styles.lightInfoIconStyle]: notification.theme === 'light', })} > - + {typeColorMap[notification.type]?.icon ?? ( + + )}
{notification.title} diff --git a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/index.tsx b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/index.tsx index 1a1f0e8b6..58c5d6dfc 100644 --- a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/index.tsx +++ b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/index.tsx @@ -163,6 +163,7 @@ const Settings = () => { onNotify={({ detail, recurring }) => { pushNotification({ type: 'success', + theme: 'default', title: t['com.affine.payment.updated-notify-title'](), message: detail.plan === SubscriptionPlan.Free diff --git a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/plan-card.tsx b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/plan-card.tsx index 737fdb9f0..359aeb3da 100644 --- a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/plan-card.tsx +++ b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/plan-card.tsx @@ -6,6 +6,7 @@ import { checkoutMutation, SubscriptionPlan, SubscriptionRecurring, + SubscriptionStatus, updateSubscriptionMutation, } from '@affine/graphql'; import { Trans } from '@affine/i18n'; @@ -243,7 +244,10 @@ const ActionButton = ({ const isFree = detail.plan === SubscriptionPlan.Free; const isCurrent = detail.plan === currentPlan && - (isFree ? true : currentRecurring === recurring); + (isFree + ? true + : currentRecurring === recurring && + subscription?.status === SubscriptionStatus.Active); // is current if (isCurrent) { @@ -455,7 +459,11 @@ const ChangeRecurring = ({ You are changing your {from}{' '} subscription to {to}{' '} subscription. This change will take effect in the next billing cycle, with - an effective date of {due}. + an effective date of{' '} + + {new Date(due).toLocaleDateString()} + + . );