Skip to content

Commit

Permalink
feat(solidarity): adds getStatus func to assign correct status to sup…
Browse files Browse the repository at this point in the history
…port request
  • Loading branch information
Viviane Dias committed Dec 7, 2023
1 parent bf9209e commit 9e04063
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/listener-solidarity/src/utils/__tests__/getStatus.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { getStatus } from "../getSupportRequests";

describe("getStatus", () => {
it("should return 'open' if zendeskStatus is an empty string", () => {
expect(getStatus("")).toStrictEqual("open");
});

it("should return 'open' if zendeskStatus is not found in newStatus key/value pair", () => {
expect(getStatus("encaminhamento__realizado")).toStrictEqual("open");
});

it("should return 'open' if zendeskStatus is 'solicitacao_recebida'", () => {
expect(getStatus("solicitação_recebida")).toStrictEqual("open");
});

it("should return 'duplicated' if zendeskStatus is 'solicitação_repetida'", () => {
expect(getStatus("solicitação_repetida")).toStrictEqual("duplicated");
});
});
17 changes: 17 additions & 0 deletions packages/listener-solidarity/src/utils/getSupportRequests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getStatusAcolhimento } from ".";
import { SupportRequestPayload, Ticket, User } from "../types";

export function getSupportType(subject: string) {
Expand All @@ -19,6 +20,22 @@ export function sanitizeCity(city: string) {
return city;
}

export function getStatus(zendeskStatus: string) {
if (!zendeskStatus) return "open";

const newStatus = {
solicitação_repetida: "duplicated",
solicitação_recebida: "open",
};

const unsupportedStatus = Object.keys(newStatus).find(
(key) => zendeskStatus === key
);
if (!unsupportedStatus) return "open";

return newStatus[zendeskStatus];
}

export default function getSupportRequests(
ticket: Ticket,
msrs: User[]
Expand Down

0 comments on commit 9e04063

Please sign in to comment.