Skip to content

Commit

Permalink
Merge pull request #347 from Enterprise-CMCS/bruce
Browse files Browse the repository at this point in the history
feat(OY2-27179): 'Initial Intake Needed' sub status
  • Loading branch information
pkim-gswell authored Jan 29, 2024
2 parents 6f25758 + 6162d47 commit e0fe69e
Show file tree
Hide file tree
Showing 25 changed files with 543 additions and 443 deletions.
8 changes: 7 additions & 1 deletion src/packages/shared-types/opensearch/_.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ export type FilterType =
| "exists";

export type RangeValue = { gte?: string; lte?: string };
export type FilterValue = string | string[] | number | boolean | RangeValue;
export type FilterValue =
| string
| string[]
| number
| boolean
| RangeValue
| null;

export type Filterable<_FIELD> = {
type: FilterType;
Expand Down
2 changes: 2 additions & 0 deletions src/packages/shared-types/opensearch/changelog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Filterable as FIL,
QueryState,
AggQuery,
ExportHeaderOptions,
} from "./../_";
import {
OneMac,
Expand Down Expand Up @@ -34,3 +35,4 @@ export type Field = keyof Document | `${keyof Document}.keyword`;
export type Filterable = FIL<Field>;
export type State = QueryState<Field>;
export type Aggs = AggQuery<Field>;
export type ExportHeader = ExportHeaderOptions<Document>;
2 changes: 2 additions & 0 deletions src/packages/shared-types/opensearch/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Filterable as FIL,
QueryState,
AggQuery,
ExportHeaderOptions,
} from "./../_";
import { z } from "zod";
import { ItemResult as Changelog } from "./../changelog";
Expand Down Expand Up @@ -34,5 +35,6 @@ export type Field = keyof Document | `${keyof Document}.keyword`;
export type Filterable = FIL<Field>;
export type State = QueryState<Field>;
export type Aggs = AggQuery<Field>;
export type ExportHeader = ExportHeaderOptions<Document>;

