import React from 'react' ; import Form , { Expired } from 'teleport/components/FormNewCredentials' ; import useToken , { State } from './useToken' ; export default function Container ( { tokenId = '' , title , submitBtnText } ) { const state = useToken ( tokenId ) ; return ( < NewCredentials { ... state } title = { title } submitBtnText = { submitBtnText } / > ) ; } export function NewCredentials ( props ) { const { submitAttempt , fetchAttempt , passwordToken , ... rest } = props ; if ( fetchAttempt . status === 'failed' ) { return < Expired />; } if ( fetchAttempt . status !== 'success' ) { return null ; } const { user , qrCode } = passwordToken ; return < Form user = { user } qr = { qrCode } attempt = { submitAttempt } { ... rest } />; } export type Props = State & { submitBtnText : string ; title : string ; resetMode ? : boolean ; } ;