Skip to content

Commit

Permalink
Merge pull request #4394 from thematters/feat/revise-set-payment-pass…
Browse files Browse the repository at this point in the history
…word

Feat/revise set payment password
  • Loading branch information
wlliaml authored May 17, 2024
2 parents 74f0ef0 + a9b507b commit 70b45f0
Show file tree
Hide file tree
Showing 18 changed files with 115 additions and 232 deletions.
13 changes: 3 additions & 10 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@
"defaultMessage": "Balance:",
"description": "src/components/Balance/index.tsx"
},
"1WeErK": {
"defaultMessage": "Welcome to use your wallet! {br} Please set a transaction password first",
"description": "src/components/Forms/PaymentForm/SetPassword/index.tsx"
},
"1Z1M77": {
"defaultMessage": "No data yet",
"description": "src/views/Me/History/index.tsx"
Expand Down Expand Up @@ -2108,9 +2104,6 @@
"beLe/F": {
"defaultMessage": "Broadcast"
},
"bhehIF": {
"defaultMessage": "To protect your assets,"
},
"c/z318": {
"defaultMessage": "Incorrect email or password",
"description": "src/components/Forms/EmailLoginForm/index.tsx"
Expand Down Expand Up @@ -2282,6 +2275,9 @@
"fKkBPz": {
"defaultMessage": "Support Again"
},
"fLvbqA": {
"defaultMessage": "To protect the security of your assets, please set a six-digit transaction password first."
},
"fPcF7H": {
"defaultMessage": "Adding tags helps readers find your articles."
},
Expand Down Expand Up @@ -3200,9 +3196,6 @@
"yBUiiy": {
"defaultMessage": "This operation cannot be undone, confirm archiving?"
},
"yBkdMI": {
"defaultMessage": "please set transaction password before top-up"
},
"yCTXXb": {
"defaultMessage": "Enter content…"
},
Expand Down
13 changes: 3 additions & 10 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@
"defaultMessage": "Balance:",
"description": "src/components/Balance/index.tsx"
},
"1WeErK": {
"defaultMessage": "Welcome to use your wallet! {br} Please set a transaction password first",
"description": "src/components/Forms/PaymentForm/SetPassword/index.tsx"
},
"1Z1M77": {
"defaultMessage": "No data yet",
"description": "src/views/Me/History/index.tsx"
Expand Down Expand Up @@ -2108,9 +2104,6 @@
"beLe/F": {
"defaultMessage": "Broadcast"
},
"bhehIF": {
"defaultMessage": "To protect your assets,"
},
"c/z318": {
"defaultMessage": "Incorrect email or password",
"description": "src/components/Forms/EmailLoginForm/index.tsx"
Expand Down Expand Up @@ -2282,6 +2275,9 @@
"fKkBPz": {
"defaultMessage": "Support Again"
},
"fLvbqA": {
"defaultMessage": "To protect the security of your assets, please set a six-digit transaction password first."
},
"fPcF7H": {
"defaultMessage": "Adding tags helps readers find your articles."
},
Expand Down Expand Up @@ -3200,9 +3196,6 @@
"yBUiiy": {
"defaultMessage": "This operation cannot be undone, confirm archiving?"
},
"yBkdMI": {
"defaultMessage": "please set transaction password before top-up"
},
"yCTXXb": {
"defaultMessage": "Enter content…"
},
Expand Down
15 changes: 4 additions & 11 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@
"defaultMessage": "余额:",
"description": "src/components/Balance/index.tsx"
},
"1WeErK": {
"defaultMessage": "欢迎使用钱包!请先设置交易密码",
"description": "src/components/Forms/PaymentForm/SetPassword/index.tsx"
},
"1Z1M77": {
"defaultMessage": "尚无阅读记录",
"description": "src/views/Me/History/index.tsx"
Expand Down Expand Up @@ -647,7 +643,7 @@
"description": "src/views/ArticleDetail/Comments/LatestComments/index.tsx"
},
"9UNFGm": {
"defaultMessage": "交易密码"
"defaultMessage": "设置交易密码"
},
"9Vkz9W": {
"defaultMessage": "图片面积不得超过 1 亿像素(如 10,000 x 10,000 像素)"
Expand Down Expand Up @@ -2108,9 +2104,6 @@
"beLe/F": {
"defaultMessage": "广播"
},
"bhehIF": {
"defaultMessage": "为了保护你的资产安全"
},
"c/z318": {
"defaultMessage": "邮箱或密码错误",
"description": "src/components/Forms/EmailLoginForm/index.tsx"
Expand Down Expand Up @@ -2282,6 +2275,9 @@
"fKkBPz": {
"defaultMessage": "再次支持"
},
"fLvbqA": {
"defaultMessage": "为了保护你的资产安全,请先设置六位数字交易密码"
},
"fPcF7H": {
"defaultMessage": "添加适合标签,帮助读者找到你的作品"
},
Expand Down Expand Up @@ -3200,9 +3196,6 @@
"yBUiiy": {
"defaultMessage": "操作无法撤销,确认归档吗?"
},
"yBkdMI": {
"defaultMessage": "在储值前请先设置交易密码"
},
"yCTXXb": {
"defaultMessage": "请输入正文…"
},
Expand Down
15 changes: 4 additions & 11 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@
"defaultMessage": "餘額:",
"description": "src/components/Balance/index.tsx"
},
"1WeErK": {
"defaultMessage": "歡迎使用錢包!請先設置交易密碼",
"description": "src/components/Forms/PaymentForm/SetPassword/index.tsx"
},
"1Z1M77": {
"defaultMessage": "尚無閱讀紀錄",
"description": "src/views/Me/History/index.tsx"
Expand Down Expand Up @@ -647,7 +643,7 @@
"description": "src/views/ArticleDetail/Comments/LatestComments/index.tsx"
},
"9UNFGm": {
"defaultMessage": "交易密碼"
"defaultMessage": "設置交易密碼"
},
"9Vkz9W": {
"defaultMessage": "圖片面積不得超過 1 億像素(如 10,000x10,000 像素)"
Expand Down Expand Up @@ -2108,9 +2104,6 @@
"beLe/F": {
"defaultMessage": "廣播"
},
"bhehIF": {
"defaultMessage": "爲了保護你的資產安全"
},
"c/z318": {
"defaultMessage": "郵件地址或密碼錯誤",
"description": "src/components/Forms/EmailLoginForm/index.tsx"
Expand Down Expand Up @@ -2282,6 +2275,9 @@
"fKkBPz": {
"defaultMessage": "再次支持"
},
"fLvbqA": {
"defaultMessage": "為了保護你的資產安全,請先設置六位數字交易密碼"
},
"fPcF7H": {
"defaultMessage": "添加合適標籤,讓站內外讀者找到你的作品"
},
Expand Down Expand Up @@ -3200,9 +3196,6 @@
"yBUiiy": {
"defaultMessage": "操作無法撤銷,確認封存嗎?"
},
"yBkdMI": {
"defaultMessage": "在儲值前請先設置交易密碼"
},
"yCTXXb": {
"defaultMessage": "請輸入正文…"
},
Expand Down
27 changes: 27 additions & 0 deletions src/components/Context/PaymentPassword/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createContext, useState } from 'react'

export const PaymentPasswordContext = createContext(
{} as {
hasPaymentPassword: boolean
setHasPaymentPassword: (hasPaymentPassword: boolean) => void
}
)

export const PaymentPasswordProvider = ({
children,
hasPaymentPassword: _hasPaymentPassword,
}: {
children: React.ReactNode
hasPaymentPassword: boolean
}) => {
const [hasPaymentPassword, setHasPaymentPassword] =
useState(_hasPaymentPassword)

return (
<PaymentPasswordContext.Provider
value={{ hasPaymentPassword, setHasPaymentPassword }}
>
{children}
</PaymentPasswordContext.Provider>
)
}
1 change: 1 addition & 0 deletions src/components/Context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from './CommentDrafts'
export * from './DraftDetailState'
export * from './Features'
export * from './Language'
export * from './PaymentPassword'
export * from './Viewer'
8 changes: 3 additions & 5 deletions src/components/Dialogs/AddCreditDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { useContext, useEffect } from 'react'
import { analytics } from '~/common/utils'
import {
Dialog,
PaymentPasswordContext,
SpinnerBlock,
useDialogSwitch,
useStep,
ViewerContext,
} from '~/components'

type Step = 'setPaymentPassword' | 'addCredit'
Expand All @@ -27,16 +27,14 @@ const DynamicAddCreditForm = dynamic(
)

const BaseAddCreditDialog = ({ children }: AddCreditDialogProps) => {
const viewer = useContext(ViewerContext)
const { hasPaymentPassword } = useContext(PaymentPasswordContext)
const {
show,
openDialog: baseOpenDialog,
closeDialog,
} = useDialogSwitch(true)

const initialStep = viewer.status?.hasPaymentPassword
? 'addCredit'
: 'setPaymentPassword'
const initialStep = hasPaymentPassword ? 'addCredit' : 'setPaymentPassword'
const { currStep, forward } = useStep<Step>(initialStep)

const openDialog = () => {
Expand Down
18 changes: 3 additions & 15 deletions src/components/Dialogs/SetPaymentPasswordDialog/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,12 @@ const SetPaymentPasswordContent: React.FC<FormProps> = ({
const isInComparedPassword = currStep === 'comparedPassword'

const header = (
<section className={styles.reason}>
<section className={styles.hint}>
{isInPassword && (
<p>
<FormattedMessage
defaultMessage="To protect your assets,"
id="bhehIF"
/>
<br />
<FormattedMessage
defaultMessage="please set transaction password before top-up"
id="yBkdMI"
defaultMessage="To protect the security of your assets, please set a six-digit transaction password first."
id="fLvbqA"
/>
</p>
)}
Expand All @@ -51,13 +46,6 @@ const SetPaymentPasswordContent: React.FC<FormProps> = ({
/>
</p>
)}

<p className={styles.hint}>
<FormattedMessage
defaultMessage="Enter a 6-digit payment password."
id="OpeFTV"
/>
</p>
</section>
)

Expand Down
16 changes: 4 additions & 12 deletions src/components/Dialogs/SetPaymentPasswordDialog/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
.reason {
padding: var(--sp24) 0;
margin: 0 var(--sp16);
font-size: var(--text16);
font-weight: var(--font-bold);
line-height: 1.5rem;
text-align: center;
}

.hint {
margin-top: var(--sp8);
margin-bottom: var(--sp24);
font-size: var(--text14);
font-weight: var(--font-normal);
color: var(--color-grey);
line-height: 1.375rem;
color: var(--color-grey-darker);
text-align: left;
}
6 changes: 3 additions & 3 deletions src/components/Dialogs/SubscribeCircleDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { OPEN_SUBSCRIBE_CIRCLE_DIALOG } from '~/common/enums'
import { analytics } from '~/common/utils'
import {
Dialog,
PaymentPasswordContext,
SpinnerBlock,
useDialogSwitch,
useEventListener,
useStep,
ViewerContext,
} from '~/components'

import { fragments } from './gql'
Expand All @@ -27,14 +27,14 @@ const BaseSubscribeCircleDialog = ({
children,
...restProps
}: SubscribeCircleDialogProps) => {
const viewer = useContext(ViewerContext)
const { hasPaymentPassword } = useContext(PaymentPasswordContext)
const {
show,
openDialog: baseOpenDialog,
closeDialog,
} = useDialogSwitch(true)

const initialStep = viewer.status?.hasPaymentPassword
const initialStep = hasPaymentPassword
? 'subscribeCircle'
: 'setPaymentPassword'
const { currStep, forward, prevStep, back } = useStep<Step>(initialStep)
Expand Down
1 change: 0 additions & 1 deletion src/components/Form/PinInput/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@mixin flex-center-all;

width: 100%;
padding: 0 var(--sp16);
margin: 0 auto;

& .pinInputItem {
Expand Down
Loading

0 comments on commit 70b45f0

Please sign in to comment.