import './permissionProfile.scss'; import React from 'react'; import Button from '../../../components/Button'; import Modal from '../../../components/Modal'; import Switch from '../../../components/Switch'; import { useTranslation } from 'react-i18next'; export type PermissionType = | 'paypay_information' | 'profile_info' | 'device_info'; interface Props { visible: boolean; toggleVisible: (v: boolean) => void; type: PermissionType; data: any; toggleSwitch: (type: PermissionType, index: number) => void; profileInfo: any; toggleEmailVisible: (v: boolean) => void; } const PermissionProfile: React.FC = (props) => { const { visible, toggleVisible, type, data, toggleSwitch, profileInfo, toggleEmailVisible, } = props; const { t } = useTranslation(); const renderContents = () => { return ( <> {renderRegisteredProfile()} {renderProfileSettings()} {renderDeviceInfo()} ); }; const renderRegisteredProfile = () => { return type === 'paypay_information' ? ( <>
{t('permissionCategory.paypay_information')}
{data && data.length > 0 ? data.map((item: any, i: number) => { return ( <>
{item.name !== 'mini_app_user_email_address' ? (
{t(`${type}.${item.name}`)}
{item.type === 'must' ? (
必須
) : (
toggleSwitch('paypay_information', i) } />
)}
) : ( <>
ユーザ識別子
{item.type === 'must' ? (
必須
) : (
toggleSwitch('paypay_information', i) } />
)}
{profileInfo.email ? ( <>
{profileInfo.email}
) : ( <>
未登録
)}
)} ); }) : null}
) : null; }; const renderProfileSettings = () => { return type === 'profile_info' ? ( <>
{t('permissionCategory.profile_info')}
{data && data.length > 0 ? data.map((item: any, i: number) => { return ( <>
{t(`${type}.${item.name}`)}
{/*
未登録
*/}
{item.type === 'must' ? (
必須
) : (
toggleSwitch('profile_info', i)} />
)}
); }) : null} {/*
姓名(カナ)
あああああ
必須
*/}
) : null; }; const renderDeviceInfo = () => { return type === 'device_info' ? ( <>
{t('permissionCategory.device_info')}
{data && data.length > 0 ? data.map((item: any, i: number) => { return ( <>
{t(`${type}.${item.name}`)}
{/*
未登録
*/}
{item.type === 'must' ? (
必須
) : (
toggleSwitch('device_info', i)} />
)}
); }) : null}
) : null; }; return ( {renderContents()} ); }; export default PermissionProfile;