-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhaojingjing
committed
Apr 9, 2024
1 parent
f248741
commit 2631fe8
Showing
11 changed files
with
289 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
packages/guard-core-v4/src/Invitation/Application/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
import { React } from 'shim-react' | ||
import { | ||
useGuardEvents, | ||
useGuardFinallyConfig, | ||
useGuardHttpClient, | ||
useGuardInitData, | ||
useGuardModule, | ||
useGuardPublicConfig | ||
} from '../../_utils/context' | ||
import { Form, Input, Select, DatePicker, message } from 'shim-antd' | ||
|
||
import { ChangeLanguage } from '../../ChangeLanguage' | ||
import SubmitButton from '../../SubmitButton' | ||
import { useTranslation } from 'react-i18next' | ||
import CustomFormItem from '../../ValidatorRules' | ||
import { InputInternationPhone } from '../../Login/core/withVerifyCode/InputInternationPhone' | ||
import { InputNumber } from '../../InputNumber' | ||
import { IconFont } from '../../IconFont' | ||
import { useMediaSize } from '../../_utils/hooks' | ||
import './style.less' | ||
import { fieldRequiredRule, i18n, useGuardHttp } from '../../_utils' | ||
import { SendCodeByEmail } from '../../SendCode/SendCodeByEmail' | ||
import { EmailScene } from '../../Type' | ||
import { GuardModuleType } from '../../Guard' | ||
|
||
const { useRef, useState, useCallback, useEffect } = React | ||
|
||
export const GuardApplicationView = () => { | ||
const { t } = useTranslation() | ||
|
||
const config = useGuardFinallyConfig() | ||
const events = useGuardEvents() | ||
const initData = useGuardInitData<{ identifier: string }>() | ||
|
||
const { changeModule } = useGuardModule() | ||
|
||
const publicConfig = useGuardPublicConfig() | ||
|
||
const { get, post } = useGuardHttp() | ||
|
||
const [form] = Form.useForm() | ||
|
||
let submitButtonRef = useRef<any>(null) | ||
|
||
const verifyCodeLength = publicConfig?.verifyCodeLength | ||
|
||
const [inviter, setInviter] = useState('') | ||
|
||
const getConfig = useCallback(async () => { | ||
const { data } = await get( | ||
`/api/v3/get-universal-invitation-public-config?identifier=${initData?.identifier}` | ||
) | ||
setInviter(data.inviter.displayName) | ||
}, [initData]) | ||
|
||
useEffect(() => { | ||
getConfig() | ||
}, [getConfig]) | ||
|
||
const onFinishHandle = async () => { | ||
try { | ||
submitButtonRef.current?.onSpin(true) | ||
// await post('/aa', { ...form.getFieldsValue() }) | ||
changeModule?.(GuardModuleType.MESSAGE, { | ||
message: | ||
'你已完成加入「北京奥星科技有限公司」的申请。<br />请等待管理员审批通过后,你将收到邮件,敬请留意。' | ||
}) | ||
} catch (error) { | ||
} finally { | ||
submitButtonRef.current?.onSpin(false) | ||
} | ||
} | ||
|
||
return ( | ||
<div className="g2-view-container g2-view-invitation-apply"> | ||
<div className="g2-view-container-inner"> | ||
<div className="g2-view-header"> | ||
<img src={config?.logo} alt="" className="icon" /> | ||
<div className="g2-view-header-container"> | ||
<div className="invitation-welcome"> | ||
{inviter} {t('common.welcomeJoin')} | ||
</div> | ||
<div className="title">{config?.title}</div> | ||
</div> | ||
</div> | ||
|
||
<div className="g2-view-content"> | ||
<Form | ||
layout="vertical" | ||
name="et-pre-check-email" | ||
onFinish={onFinishHandle} | ||
onFinishFailed={() => submitButtonRef.current.onError()} | ||
autoComplete="off" | ||
form={form} | ||
className="authing-g2-form-required-item-icon-after" | ||
// onValuesChange={formValuesChange} | ||
> | ||
<Form.Item | ||
name="name" | ||
label={t('common.name')} | ||
rules={[{ required: true }]} | ||
className="authing-g2-input-form" | ||
> | ||
<Input | ||
type="text" | ||
size="large" | ||
className="authing-g2-input" | ||
autoComplete="off" | ||
/> | ||
</Form.Item> | ||
<CustomFormItem.Email | ||
className="authing-g2-input-form" | ||
name="email" | ||
checkRepeat={true} | ||
label={i18n.t('common.email')} | ||
key="internal email:email13" | ||
validateFirst={true} | ||
required | ||
> | ||
<Input | ||
className="authing-g2-input" | ||
autoComplete="email" | ||
size="large" | ||
placeholder={t('login.inputEmail') as string} | ||
/> | ||
</CustomFormItem.Email> | ||
<Form.Item | ||
validateTrigger={['onBlur', 'onChange']} | ||
className="authing-g2-input-form" | ||
name="emailCode" | ||
key="internal email:code1432" | ||
rules={fieldRequiredRule(t('common.captchaCode'))} | ||
> | ||
<SendCodeByEmail | ||
className="authing-g2-input g2-send-code-input" | ||
autoComplete="one-time-code" | ||
size="large" | ||
placeholder={ | ||
t('common.inputFourVerifyCode', { | ||
length: verifyCodeLength | ||
}) as string | ||
} | ||
maxLength={verifyCodeLength} | ||
data={''} | ||
scene={EmailScene.VERIFY_CODE} | ||
fieldName="email" | ||
form={form} | ||
onSendCodeBefore={() => form.validateFields(['email'])} | ||
/> | ||
</Form.Item> | ||
<Form.Item className="authing-g2-sumbit-form"> | ||
<SubmitButton | ||
text={t('common.applyJoin') as string} | ||
className="password" | ||
ref={submitButtonRef} | ||
/> | ||
</Form.Item> | ||
</Form> | ||
</div> | ||
<ChangeLanguage | ||
langRange={config?.langRange} | ||
onLangChange={events?.onLangChange} | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/guard-core-v4/src/Invitation/Application/style.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.g2-view-invitation-apply { | ||
.g2-view-header { | ||
display: flex; | ||
&-container { | ||
margin-left: 16px; | ||
.invitation-welcome { | ||
margin-bottom: 4px; | ||
color: #545968; | ||
font-size: 14px; | ||
} | ||
.title { | ||
line-height: 1; | ||
} | ||
} | ||
} | ||
.g2-view-content { | ||
padding: 0 38px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { React } from 'shim-react' | ||
|
||
import { i18n } from '../_utils/locales' | ||
|
||
import './styles.less' | ||
|
||
import { useGuardInitData, useGuardPublicConfig } from '../_utils/context' | ||
|
||
import { useGuardView } from '../Guard/core/hooks/useGuardView' | ||
|
||
const { useMemo } = React | ||
|
||
export interface MessageProps { | ||
message?: React.ReactNode | ||
} | ||
|
||
export interface GuardMessageProps { | ||
initData?: MessageProps | ||
} | ||
|
||
export const GuardMessageView: React.FC<MessageProps> = propsInitData => { | ||
const guardXInitData = useGuardInitData<MessageProps>() | ||
|
||
const publicConfig = useGuardPublicConfig() | ||
|
||
useGuardView() | ||
|
||
const messages = useMemo(() => { | ||
const message = propsInitData?.message ?? guardXInitData?.message | ||
|
||
return `${message}` ?? `${i18n.t('user.contactAdministrator')}` | ||
}, [guardXInitData?.message, propsInitData?.message]) | ||
|
||
return ( | ||
<div className="g2-view-container g2-view-message"> | ||
<div className="g2-message-content"> | ||
<div style={{ display: 'flex', justifyContent: 'center' }}> | ||
<div | ||
style={{ | ||
width: 135, | ||
height: 103, | ||
backgroundImage: `url(${publicConfig.cdnBase}/authing_message.svg)`, | ||
backgroundSize: 'contain' | ||
}} | ||
/> | ||
</div> | ||
<span | ||
className="g2-message-text" | ||
dangerouslySetInnerHTML={{ __html: messages }} | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.g2-message-content { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
margin: auto 0; | ||
|
||
.g2-message-text { | ||
margin-top: 10px; | ||
color: #545968; | ||
font-size: 14px; | ||
} | ||
// .g2-error-message { | ||
// margin-top: 30px; | ||
// color: #545968; | ||
// font-size: 16px; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters