diff --git a/src/lib/assertUnreachable.ts b/src/lib/assertUnreachable.ts new file mode 100644 index 00000000..ef3f4ddc --- /dev/null +++ b/src/lib/assertUnreachable.ts @@ -0,0 +1,3 @@ +export function assertUnreachable(_: never, defaultValue: T): T { + return defaultValue; +} diff --git a/src/providers/github/components/IssueCard/IssueCard.tsx b/src/providers/github/components/IssueCard/IssueCard.tsx index 51154a69..63708c75 100644 --- a/src/providers/github/components/IssueCard/IssueCard.tsx +++ b/src/providers/github/components/IssueCard/IssueCard.tsx @@ -19,6 +19,7 @@ export interface IIssue { url: string; html_url: string; state: 'open' | 'closed' | 'merged'; + isDraft: boolean; status: IssueStatus; number: number; createdAt: string; @@ -101,7 +102,7 @@ export const IssueCard = compose(
- + = { - open: 'text-green-500', - closed: 'text-red-500', - merged: 'text-purple-500', -}; +import {assertUnreachable} from "../../../../lib/assertUnreachable"; interface IProps { - type: IIssue['type']; - state: IIssue['state']; + issue: Pick; } -export const IssueStatusIndicator = ({ type, state }: IProps) => ( +export const IssueStatusIndicator = ({ issue }: IProps) => ( ); + +function getColor(state: IIssue['state'], isDraft: boolean) +{ + switch (state) { + case 'open': + return isDraft ? 'text-gray-500' : 'text-green-500'; + case 'closed': + return 'text-red-500'; + case 'merged': + return 'text-purple-500'; + default: + return assertUnreachable(state, 'text-gray-500'); + } +} diff --git a/src/providers/github/fetchers/graphql/query.ts b/src/providers/github/fetchers/graphql/query.ts index 87615227..36c3a41e 100644 --- a/src/providers/github/fetchers/graphql/query.ts +++ b/src/providers/github/fetchers/graphql/query.ts @@ -35,6 +35,7 @@ const pullRequestFragment = ` fragment PullRequestFragment on PullRequest { ${commonFields} mergeable + isDraft reviews { totalCount }