Skip to content

Commit

Permalink
fix: undefined error
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavan Soratur authored and Pavan Soratur committed Oct 19, 2024
1 parent 5c2f68e commit 61b0746
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 5 additions & 3 deletions components/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export const LoginForm: React.FC<LoginFormProps> = ({ onSubmitAction }) => {

const onSubmit = async (data: LoginFormData) => {
startTransition(async () => {
const { errorMessage = 'Something went wrong!' } =
await onSubmitAction(data);
const response = await onSubmitAction(data);

if (errorMessage) toast.error(errorMessage);
if (response) {
if (response.errorMessage) toast.error(response.errorMessage);
if (response.successMessage) toast.success(response.successMessage);
}

reset();
});
Expand Down
11 changes: 5 additions & 6 deletions components/auth/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ export const RegisterForm: React.FC<RegisterFormProps> = ({

const onSubmit = async (data: RegisterFormData) => {
startTransition(async () => {
const {
successMessage = 'Successfully registered!',
errorMessage = 'Something went wrong!',
} = await onSubmitAction(data);
const response = await onSubmitAction(data);

if (successMessage) toast.success(successMessage);
if (errorMessage) toast.error(errorMessage);
if (response) {
if (response.errorMessage) toast.error(response.errorMessage);
if (response.successMessage) toast.success(response.successMessage);
}

reset();
});
Expand Down

0 comments on commit 61b0746

Please sign in to comment.