From 119082fd948e4527bb4144e446b23d97749113f2 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Thu, 7 Mar 2024 10:21:57 -0500 Subject: [PATCH] Clean Mirage People route --- web/mirage/config.ts | 69 ++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 44 deletions(-) diff --git a/web/mirage/config.ts b/web/mirage/config.ts index 5b209db53..926998028 100644 --- a/web/mirage/config.ts +++ b/web/mirage/config.ts @@ -377,6 +377,7 @@ export default function (mirageConfig) { * Jira requests * *************************************************************************/ + // Get issue this.get("/jira/issues/:issue_id", (schema, request) => { const issue = schema.jiraIssues.findBy({ @@ -789,32 +790,12 @@ export default function (mirageConfig) { /************************************************************************* * - * HEAD requests + * People * *************************************************************************/ - this.head("/me", (schema, _request) => { - let isLoggedIn = schema.db.me[0].isLoggedIn; - - if (isLoggedIn) { - return new Response(200, {}); - } else { - return new Response(401, {}); - } - }); - - /************************************************************************* - * - * POST requests - * - *************************************************************************/ - - /** - * Used by the `PeopleSelect` component to query for people - * without exposing personal information like a GET request might. - */ + // Query via the PeopleSelect this.post("/people", (schema, request) => { - // Grab the query from the request body let query: string = JSON.parse(request.requestBody).query; // Search everyone's first emailAddress for matches @@ -831,6 +812,28 @@ export default function (mirageConfig) { return new Response(200, {}, matches.models); }); + /************************************************************************* + * + * HEAD requests + * + *************************************************************************/ + + this.head("/me", (schema, _request) => { + let isLoggedIn = schema.db.me[0].isLoggedIn; + + if (isLoggedIn) { + return new Response(200, {}); + } else { + return new Response(401, {}); + } + }); + + /************************************************************************* + * + * POST requests + * + *************************************************************************/ + /** * Used when publishing a draft for review. * Updates the document's status and isDraft properties. @@ -951,28 +954,6 @@ export default function (mirageConfig) { } }); - /** - * Used by the PeopleSelect component to get a list of people. - * Used to confirm that an approver has access to a document. - */ - this.get("/people", (schema, request) => { - if (request.queryParams.emails !== "") { - const emails = request.queryParams.emails.split(","); - - if (emails.length === 0) { - return new Response(200, {}, []); - } - - const hermesUsers = emails.map((email: string) => { - return { emailAddresses: [{ value: email }], photos: [] }; - }); - - return new Response(200, {}, hermesUsers); - } - - return schema.people.all(); - }); - /** * Used by the Document route to get a document. */