diff --git a/apps/app/src/app/(protected)/components/HomeMain/HomeMain.tsx b/apps/app/src/app/(protected)/components/HomeMain/HomeMain.tsx
index cf0869d..9bc93e8 100644
--- a/apps/app/src/app/(protected)/components/HomeMain/HomeMain.tsx
+++ b/apps/app/src/app/(protected)/components/HomeMain/HomeMain.tsx
@@ -22,9 +22,11 @@ export const HomeMain = () => {
-
+ {process.env.NEXT_PUBLIC_EMULATORS_ON === 'true' && (
+
+ )}
);
};
diff --git a/apps/app/src/app/(protected)/events/create/form/index.tsx b/apps/app/src/app/(protected)/events/create/form/index.tsx
index a3e3289..f89f2b5 100644
--- a/apps/app/src/app/(protected)/events/create/form/index.tsx
+++ b/apps/app/src/app/(protected)/events/create/form/index.tsx
@@ -96,12 +96,14 @@ export const CreateEventForm = () => {
-
+ {process.env.NODE_ENV === 'development' && (
+
+ )}
diff --git a/apps/app/src/app/(protected)/events/create/form/test-field-array.tsx b/apps/app/src/app/(protected)/events/create/form/test-field-array.tsx
deleted file mode 100644
index 1f2dd3c..0000000
--- a/apps/app/src/app/(protected)/events/create/form/test-field-array.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import * as Yup from 'yup';
-
-import { yupResolver } from '@hookform/resolvers/yup';
-import React, { useEffect } from 'react';
-import { useForm, useFieldArray } from 'react-hook-form';
-
-type Props = {};
-
-export const TestFieldArray = (props: Props) => {
- // form validation rules
- const validationSchema = Yup.object().shape({
- numberOfTickets: Yup.string().required('Number of tickets is required'),
- tickets: Yup.array().of(
- Yup.object().shape({
- name: Yup.string().required('Name is required'),
- email: Yup.string().email('Email is Invalid').required('Email is required'),
- })
- ),
- });
- type IvalidationSchema = Yup.InferType;
- const formOptions = { resolver: yupResolver(validationSchema) };
-
- // functions to build form returned by useForm() and useFieldArray() hooks
- const { register, control, handleSubmit, reset, formState, watch } = useForm(formOptions);
- const { errors } = formState;
- const { fields, append, remove } = useFieldArray({ name: 'tickets', control });
-
- console.log('🚀 file: test-field-array.tsx:25 control:', control);
- console.log('🚀 file: test-field-array.tsx:27 fields:', fields);
-
- // watch to enable re-render when ticket number is changed
- const numberOfTickets = watch('numberOfTickets');
-
- useEffect(() => {
- // update field array when ticket number changed
- const newVal = parseInt(numberOfTickets) || 0;
- const oldVal = fields.length;
- if (newVal > oldVal) {
- // append tickets to field array
- for (let i = oldVal; i < newVal; i++) {
- append({ name: '', email: '' });
- }
- } else {
- // remove tickets from field array
- for (let i = oldVal; i > newVal; i--) {
- remove(i - 1);
- }
- }
- }, [numberOfTickets]);
-
- function onSubmit(data) {
- // display form data on success
- alert('SUCCESS!! :-)\n\n' + JSON.stringify(data, null, 4));
- }
-
- return (
-
- );
-};
diff --git a/apps/app/src/app/(protected)/profile/components/form/index.tsx b/apps/app/src/app/(protected)/profile/components/form/index.tsx
index 2791b43..6c7e774 100644
--- a/apps/app/src/app/(protected)/profile/components/form/index.tsx
+++ b/apps/app/src/app/(protected)/profile/components/form/index.tsx
@@ -74,12 +74,14 @@ export const EditProfileForm = () => {
-
+ {process.env.NODE_ENV === 'development' && (
+
+ )}
diff --git a/apps/app/src/app/(protected)/settings/components/delete-acc-form/index.tsx b/apps/app/src/app/(protected)/settings/components/delete-acc-form/index.tsx
index ba5ce39..98c61a6 100644
--- a/apps/app/src/app/(protected)/settings/components/delete-acc-form/index.tsx
+++ b/apps/app/src/app/(protected)/settings/components/delete-acc-form/index.tsx
@@ -10,7 +10,7 @@ import { TextInput, FormError, ActionButton } from 'ui';
import { useAuthState, useDeleteUser } from 'react-firebase-hooks/auth';
import { reAuthenticate } from '__firebase/utilities';
import { useRouter } from 'next/navigation';
-import { DevTool } from '@hookform/devtools';
+import { onTestForm } from '__utils/helpers';
export const DeleteAccountForm = () => {
const { currentUser } = useContext(CurrUserContext);
@@ -19,19 +19,12 @@ export const DeleteAccountForm = () => {
const [deleteUser, loading_delete, error_delete] = useDeleteUser(auth);
const router = useRouter();
- const {
- register,
- reset,
- handleSubmit,
- setError,
- control,
- watch,
-
- formState: { errors, isDirty, isValid, isSubmitting, isSubmitSuccessful, dirtyFields },
- } = useForm({
- mode: 'onTouched',
- resolver: providerId === 'password' ? yupResolver(deleteUserSchema) : null,
- });
+ const { register, reset, handleSubmit, setError, watch, formState, getValues } =
+ useForm({
+ mode: 'onTouched',
+ resolver: providerId === 'password' ? yupResolver(deleteUserSchema) : null,
+ });
+ const { errors, isDirty, isValid, isSubmitting, isSubmitSuccessful } = formState;
useEffect(() => {
if (isSubmitSuccessful) {
@@ -43,13 +36,10 @@ export const DeleteAccountForm = () => {
try {
const result =
providerId === 'password' ? await reAuthenticate(data.password) : await reAuthenticate();
-
result instanceof Error
? setError('password', { message: 'Incorrect password' })
: await deleteUser();
-
router.push('/');
-
return;
} catch (error) {
console.log('🚀 file: WorkInfo.tsx:59 error:', error);
@@ -58,16 +48,6 @@ export const DeleteAccountForm = () => {
const buttonDisabled = providerId === 'password' ? !isDirty || !isValid : false;
- const onTest = () => {
- const data = watch();
- // const changedData = getChangedFormData(data, dirtyFields);
- console.log('🚀 file: index.tsx:66 data:', data);
- console.log('🚀 file: index.tsx:66 dirtyFields:', dirtyFields);
- // console.log('🚀 file: index.tsx:66 filteredData:', changedData);
- console.log('🚀 file: index.tsx:66 isValid:', isValid);
- console.log('🚀 file: index.tsx:66 errors:', errors);
- };
-
return currentUser ? (
Delete Account
@@ -75,7 +55,6 @@ export const DeleteAccountForm = () => {
) : null;
};
diff --git a/apps/app/src/app/test-success/page.tsx b/apps/app/src/app/test-success/page.tsx
deleted file mode 100644
index c2ac82e..0000000
--- a/apps/app/src/app/test-success/page.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-'use client';
-
-import { auth } from '__firebase/clientApp';
-import { useRouter } from 'next/navigation';
-import React, { use, useEffect, useState } from 'react';
-import { useAuthState } from 'react-firebase-hooks/auth';
-
-type Props = {};
-
-function TestSuccess({}: Props) {
- const [user, loading, error] = useAuthState(auth);
- // const [_loading, _setLoading] = useState(true);
- const router = useRouter();
-
- useEffect(() => {
- // _setLoading(true);
- const fetchToken = async () => {
- const token = await user?.getIdTokenResult();
- console.log('🚀 file: PublicRoutes.tsx:19 token:', token);
- // !loading && !token?.claims.basic_info_done ? router.push('/test') : _setLoading(false);
- !loading && !token?.claims.basic_info_done && router.push('/test');
- };
-
- fetchToken();
- }, [user, router, loading]);
-
- const onLogout = async () => {
- try {
- await auth.signOut();
- } catch (error) {
- console.log('🚀 file: page.tsx:13 error:', error);
- }
- };
-
- return loading ? (
- Loading...
- ) : (
-
- SUccessfully user
-
-
- );
-}
-
-export default TestSuccess;
diff --git a/apps/app/src/app/test/page.tsx b/apps/app/src/app/test/page.tsx
deleted file mode 100644
index 5429d64..0000000
--- a/apps/app/src/app/test/page.tsx
+++ /dev/null
@@ -1,118 +0,0 @@
-'use client';
-
-import { auth, getCloudFunction } from '__firebase/clientApp';
-import React, { MouseEvent, useEffect, useState } from 'react';
-import { useAuthState, useSignInWithGoogle, useUpdateProfile } from 'react-firebase-hooks/auth';
-import { useRouter } from 'next/navigation';
-
-function Test() {
- const [signInWithGoogle, _userG, loadingGoogle, errorGoogle] = useSignInWithGoogle(auth);
- const [user, loading, error] = useAuthState(auth);
- const [_loading, _setLoading] = useState(true);
- const router = useRouter();
-
- // auth.onAuthStateChanged(async user => {
- // console.log('onAuthStateChanged called!!!!!!!!!');
- // // _setLoading(true);
- // if (user) {
- // const token = await user.getIdTokenResult(true);
- // console.log('🤣 onAuthStateChanged:', token);
- // if (token.claims.basic_info_done) {
- // router.push('/test-success');
- // }
- // } else {
- // console.log('🤣 onAuthStateChanged: user is null');
- // }
- // // _setLoading(false);
- // });
-
- useEffect(() => {
- console.log('useEffect called!!!!!!!!!');
- _setLoading(true);
- const fetchToken = async () => {
- const token = await user?.getIdTokenResult();
- console.log('🚀 file: page.tsx:11 user:', user);
- console.log('🚀 file: PublicRoutes.tsx:19 token:', token);
- token?.claims?.basic_info_done ? router.push('/test-success') : _setLoading(false);
- };
-
- fetchToken();
- }, [user, router]);
-
- // useEffect(() => {
- // console.log('useEffect called!!!!!!!!!');
- // }, []);
-
- // useEffect(() => {
- // console.log('useEffect called 222222222222');
- // }, [user]);
-
- const onClick = async (e: MouseEvent) => {
- try {
- e.preventDefault();
- const succes = await signInWithGoogle();
- } catch (error) {
- console.log('🚀 file: page.tsx:13 error:', error);
- }
- };
-
- const onClick2 = async (e: MouseEvent) => {
- try {
- e.preventDefault();
-
- const setCustomClaims = getCloudFunction('setCustomClaims'); // Our custom function
- const resSetCC = await setCustomClaims({
- uid: user?.uid,
- payload: { basic_info_done: true },
- });
- console.log('🚀 file: page.tsx:55 resSetCC:', resSetCC);
- const token = await user.getIdTokenResult(true);
- if (token.claims.basic_info_done) {
- // router.push('/test-success');
- router.push('/');
- } else {
- console.log('🚀 claims.basic_info_done fdlse:', token);
- }
-
- // const lala = user.getIdToken(true);
- // user.
- } catch (error) {
- console.log('🚀 file: page.tsx:13 error:', error);
- }
- };
- const onClick3 = async (e: MouseEvent) => {
- try {
- e.preventDefault();
- const token = await user.getIdTokenResult(true);
- console.log('🚀 file: page.tsx:75 token:', token);
- } catch (error) {
- console.log('🚀 file: page.tsx:77 error:', error);
- }
- };
-
- return loading || _loading ? (
- loading...
- ) : (
-
-
Testing Oauth and auth object
- {user &&
user displayName: {user?.displayName}
}
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-export default Test;