From fe04d0253b0cea4643b0b10e98bedf2f873b7e25 Mon Sep 17 00:00:00 2001 From: AndyOoh Date: Sun, 21 Jan 2024 00:33:22 +0700 Subject: [PATCH 1/8] style and coinditional render button --- .../events/components/create-event-button.tsx | 15 +++++++++++++++ apps/app/src/app/(protected)/events/page.tsx | 12 ++++++------ .../(protected)/profile/components/form/index.tsx | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 apps/app/src/app/(protected)/events/components/create-event-button.tsx diff --git a/apps/app/src/app/(protected)/events/components/create-event-button.tsx b/apps/app/src/app/(protected)/events/components/create-event-button.tsx new file mode 100644 index 0000000..a8a7424 --- /dev/null +++ b/apps/app/src/app/(protected)/events/components/create-event-button.tsx @@ -0,0 +1,15 @@ +'use client'; + +import { CurrUserContext } from 'app/(protected)/components/Providers/CurrentUserProvider'; +import Link from 'next/link'; +import React, { useContext } from 'react'; + +export const CreateEventButton = () => { + const { currentUser } = useContext(CurrUserContext); + console.log('😍😍😍😍 currentUser:', currentUser); + return currentUser?.customClaims.type === 'business' ? ( + + Create Event + + ) : null; +}; diff --git a/apps/app/src/app/(protected)/events/page.tsx b/apps/app/src/app/(protected)/events/page.tsx index 08c4533..6ac584b 100644 --- a/apps/app/src/app/(protected)/events/page.tsx +++ b/apps/app/src/app/(protected)/events/page.tsx @@ -1,8 +1,8 @@ import 'server-only'; import { getCloudFunction } from '__firebase/clientApp'; -import Link from 'next/link'; import { EventsLala } from './Events'; +import { CreateEventButton } from './components/create-event-button'; type Props = {}; @@ -10,14 +10,14 @@ export default async function Events({}: Props) { const fetchDocs = getCloudFunction('fetchDocs'); const { data } = await fetchDocs({ collectionName: 'events' }); - return (
-

Upcoming Events

+
+

Upcoming Events

+ +
- - Create New Event - +
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 6c7e774..294edde 100644 --- a/apps/app/src/app/(protected)/profile/components/form/index.tsx +++ b/apps/app/src/app/(protected)/profile/components/form/index.tsx @@ -22,7 +22,7 @@ export const EditProfileForm = () => { mode: 'onTouched', resolver: yupResolver(personalInfoSchema({ initialEmail: currentUser?.email })), }); - const { errors, isDirty, isValid, isSubmitting, isSubmitSuccessful, dirtyFields } = formState; + const { errors, isDirty, isValid, isSubmitting, isSubmitSuccessful } = formState; useEffect(() => { if (isSubmitSuccessful) { From e0e478ca4376cd5fcd401a7046392eb09f89ad9b Mon Sep 17 00:00:00 2001 From: AndyOoh Date: Sun, 21 Jan 2024 00:36:47 +0700 Subject: [PATCH 2/8] fix button sizes --- apps/app/src/app/(protected)/events/Events.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/app/src/app/(protected)/events/Events.tsx b/apps/app/src/app/(protected)/events/Events.tsx index 739cdc9..86c9a69 100644 --- a/apps/app/src/app/(protected)/events/Events.tsx +++ b/apps/app/src/app/(protected)/events/Events.tsx @@ -167,7 +167,7 @@ export const EventsLala = ({ events }: Props) => {
- + {process.env.NODE_ENV === 'development' && } ) : null; }; From 449afebb566c71a00e019129e586b3420124c040 Mon Sep 17 00:00:00 2001 From: AndyOoh Date: Sun, 21 Jan 2024 02:03:57 +0700 Subject: [PATCH 6/8] implement event_id --- .../src/app/(protected)/events/create/form/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 0d971fc..ab0ae4c 100644 --- a/apps/app/src/app/(protected)/events/create/form/index.tsx +++ b/apps/app/src/app/(protected)/events/create/form/index.tsx @@ -1,7 +1,7 @@ 'use client'; import React, { useContext, useEffect } from 'react'; -import { addDoc, arrayUnion, collection, doc, updateDoc } from 'firebase/firestore'; +import { addDoc, arrayUnion, collection, doc, increment, updateDoc } from 'firebase/firestore'; import { DevTool } from '@hookform/devtools'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -42,11 +42,10 @@ export const CreateEventForm = () => { collectionName: 'metaData', id: 'events', }); - console.log('🚀 eventsMetadata:', eventsMetadata); const newEventRef = await addDoc(eventsCollectionRef, { ...data, - event_id: eventsMetadata.currentId, + event_id: eventsMetadata.currentId + 1, }); // Step 2: Get the reference to the newly created event @@ -58,6 +57,13 @@ export const CreateEventForm = () => { events: arrayUnion({ eventId: eventDocId }), }); + /* update metaData/events */ + const eventsDocRef = doc(db, 'mataData', 'events'); + console.log('🚀 eventsDocRef:', eventsDocRef); + await updateDoc(eventsDocRef, { + currentId: increment(1), + }); + console.log('Event submitted successfully!'); } catch (error) { console.error('Error submitting event:', error); From e678077dd42289bc959ffcdd2be4bb50e22f29e7 Mon Sep 17 00:00:00 2001 From: AndyOoh Date: Sun, 21 Jan 2024 02:12:11 +0700 Subject: [PATCH 7/8] export metadata --- .../(protected)/events/create/form/index.tsx | 7 +++++-- .../emulator-data/auth_export/accounts.json | 2 +- .../all_namespaces_all_kinds.export_metadata | Bin 52 -> 52 bytes .../all_namespaces/all_kinds/output-0 | Bin 4762 -> 4896 bytes .../firestore_export.overall_export_metadata | Bin 95 -> 95 bytes ...8 => 7f4facbc-16e2-4659-919b-e10117da70ee} | Bin ...a => f0e728a2-a4ac-4977-aefe-2e7e396007bc} | Bin ...6 => f363225c-501a-4a61-8f8a-e8286dcba13a} | Bin ...1 => fb4c678d-5820-42dd-99ea-b7a28079cea1} | 0 ...7f4facbc-16e2-4659-919b-e10117da70ee.json} | 0 ...f0e728a2-a4ac-4977-aefe-2e7e396007bc.json} | 0 ...f363225c-501a-4a61-8f8a-e8286dcba13a.json} | 0 ...fb4c678d-5820-42dd-99ea-b7a28079cea1.json} | 0 .../src/fetch-firestore-data.ts | 2 -- 14 files changed, 6 insertions(+), 5 deletions(-) rename apps/firebase-cloud-functions/emulator-data/storage_export/blobs/{d884332e-f11d-481e-86bc-8d464afa1b58 => 7f4facbc-16e2-4659-919b-e10117da70ee} (100%) rename apps/firebase-cloud-functions/emulator-data/storage_export/blobs/{69f9df53-84bd-49b2-ac62-7e2400736f8a => f0e728a2-a4ac-4977-aefe-2e7e396007bc} (100%) rename apps/firebase-cloud-functions/emulator-data/storage_export/blobs/{fce0ef55-6ef7-4ad8-baca-48084a13dd26 => f363225c-501a-4a61-8f8a-e8286dcba13a} (100%) rename apps/firebase-cloud-functions/emulator-data/storage_export/blobs/{d5860acd-764b-4d6d-b94d-f4ad35907301 => fb4c678d-5820-42dd-99ea-b7a28079cea1} (100%) rename apps/firebase-cloud-functions/emulator-data/storage_export/metadata/{d884332e-f11d-481e-86bc-8d464afa1b58.json => 7f4facbc-16e2-4659-919b-e10117da70ee.json} (100%) rename apps/firebase-cloud-functions/emulator-data/storage_export/metadata/{69f9df53-84bd-49b2-ac62-7e2400736f8a.json => f0e728a2-a4ac-4977-aefe-2e7e396007bc.json} (100%) rename apps/firebase-cloud-functions/emulator-data/storage_export/metadata/{fce0ef55-6ef7-4ad8-baca-48084a13dd26.json => f363225c-501a-4a61-8f8a-e8286dcba13a.json} (100%) rename apps/firebase-cloud-functions/emulator-data/storage_export/metadata/{d5860acd-764b-4d6d-b94d-f4ad35907301.json => fb4c678d-5820-42dd-99ea-b7a28079cea1.json} (100%) 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 ab0ae4c..06d0c7e 100644 --- a/apps/app/src/app/(protected)/events/create/form/index.tsx +++ b/apps/app/src/app/(protected)/events/create/form/index.tsx @@ -37,6 +37,10 @@ export const CreateEventForm = () => { // Step 1: Add a new entry to the "events" collection const eventsCollectionRef = collection(db, 'events'); + /* + * Fetch metaData/events doc to get currentId for events. + * Perhaps this can be done using const eventsDocRef = doc(db, 'metaData', 'events') ?? + */ const fetchDocById = getCloudFunction('fetchDocById'); const { data: eventsMetadata }: any = await fetchDocById({ collectionName: 'metaData', @@ -58,8 +62,7 @@ export const CreateEventForm = () => { }); /* update metaData/events */ - const eventsDocRef = doc(db, 'mataData', 'events'); - console.log('🚀 eventsDocRef:', eventsDocRef); + const eventsDocRef = doc(db, 'metaData', 'events'); await updateDoc(eventsDocRef, { currentId: increment(1), }); diff --git a/apps/firebase-cloud-functions/emulator-data/auth_export/accounts.json b/apps/firebase-cloud-functions/emulator-data/auth_export/accounts.json index 7c25f8b..f93140c 100644 --- a/apps/firebase-cloud-functions/emulator-data/auth_export/accounts.json +++ b/apps/firebase-cloud-functions/emulator-data/auth_export/accounts.json @@ -1 +1 @@ -{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"DI4Dx3YiiDonUcaz0UiiFjdCUkAU","createdAt":"1704033339723","lastLoginAt":"1704033339727","displayName":"Orange Chicken","photoUrl":"http://localhost:9199/v0/b/event-dee-staging.appspot.com/o/users%2FDI4Dx3YiiDonUcaz0UiiFjdCUkAU%2Fimages%2Fprofile?alt=media&token=aaa55962-ac74-4b1d-8045-7c688f925cc4","customAttributes":"{\"basic_info_done\":true,\"type\":\"freelancer\"}","providerUserInfo":[{"providerId":"google.com","rawId":"6233296176568572704053954672800598602635","federatedId":"6233296176568572704053954672800598602635","displayName":"Orange Chicken","email":"orange.chicken.38@example.com","screenName":"chicken_orange"}],"validSince":"1705773459","email":"orange.chicken.38@example.com","emailVerified":true,"disabled":false},{"localId":"XobXVTMfKX21NwEP7V5LEuuX4q8u","createdAt":"1704023132744","lastLoginAt":"1704023132744","photoUrl":"http://localhost:9199/v0/b/event-dee-staging.appspot.com/o/users%2FXobXVTMfKX21NwEP7V5LEuuX4q8u%2Fimages%2Fprofile?alt=media&token=be3f3bef-d833-4dd0-b275-11a58ec238a3","passwordHash":"fakeHash:salt=fakeSaltUu0sqgKGXdW18M52lrCJ:password=oooooo","salt":"fakeSaltUu0sqgKGXdW18M52lrCJ","passwordUpdatedAt":1705773459746,"customAttributes":"{\"basic_info_done\":true,\"type\":\"freelancer\"}","providerUserInfo":[{"providerId":"password","email":"oo@oo.oo","federatedId":"oo@oo.oo","rawId":"oo@oo.oo","photoUrl":"http://localhost:9199/v0/b/event-dee-staging.appspot.com/o/users%2FXobXVTMfKX21NwEP7V5LEuuX4q8u%2Fimages%2Fprofile?alt=media&token=be3f3bef-d833-4dd0-b275-11a58ec238a3"}],"validSince":"1705773459","email":"oo@oo.oo","emailVerified":false,"disabled":false},{"localId":"qIsokoD9bxhWt2tcFdcNpAg0DPZb","createdAt":"1704107208217","lastLoginAt":"1704912527992","photoUrl":"https://storage.cloud.google.com/event-dee-staging.appspot.com/misc/profile-photo-placeholder.jpg","passwordHash":"fakeHash:salt=fakeSalth89eFQSxrdhCytX68Nxe:password=bbbbbb","salt":"fakeSalth89eFQSxrdhCytX68Nxe","passwordUpdatedAt":1705773459746,"customAttributes":"{\"basic_info_done\":true,\"type\":\"business\"}","providerUserInfo":[{"providerId":"password","email":"bb@bb.bb","federatedId":"bb@bb.bb","rawId":"bb@bb.bb","photoUrl":"https://storage.cloud.google.com/event-dee-staging.appspot.com/misc/profile-photo-placeholder.jpg"}],"validSince":"1705773459","email":"bb@bb.bb","emailVerified":false,"disabled":false}]} \ No newline at end of file +{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"DI4Dx3YiiDonUcaz0UiiFjdCUkAU","createdAt":"1704033339723","lastLoginAt":"1704033339727","displayName":"Orange Chicken","photoUrl":"http://localhost:9199/v0/b/event-dee-staging.appspot.com/o/users%2FDI4Dx3YiiDonUcaz0UiiFjdCUkAU%2Fimages%2Fprofile?alt=media&token=aaa55962-ac74-4b1d-8045-7c688f925cc4","customAttributes":"{\"basic_info_done\":true,\"type\":\"freelancer\"}","providerUserInfo":[{"providerId":"google.com","rawId":"6233296176568572704053954672800598602635","federatedId":"6233296176568572704053954672800598602635","displayName":"Orange Chicken","email":"orange.chicken.38@example.com","screenName":"chicken_orange"}],"validSince":"1705773834","email":"orange.chicken.38@example.com","emailVerified":true,"disabled":false},{"localId":"XobXVTMfKX21NwEP7V5LEuuX4q8u","createdAt":"1704023132744","lastLoginAt":"1704023132744","photoUrl":"http://localhost:9199/v0/b/event-dee-staging.appspot.com/o/users%2FXobXVTMfKX21NwEP7V5LEuuX4q8u%2Fimages%2Fprofile?alt=media&token=be3f3bef-d833-4dd0-b275-11a58ec238a3","passwordHash":"fakeHash:salt=fakeSaltUu0sqgKGXdW18M52lrCJ:password=oooooo","salt":"fakeSaltUu0sqgKGXdW18M52lrCJ","passwordUpdatedAt":1705773834089,"customAttributes":"{\"basic_info_done\":true,\"type\":\"freelancer\"}","providerUserInfo":[{"providerId":"password","email":"oo@oo.oo","federatedId":"oo@oo.oo","rawId":"oo@oo.oo","photoUrl":"http://localhost:9199/v0/b/event-dee-staging.appspot.com/o/users%2FXobXVTMfKX21NwEP7V5LEuuX4q8u%2Fimages%2Fprofile?alt=media&token=be3f3bef-d833-4dd0-b275-11a58ec238a3"}],"validSince":"1705773834","email":"oo@oo.oo","emailVerified":false,"disabled":false},{"localId":"qIsokoD9bxhWt2tcFdcNpAg0DPZb","createdAt":"1704107208217","lastLoginAt":"1705774752210","photoUrl":"https://storage.cloud.google.com/event-dee-staging.appspot.com/misc/profile-photo-placeholder.jpg","passwordHash":"fakeHash:salt=fakeSalth89eFQSxrdhCytX68Nxe:password=bbbbbb","salt":"fakeSalth89eFQSxrdhCytX68Nxe","passwordUpdatedAt":1705773834089,"customAttributes":"{\"basic_info_done\":true,\"type\":\"business\"}","providerUserInfo":[{"providerId":"password","email":"bb@bb.bb","federatedId":"bb@bb.bb","rawId":"bb@bb.bb","photoUrl":"https://storage.cloud.google.com/event-dee-staging.appspot.com/misc/profile-photo-placeholder.jpg"}],"validSince":"1705773834","email":"bb@bb.bb","emailVerified":false,"disabled":false,"lastRefreshAt":"2024-01-20T19:06:09.807Z"}]} \ No newline at end of file diff --git a/apps/firebase-cloud-functions/emulator-data/firestore_export/all_namespaces/all_kinds/all_namespaces_all_kinds.export_metadata b/apps/firebase-cloud-functions/emulator-data/firestore_export/all_namespaces/all_kinds/all_namespaces_all_kinds.export_metadata index aaf44af73088b1fc007d1be9c7133e66853ad692..8f22f67972d418941e88bd92dc0a6e970478a386 100644 GIT binary patch delta 36 pcmXppnII~E{>A^kt8bc_C7%9m=m#-`c(@pZIPyzN3Q9|K4FEk74_E*I delta 36 ocmXppnIJ0Pd7%B>(KpS^60cTtfEhwOTns`S`K2WVr6sxs04pL6$p8QV diff --git a/apps/firebase-cloud-functions/emulator-data/firestore_export/all_namespaces/all_kinds/output-0 b/apps/firebase-cloud-functions/emulator-data/firestore_export/all_namespaces/all_kinds/output-0 index 8a5c4ce472dc5b1c02878589799180ea05f4aff5..5b8855b996422a543548f3c222a1216fc1732d15 100644 GIT binary patch delta 183 zcmbQGxZibNzkmgkySnpP#5hvs|uC*|em`A-(- z)e-Ry%M8u&wD2+wsxb16a863~N^%BEB)S&5yBqs?SyZN(2Btdt`@2`3gO~WT&=hfXjfscy?06I!GLjV8( delta 203 zcmZ3WHcOSWza)&Ml!Y2E>RK*aCCAlNii@l4oyl)E(!Iq3`h#+ zsS=T5%}4}71qLlnDRvMG2&;sp*g={y^U{IhY*H*ai8+Z)j0DU&=(X9F8R%GtEYXzI Qvbxl=)Vz|-TKwOb0TBW``2YX_ diff --git a/apps/firebase-cloud-functions/emulator-data/firestore_export/firestore_export.overall_export_metadata b/apps/firebase-cloud-functions/emulator-data/firestore_export/firestore_export.overall_export_metadata index 449ea0e92332c6daade3cc3f3d7f70614a4d28f7..ffa885b42d83eeb0df2f732101d62d8b43603293 100644 GIT binary patch delta 23 ecma!#=h>0#;>XCqXw3Gjy=)?nKMSkE0yO|p{sxZ# delta 23 ecma!#=h>0#;>XCqXndAsd&@)~e-<`{S*ie26$Y39 diff --git a/apps/firebase-cloud-functions/emulator-data/storage_export/blobs/d884332e-f11d-481e-86bc-8d464afa1b58 b/apps/firebase-cloud-functions/emulator-data/storage_export/blobs/7f4facbc-16e2-4659-919b-e10117da70ee similarity index 100% rename from apps/firebase-cloud-functions/emulator-data/storage_export/blobs/d884332e-f11d-481e-86bc-8d464afa1b58 rename to apps/firebase-cloud-functions/emulator-data/storage_export/blobs/7f4facbc-16e2-4659-919b-e10117da70ee diff --git a/apps/firebase-cloud-functions/emulator-data/storage_export/blobs/69f9df53-84bd-49b2-ac62-7e2400736f8a b/apps/firebase-cloud-functions/emulator-data/storage_export/blobs/f0e728a2-a4ac-4977-aefe-2e7e396007bc similarity index 100% rename from apps/firebase-cloud-functions/emulator-data/storage_export/blobs/69f9df53-84bd-49b2-ac62-7e2400736f8a rename to apps/firebase-cloud-functions/emulator-data/storage_export/blobs/f0e728a2-a4ac-4977-aefe-2e7e396007bc diff --git a/apps/firebase-cloud-functions/emulator-data/storage_export/blobs/fce0ef55-6ef7-4ad8-baca-48084a13dd26 b/apps/firebase-cloud-functions/emulator-data/storage_export/blobs/f363225c-501a-4a61-8f8a-e8286dcba13a similarity index 100% rename from apps/firebase-cloud-functions/emulator-data/storage_export/blobs/fce0ef55-6ef7-4ad8-baca-48084a13dd26 rename to apps/firebase-cloud-functions/emulator-data/storage_export/blobs/f363225c-501a-4a61-8f8a-e8286dcba13a diff --git a/apps/firebase-cloud-functions/emulator-data/storage_export/blobs/d5860acd-764b-4d6d-b94d-f4ad35907301 b/apps/firebase-cloud-functions/emulator-data/storage_export/blobs/fb4c678d-5820-42dd-99ea-b7a28079cea1 similarity index 100% rename from apps/firebase-cloud-functions/emulator-data/storage_export/blobs/d5860acd-764b-4d6d-b94d-f4ad35907301 rename to apps/firebase-cloud-functions/emulator-data/storage_export/blobs/fb4c678d-5820-42dd-99ea-b7a28079cea1 diff --git a/apps/firebase-cloud-functions/emulator-data/storage_export/metadata/d884332e-f11d-481e-86bc-8d464afa1b58.json b/apps/firebase-cloud-functions/emulator-data/storage_export/metadata/7f4facbc-16e2-4659-919b-e10117da70ee.json similarity index 100% rename from apps/firebase-cloud-functions/emulator-data/storage_export/metadata/d884332e-f11d-481e-86bc-8d464afa1b58.json rename to apps/firebase-cloud-functions/emulator-data/storage_export/metadata/7f4facbc-16e2-4659-919b-e10117da70ee.json diff --git a/apps/firebase-cloud-functions/emulator-data/storage_export/metadata/69f9df53-84bd-49b2-ac62-7e2400736f8a.json b/apps/firebase-cloud-functions/emulator-data/storage_export/metadata/f0e728a2-a4ac-4977-aefe-2e7e396007bc.json similarity index 100% rename from apps/firebase-cloud-functions/emulator-data/storage_export/metadata/69f9df53-84bd-49b2-ac62-7e2400736f8a.json rename to apps/firebase-cloud-functions/emulator-data/storage_export/metadata/f0e728a2-a4ac-4977-aefe-2e7e396007bc.json diff --git a/apps/firebase-cloud-functions/emulator-data/storage_export/metadata/fce0ef55-6ef7-4ad8-baca-48084a13dd26.json b/apps/firebase-cloud-functions/emulator-data/storage_export/metadata/f363225c-501a-4a61-8f8a-e8286dcba13a.json similarity index 100% rename from apps/firebase-cloud-functions/emulator-data/storage_export/metadata/fce0ef55-6ef7-4ad8-baca-48084a13dd26.json rename to apps/firebase-cloud-functions/emulator-data/storage_export/metadata/f363225c-501a-4a61-8f8a-e8286dcba13a.json diff --git a/apps/firebase-cloud-functions/emulator-data/storage_export/metadata/d5860acd-764b-4d6d-b94d-f4ad35907301.json b/apps/firebase-cloud-functions/emulator-data/storage_export/metadata/fb4c678d-5820-42dd-99ea-b7a28079cea1.json similarity index 100% rename from apps/firebase-cloud-functions/emulator-data/storage_export/metadata/d5860acd-764b-4d6d-b94d-f4ad35907301.json rename to apps/firebase-cloud-functions/emulator-data/storage_export/metadata/fb4c678d-5820-42dd-99ea-b7a28079cea1.json diff --git a/apps/firebase-cloud-functions/src/fetch-firestore-data.ts b/apps/firebase-cloud-functions/src/fetch-firestore-data.ts index 08ece3a..0af68db 100644 --- a/apps/firebase-cloud-functions/src/fetch-firestore-data.ts +++ b/apps/firebase-cloud-functions/src/fetch-firestore-data.ts @@ -81,10 +81,8 @@ export const fetchDocById = https.onCall( const querySnapshot = await collectionRef .doc(id) // Assuming 'value' is the document ID .get(); - console.log('🚀 querySnapshot:', querySnapshot); const document = querySnapshot.data()!; - console.log('🚀 document:', document) return document; } catch (error) { console.error('Error fetching documents, fetchDocById:', error); From 308f7bf3121e9c2e692e8867e95b75d44a6cd1e4 Mon Sep 17 00:00:00 2001 From: AndyOoh Date: Sun, 21 Jan 2024 02:27:38 +0700 Subject: [PATCH 8/8] add page for emul test --- .../components/HomeMain/HomeMain.tsx | 19 --------------- .../app/(protected)/events/create/page.tsx | 6 +---- .../app/(protected)/test-emulator/page.tsx | 22 ++++++++++++++++++ apps/app/src/components/Sidebar/Sidebar.tsx | 23 +++++++++++++++---- 4 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 apps/app/src/app/(protected)/test-emulator/page.tsx diff --git a/apps/app/src/app/(protected)/components/HomeMain/HomeMain.tsx b/apps/app/src/app/(protected)/components/HomeMain/HomeMain.tsx index 26a9f21..27e7775 100644 --- a/apps/app/src/app/(protected)/components/HomeMain/HomeMain.tsx +++ b/apps/app/src/app/(protected)/components/HomeMain/HomeMain.tsx @@ -1,30 +1,11 @@ -'use client'; - -import React from 'react'; import { Stats } from './stats/Stats'; import { ReferralAd } from './referralAd/ReferralAd'; -import { createDocument } from '__firebase/utilities'; export const HomeMain = () => { - const submitHandler = async () => { - try { - console.log('submitHandler'); - await createDocument('emul-test', { id: 123, test: 'it works' }); - } catch (error) { - console.log('🚀 file: HomeMain.tsx:17 error:', error); - } - }; - return (
- - {process.env.NEXT_PUBLIC_EMULATORS_ON === 'true' && ( - - )}
); }; diff --git a/apps/app/src/app/(protected)/events/create/page.tsx b/apps/app/src/app/(protected)/events/create/page.tsx index cf575ff..34f79c4 100644 --- a/apps/app/src/app/(protected)/events/create/page.tsx +++ b/apps/app/src/app/(protected)/events/create/page.tsx @@ -1,10 +1,6 @@ -import Link from 'next/link'; -import React from 'react'; import { CreateEventForm } from './form'; -type Props = {}; - -export default function CreateEvent({}: Props) { +export default function CreateEvent() { return (

Create a new event

diff --git a/apps/app/src/app/(protected)/test-emulator/page.tsx b/apps/app/src/app/(protected)/test-emulator/page.tsx new file mode 100644 index 0000000..510e6ca --- /dev/null +++ b/apps/app/src/app/(protected)/test-emulator/page.tsx @@ -0,0 +1,22 @@ +import { createDocument } from '__firebase/utilities'; + +export default function TestEmulatorPage() { + const submitHandler = async () => { + try { + console.log('submitHandler'); + await createDocument('emul-test', { id: 123, test: 'it works' }); + } catch (error) { + console.log('🚀 file: HomeMain.tsx:17 error:', error); + } + }; + return ( +
+

Test Emulator Page

+ {process.env.NEXT_PUBLIC_EMULATORS_ON === 'true' && ( + + )} +
+ ); +} diff --git a/apps/app/src/components/Sidebar/Sidebar.tsx b/apps/app/src/components/Sidebar/Sidebar.tsx index d575149..786bb92 100644 --- a/apps/app/src/components/Sidebar/Sidebar.tsx +++ b/apps/app/src/components/Sidebar/Sidebar.tsx @@ -1,8 +1,14 @@ -import { BiHome, BiSearchAlt, BiDollarCircle, BiCalendarCheck, BiCog } from 'react-icons/bi'; +import { + BiHome, + BiSearchAlt, + BiDollarCircle, + BiCalendarCheck, + BiCog, + BiTestTube, +} from 'react-icons/bi'; import Image from 'next/image'; import combi_mint from '/public/logo/combi/combi_mint.png'; import Link from 'next/link'; -// import { useState } from 'react'; type Props = {}; @@ -59,11 +65,20 @@ function Sidebar({}: Props) { {item.title} ))} + {process.env.NEXT_PUBLIC_EMULATORS_ON === 'true' && ( + + + + + Emulator Test + + )} - //
- //
); }