-
Notifications
You must be signed in to change notification settings - Fork 0
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 #60 from ChangePlusPlusVandy/fake-data-update
Fake data update
- Loading branch information
Showing
12 changed files
with
367 additions
and
237 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
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 |
---|---|---|
|
@@ -30,10 +30,7 @@ const dummyEventData: QueriedVolunteerEventData = { | |
}, | ||
phone: '123-456-7890', | ||
email: '[email protected]', | ||
program: { | ||
_id: new mongoose.Types.ObjectId(), | ||
tagName: 'BNFK', | ||
}, | ||
program: new mongoose.Types.ObjectId(), | ||
requireApplication: true, | ||
volunteers: [], | ||
tags: [], | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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,51 @@ | ||
import dbConnect from '@/lib/dbConnect'; | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
import Tags from 'bookem-shared/src/models/Tags'; | ||
import VolunteerPrograms from 'bookem-shared/src/models/VolunteerPrograms'; | ||
import { INSERTED_PROGRAMS, INSERTED_TAGS } from './constants'; | ||
import { generateProgram, generateTag } from './helper-functions'; | ||
|
||
export default async function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse | ||
) { | ||
switch (req.method) { | ||
case 'GET': | ||
try { | ||
// Connect to the database | ||
await dbConnect(); | ||
|
||
// TODO: | ||
// delete all tags | ||
await Tags.deleteMany({}); | ||
|
||
// delete all programs | ||
await VolunteerPrograms.deleteMany({}); | ||
|
||
// Generate programs | ||
INSERTED_PROGRAMS.forEach(async program => { | ||
const generatedProgram = generateProgram(program); | ||
await VolunteerPrograms.insertMany(generatedProgram); | ||
}); | ||
|
||
// Generate tags | ||
INSERTED_TAGS.forEach(async tag => { | ||
const genratedTag = generateTag(tag); | ||
await Tags.insertMany(genratedTag); | ||
}); | ||
|
||
res.status(200).json({ | ||
success: true, | ||
message: 'Inserted fake tags and program data', | ||
}); | ||
} catch (error: any) { | ||
res.status(500).json({ success: false, error: error.message }); | ||
} | ||
|
||
break; | ||
|
||
default: | ||
res.status(400).json({ success: false }); | ||
break; | ||
} | ||
} |
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.
2a77b40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
bookem-user – ./
bookem-user.vercel.app
bookem-user-bookem-user.vercel.app
bookem-user-git-main-bookem-user.vercel.app