Skip to content

Commit

Permalink
suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Feb 21, 2020
1 parent e28d322 commit 0d68fde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,9 @@ export interface UseGetCasesState {
filterOptions: FilterOptions;
}

export interface QueryArgs {
page?: number;
perPage?: number;
sortField?: SortFieldCase;
sortOrder?: Direction;
}

export interface Action {
type: string;
payload?: AllCases | QueryArgs | FilterOptions;
payload?: AllCases | Partial<QueryParams> | FilterOptions;
}
const dataFetchReducer = (state: UseGetCasesState, action: Action): UseGetCasesState => {
switch (action.type) {
Expand Down Expand Up @@ -89,7 +82,7 @@ const initialData: AllCases = {
};
export const useGetCases = (): [
UseGetCasesState,
Dispatch<SetStateAction<QueryArgs>>,
Dispatch<SetStateAction<Partial<QueryParams>>>,
Dispatch<SetStateAction<FilterOptions>>
] => {
const [state, dispatch] = useReducer(dataFetchReducer, {
Expand All @@ -107,7 +100,7 @@ export const useGetCases = (): [
sortOrder: Direction.desc,
},
});
const [queryParams, setQueryParams] = useState(state.queryParams as QueryArgs);
const [queryParams, setQueryParams] = useState(state.queryParams as Partial<QueryParams>);
const [filterQuery, setFilters] = useState(state.filterOptions as FilterOptions);
const [, dispatchToaster] = useStateToaster();

Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/case/server/routes/api/update_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export function initUpdateCaseApi({ caseService, router }: RouteDeps) {
Object.keys(updateCase).forEach(key => {
if (
key === 'tags' &&
updateCase.tags &&
updateCase.tags.length === currentCase.tags.length &&
updateCase.tags.every((element, index) => element === currentCase.tags[index])
updateCase[key] &&
updateCase[key].length === currentCase[key].length &&
updateCase[key].every((element, index) => element === currentCase[key][index])
) {
delete updateCase.tags;
delete updateCase[key];
} else if (updateCase[key] === currentCase[key]) {
delete updateCase[key];
}
Expand Down

0 comments on commit 0d68fde

Please sign in to comment.