oak-general-business/es/components/userRelation/upsert/web.pc.js

36 lines
1.6 KiB
JavaScript

import React from 'react';
import { Tabs } from 'antd';
import Style from './web.module.less';
import ByMobile from './byMobile/index';
import ByUserEntityGrant from './byUserEntityGrant';
export default function Render(props) {
const { entity, entityId, relations, enabled, redirectToAfterConfirm, qrCodeType, claimUrl, rule, passwordRequired, onUserEntityGrantCreated, } = props.data;
const { t } = props.methods;
if (enabled.length === 0) {
return (<div className={Style.container}>
{t('noMethods')}
</div>);
}
const SubParts = enabled.map((ele) => {
switch (ele) {
case 'email': {
return <div key={ele} className={Style.container}>{t('not-implemented')}</div>;
}
case 'mobile': {
return (<ByMobile key={ele} passwordRequired={passwordRequired} entity={entity} entityId={entityId} relations={relations} oakPath="$userRelation-upsert-by-mobile" oakAutoUnmount={true}/>);
}
case 'userEntityGrant': {
return (<ByUserEntityGrant key={ele} qrCodeType={qrCodeType} entity={entity} entityId={entityId} relations={relations} claimUrl={claimUrl} rule={rule} oakPath="$userRelation-upsert-by-userEntityGrant" oakAutoUnmount={true} redirectToAfterConfirm={redirectToAfterConfirm} onUserEntityGrantCreated={onUserEntityGrantCreated}/>);
}
}
});
if (SubParts.length === 1) {
return SubParts[0];
}
return (<Tabs items={enabled.map((ele, idx) => ({
label: t(`methods.${ele}`),
key: `item-${idx}`,
children: SubParts[idx]
}))}/>);
}