export * from "./transforms";
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ export const transform = (id: string) => {
description: data.STATE_PLAN.SUMMARY_MEMO,
finalDispositionDate: getFinalDispositionDate(seatoolStatus, data),
leadAnalystOfficerId,
initialIntakeNeeded:
!leadAnalystName && seatoolStatus !== SEATOOL_STATUS.WITHDRAWN,
leadAnalystName,
planType: data.PLAN_TYPES?.[0].PLAN_TYPE_NAME as PlanType | null,
planTypeId: data.STATE_PLAN.PLAN_TYPE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
import { type FC, useCallback, Fragment } from "react";
import { type FC, useCallback } from "react";

import { Chip } from "@/components/Chip";
import { useOsUrl } from "@/components/Opensearch/main";
import { opensearch } from "shared-types";
import { useFilterDrawerContext } from "./FilterProvider";
import { useFilterDrawerContext } from "../FilterProvider";
import { checkMultiFilter } from "@/components/Opensearch";
import { useLabelMapping } from "@/hooks";

interface RenderProp {
export interface RenderProp {
filter: opensearch.main.Filterable;
index: number;
openDrawer: () => void;
clearFilter: (filter: opensearch.main.Filterable, valIndex?: number) => void;
}

// simple date range chips
const DateChip: FC<RenderProp> = ({
export const ChipBool: FC<RenderProp> = ({
filter,
openDrawer,
clearFilter,
}) => {
const value = filter.value as opensearch.RangeValue;
return (
<Chip
onChipClick={openDrawer}
onIconClick={() => {
clearFilter(filter);
}}
>
{filter?.label}: <strong>{value ? "Yes" : "No"}</strong>
</Chip>
);
};

export const ChipDate: FC<RenderProp> = ({
filter,
index,
openDrawer,
clearFilter,
}) => {
const value = filter.value as opensearch.RangeValue;
return (
<Chip
key={`${index}-${filter.field}`}
onChipClick={openDrawer}
onIconClick={() => {
clearFilter(filter);
Expand All @@ -39,10 +54,8 @@ const DateChip: FC<RenderProp> = ({
);
};

// array value chips
const ChipList: FC<RenderProp> = ({
export const ChipTerms: FC<RenderProp> = ({
filter,
index,
clearFilter,
openDrawer,
}) => {
Expand All @@ -51,12 +64,12 @@ const ChipList: FC<RenderProp> = ({
if (!Array.isArray(filter.value)) return null;

return (
<Fragment key={`${index}-${filter.field}-fragment`}>
<>
{filter.value.map((v, vindex) => {
const chipText = `${filter?.label + ": " ?? ""}${labelMap[v] ?? v}`;
return (
<Chip
key={`${index}-${vindex}-${filter.field}`}
key={`${vindex}-${filter.field}`}
onChipClick={openDrawer}
onIconClick={() => {
clearFilter(filter, vindex);
Expand All @@ -66,7 +79,7 @@ const ChipList: FC<RenderProp> = ({
</Chip>
);
})}
</Fragment>
</>
);
};

Expand Down Expand Up @@ -112,8 +125,12 @@ export const FilterChips: FC = () => {
<div className="justify-start items-center py-2 flex flex-wrap gap-y-2 gap-x-2">
{url.state.filters.map((filter, index) => {
const props: RenderProp = { clearFilter, openDrawer, filter, index };
if (filter.type === "range") return <DateChip {...props} />;
if (filter.type === "terms") return <ChipList {...props} />;
const key = `${filter.field}-${index}`;

if (filter.type === "range") return <ChipDate key={key} {...props} />;
if (filter.type === "terms") return <ChipTerms key={key} {...props} />;
if (filter.type === "match") return <ChipBool key={key} {...props} />;

return null;
})}
{twoOrMoreFiltersApplied && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Checkbox } from "@/components/Inputs";
import { FC } from "react";

export const FilterableBoolean: FC<{
value: boolean | null;
onChange: (val: boolean | null) => void;
}> = (props) => {
const yes = props.value === null ? false : props.value;
const no = props.value === null ? false : !props.value;

const onYes = (mhm: boolean) => {
props.onChange(mhm ? true : null);
};

const onNo = (mhm: boolean) => {
props.onChange(mhm ? false : null);
};

return (
<div className="flex flex-col items-start">
<Checkbox checked={yes} onCheckedChange={onYes} label="Yes" />
<Checkbox checked={no} onCheckedChange={onNo} label="No" />
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Props = {
options: { label: string; value: string }[];
};

export const FilterableCheckbox = (props: Props) => {
export const FilterableMultiCheck = (props: Props) => {
const onClear = () => {
props.onChange([]);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./Boolean";
export * from "./DateRange";
export * from "./Multicheck";
export * from "./Select";
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { opensearch } from "shared-types";
import { OsFilterComponentType } from "../../types";

/**
* @desc
* - label: ui label
* - field: opensearch field property (should match key)
* - component: filterable component type
* - prefix: query prefix
* - type: query type
* - value: query value
*/
export type DrawerFilterableGroup = {
label: string;
component: OsFilterComponentType;
} & opensearch.main.Filterable;

export const SELECT_STATE: DrawerFilterableGroup = {
label: "State",
field: "state.keyword",
component: "multiSelect",
prefix: "must",
type: "terms",
value: [],
};

export const CHECK_PLANTYPE: DrawerFilterableGroup = {
label: "Type",
field: "planType.keyword",
component: "multiCheck",
prefix: "must",
type: "terms",
value: [],
};

export const CHECK_CMSSTATUS: DrawerFilterableGroup = {
label: "Status",
field: "cmsStatus.keyword",
component: "multiCheck",
prefix: "must",
type: "terms",
value: [],
};

export const CHECK_STATESTATUS: DrawerFilterableGroup = {
label: "Status",
field: "stateStatus.keyword",
component: "multiCheck",
prefix: "must",
type: "terms",
value: [],
};

export const BOOL_INITIALINTAKENEEDED: DrawerFilterableGroup = {
label: "Initial Intake Needed",
field: "initialIntakeNeeded",
component: "boolean",
prefix: "must",
type: "match",
value: null,
};

export const CHECK_ACTIONTYPE: DrawerFilterableGroup = {
label: "Action Type",
field: "actionType.keyword",
component: "multiCheck",
prefix: "must",
type: "terms",
value: [],
};

export const DATE_SUBMISSION: DrawerFilterableGroup = {
label: "Initial Submission",
field: "submissionDate",
component: "dateRange",
prefix: "must",
type: "range",
value: { gte: undefined, lte: undefined },
};

export const DATE_RAIRECEIVED: DrawerFilterableGroup = {
label: "Formal RAI Response",
field: "raiReceivedDate",
component: "dateRange",
prefix: "must",
type: "range",
value: { gte: undefined, lte: undefined },
};

export const SELECT_CPOC: DrawerFilterableGroup = {
label: "CPOC Name",
field: "leadAnalystName.keyword",
component: "multiSelect",
prefix: "must",
type: "terms",
value: [],
};

export const SELECT_ORIGIN: DrawerFilterableGroup = {
label: "Submission Source",
field: "origin.keyword",
component: "multiSelect",
prefix: "must",
type: "terms",
value: [],
};
Loading

0 comments on commit e0fe69e

Please sign in to comment.