Skip to content

Commit

Permalink
fix(TAA-136): addresses type error, wires up now returning decision n…
Browse files Browse the repository at this point in the history
…otes
  • Loading branch information
KlimekM committed Feb 5, 2025
1 parent bd686d0 commit c386be0
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 11 deletions.
22 changes: 17 additions & 5 deletions assets/approval-requests-bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/modules/approval-requests/ApprovalRequestListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function ApprovalRequestListPage({
const {
approvalRequests,
errorFetchingApprovalRequests: error,
approvalRequestStatus,
setApprovalRequestStatus,
isLoading,
} = useSearchApprovalRequests();
Expand Down Expand Up @@ -60,6 +61,7 @@ function ApprovalRequestListPage({
<Container>
<XXL isBold>Approval requests</XXL>

Check warning on line 62 in src/modules/approval-requests/ApprovalRequestListPage.tsx

View workflow job for this annotation

GitHub Actions / Lint JS files

Do not use hardcoded content as the children of the XXL component
<ApprovalRequestListFilters
approvalRequestStatus={approvalRequestStatus}
setApprovalRequestStatus={setApprovalRequestStatus}
setSearchTerm={setSearchTerm}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,24 @@ const DropdownFilterField = styled(Field)`
flex: 1;
`;

const ApprovalRequestStatusInputMap = {
any: "Any",
active: "Decision pending",
approved: "Approved",
rejected: "Denied",
withdrawn: "Withdrawn",
};

interface ApprovalRequestListFiltersProps {
approvalRequestStatus: ApprovalRequestDropdownStatus;
setApprovalRequestStatus: Dispatch<
SetStateAction<ApprovalRequestDropdownStatus>
>;
setSearchTerm: Dispatch<SetStateAction<string>>;
}

function ApprovalRequestListFilters({
approvalRequestStatus,
setApprovalRequestStatus,
setSearchTerm,
}: ApprovalRequestListFiltersProps) {
Expand Down Expand Up @@ -91,8 +101,13 @@ function ApprovalRequestListFilters({
</SearchField>
<DropdownFilterField>
<Label>Status:</Label>

Check warning on line 103 in src/modules/approval-requests/components/approval-request-list/ApprovalRequestListFilters.tsx

View workflow job for this annotation

GitHub Actions / Lint JS files

Do not use hardcoded content as the children of the Label component
<Combobox isEditable={false} onChange={handleChange}>
<Option value="any" isSelected label="Any" />
<Combobox
isEditable={false}
onChange={handleChange}
selectionValue={approvalRequestStatus}
inputValue={ApprovalRequestStatusInputMap[approvalRequestStatus]}
>
<Option value="any" label="Any" />
<Option value="active" label="Decision pending" />
{/* <Option value="clarification_requested" label="Info needed" /> */}
<Option value="approved" label="Approved" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,31 @@ function ApprovalRequestDetails({
</MD>
</Col>
</DetailRow>
{/* MKTODO: need to add decided at and decision notes when returning from the API */}
{approvalRequest.decided_at && (
<DetailRow>
<Col size={4}>
<FieldLabel>Decided</FieldLabel>
</Col>
<Col size={8}>
<MD>
{formatApprovalRequestDate(
approvalRequest.decided_at,
baseLocale
)}
</MD>
</Col>
</DetailRow>
)}
{approvalRequest.decision_notes.length > 0 && (
<DetailRow>
<Col size={4}>
<FieldLabel>Comment</FieldLabel>
</Col>
<Col size={8}>
<MD>{approvalRequest.decision_notes[0]}</MD>
</Col>
</DetailRow>
)}
</Container>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import styled from "styled-components";
import { MD } from "@zendeskgarden/react-typography";
import { getColorV8 } from "@zendeskgarden/react-theming";
import { Grid } from "@zendeskgarden/react-grid";
import type { MockTicket } from "../../types";
import { Tag } from "@zendeskgarden/react-tags";
import type { ApprovalRequestTicket } from "../../types";

const TicketContainer = styled(Grid)`
padding: ${(props) => props.theme.space.md}; /* 20px */
Expand Down Expand Up @@ -36,11 +36,16 @@ const CustomFieldsGrid = styled.div`
}
`;

const NULL_VALUE_PLACEHOLDER = "-";

function CustomFieldValue({
value,
}: {
value: string | boolean | Array<string> | undefined;
}) {
if (!value) {
return <MD>{NULL_VALUE_PLACEHOLDER}</MD>;
}
if (Array.isArray(value)) {
return (
<MD>
Expand All @@ -61,7 +66,7 @@ function CustomFieldValue({
}

interface ApprovalTicketDetailsProps {
ticket: MockTicket;
ticket: ApprovalRequestTicket;
}

function ApprovalTicketDetails({ ticket }: ApprovalTicketDetailsProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
export function useSearchApprovalRequests(): {
approvalRequests: SearchApprovalRequest[];
errorFetchingApprovalRequests: unknown;
approvalRequestStatus: ApprovalRequestDropdownStatus;
setApprovalRequestStatus: Dispatch<
SetStateAction<ApprovalRequestDropdownStatus>
>;
Expand Down Expand Up @@ -66,6 +67,7 @@ export function useSearchApprovalRequests(): {
return {
approvalRequests,
errorFetchingApprovalRequests: error,
approvalRequestStatus,
setApprovalRequestStatus,
isLoading: isLoading,
};
Expand Down
4 changes: 3 additions & 1 deletion src/modules/approval-requests/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export interface ApprovalRequest {
message: string;
status: ApprovalRequestStatus;
created_at: string;
assignee_user: ApprovalRequestUser;
created_by_user: ApprovalRequestUser;
decided_at: string | null;
decision_notes: string[];
assignee_user: ApprovalRequestUser;
ticket_details: ApprovalRequestTicket;
}

Expand Down

0 comments on commit c386be0

Please sign in to comment.