Skip to content

Commit

Permalink
Update create organization endpoint to populate state and region.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Grayson committed Mar 4, 2024
1 parent b14b5aa commit 73d45bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions backend/src/api/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,17 @@ export const update = wrapHandler(async (event) => {
*/
export const create = wrapHandler(async (event) => {
if (!isGlobalWriteAdmin(event)) return Unauthorized;
const body = await validateBody(NewOrganization, event.body);
const body = await validateBody(NewOrUpdatedOrganization, event.body);
await connectToDatabase();

if ('tags' in body) {
body.tags = await findOrCreateTags(body.tags);
}
const organization = await Organization.create({
const organization = Organization.create({
...body,
createdBy: { id: event.requestContext.authorizer!.id },
parent: { id: body.parent }
parent: { id: body.parent },
regionId: REGION_STATE_MAP[body.stateName!] ?? null
});
const res = await organization.save();
return {
Expand Down

0 comments on commit 73d45bf

Please sign in to comment.