import React from 'react'; import { react2angular } from 'react2angular'; import { SubmitHandler, useForm } from 'react-hook-form'; import { User } from '../../models/user'; import { IApplication } from '../../models/application'; import { Loader } from '../base/loader'; import { FormInput } from '../form/form-input'; declare const Application: IApplication; interface UserProfileFormProps { action: 'create' | 'update', user: User; className?: string; } export const UserProfileForm: React.FC = ({ action, user, className }) => { const { handleSubmit, register } = useForm({ defaultValues: { ...user } }); /** * Callback triggered when the form is submitted: process with the user creation or update. */ const onSubmit: SubmitHandler = (data: User) => { console.log(action, data); }; return (
); }; const UserProfileFormWrapper: React.FC = (props) => { return ( ); }; Application.Components.component('userProfileForm', react2angular(UserProfileFormWrapper, ['action', 'user', 'className']));