-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from WelcometoMyGarden/feat/membership
Adds memberships
- Loading branch information
Showing
104 changed files
with
3,401 additions
and
1,703 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Prepare WTMG source | ||
description: Prepare the WTMG source code for building | ||
inputs: | ||
credentials_json: | ||
description: 'GCP Service Account JSON Credentials' | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'yarn' | ||
- name: Install Dependencies | ||
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data | ||
# https://yarnpkg.com/cli/install | ||
# --frozen-lockfile is deprecated | ||
run: yarn install --immutable | ||
shell: bash | ||
- id: auth | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
credentials_json: '${{ inputs.credentials_json }}' | ||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v1 | ||
with: | ||
version: '>= 363.0.0' | ||
project_id: 'wtmg-production' | ||
- name: Use gcloud CLI | ||
run: gsutil -m cp -r gs://wtmg-static/assets ${{ github.workspace }}/src/lib | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ admin-credentials.json | |
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
!.yarn/versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ const db = admin.firestore(app); | |
const auth = admin.auth(app); | ||
|
||
/** | ||
* @param {import('firebase-admin/auth').CreateRequest} authProps | ||
* @param {import('../../src/lib/api/functions').CreateUserRequest & {superfan?: true}} callableProps | ||
* @param {import('firebase-admin/auth').CreateRequest} authProps - passed to auth.createUser | ||
* @param {import('../../src/lib/api/functions').CreateUserRequest & {superfan?: true}} callableProps - replicating what is passed to the createUser callable | ||
*/ | ||
const createNewUser = async (authProps, callableProps) => { | ||
const user = await auth.createUser({ | ||
|
@@ -55,6 +55,14 @@ const createNewUser = async (authProps, callableProps) => { | |
return user; | ||
}; | ||
|
||
/** | ||
* @param {string} uid | ||
* @param {import('../../src/lib/types/Garden').Garden} data | ||
*/ | ||
const createGarden = async (uid, data) => { | ||
await db.collection('campsites').doc(uid).set(data); | ||
}; | ||
|
||
/** | ||
* Based on src/lib/api/chat.ts -> create | ||
* @param {string} uid1 | ||
|
@@ -122,19 +130,57 @@ const sendMessage = async (currentUserId, chatId, message, useLastMessageSeen = | |
}; | ||
|
||
const seed = async () => { | ||
// Seed two users | ||
const user1 = await createNewUser( | ||
{ email: '[email protected]' }, | ||
{ firstName: 'Bob', lastName: 'Dylan', countryCode: 'US' } | ||
); | ||
|
||
const user2 = await createNewUser( | ||
{ email: '[email protected]' }, | ||
{ firstName: 'Urbain', lastName: 'Servranckx', countryCode: 'BE', superfan: true } | ||
); | ||
// Create users | ||
const [user1, user2, user3] = await Promise.all([ | ||
// First user: non-superfan, has a garden | ||
createNewUser( | ||
{ email: '[email protected]' }, | ||
{ firstName: 'Bob', lastName: 'Dylan', countryCode: 'US' } | ||
).then(async (user1Inner) => { | ||
await createGarden(user1Inner.uid, { | ||
description: 'Hello, this is a test camping spot. You are welcome to stay!', | ||
location: { | ||
latitude: 50.952798579681854, | ||
longitude: 4.763172541851901 | ||
}, | ||
facilities: { | ||
capacity: 2, | ||
toilets: true, | ||
shower: false, | ||
electricity: true, | ||
water: false, | ||
drinkableWater: true, | ||
bonfire: true, | ||
tent: true | ||
}, | ||
photo: null, | ||
listed: true | ||
}); | ||
return user1Inner; | ||
}), | ||
// Second user: superfan, no garden | ||
createNewUser( | ||
{ email: '[email protected]' }, | ||
{ firstName: 'Urbain', lastName: 'Servranckx', countryCode: 'BE', superfan: true } | ||
), | ||
// Third user: no superfan, no garden, has past chats | ||
createNewUser( | ||
{ | ||
email: '[email protected]' | ||
}, | ||
{ firstName: 'Maria Louise', lastName: 'from Austria', countryCode: 'AT' } | ||
), | ||
// Fourth user: a non-superfan user without garden and without messages sent yet | ||
createNewUser( | ||
{ | ||
email: '[email protected]' | ||
}, | ||
{ firstName: 'Laura', lastName: 'Verheyden', countryCode: 'BE' } | ||
) | ||
]); | ||
|
||
// Send chats | ||
// TODO messages are sent without gardens being created, this is not realistic | ||
// TODO messages are sent to user 2 without that account having a garden, this is not realistic | ||
// initiated by 1 to 2 | ||
const chatId = await createChat(user1.uid, user2.uid, 'Hey, can I stay in your garden?', false); | ||
for (let i = 0; i < 10; i += 1) { | ||
|
@@ -143,13 +189,6 @@ const seed = async () => { | |
await sendMessage((even ? user2 : user1).uid, chatId, faker.lorem.sentences(), false); | ||
} | ||
|
||
const user3 = await createNewUser( | ||
{ | ||
email: '[email protected]' | ||
}, | ||
{ firstName: 'Maria Louise', lastName: 'from Austria', countryCode: 'AT' } | ||
); | ||
|
||
// from 3 to 1 | ||
await createChat(user3.uid, user1.uid, 'I have a question'); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.