Skip to content

Commit

Permalink
fix(FilterPresetForm): simplify api
Browse files Browse the repository at this point in the history
  • Loading branch information
LamaEats committed Oct 13, 2023
1 parent 7775e23 commit 50be538
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/components/FilterCreateForm/FilterCreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import * as Sentry from '@sentry/nextjs';

import { errorsProvider } from '../../utils/forms';
import { createFilterSchema, CreateFilter } from '../../schema/filter';
import { Nullish, Void } from '../../types/void';
import { FilterById } from '../../../trpc/inferredTypes';
import { useFilterResource } from '../../hooks/useFilterResource';
import { ModalEvent, dispatchModalEvent } from '../../utils/dispatchModal';

Expand All @@ -17,7 +15,7 @@ interface FilterCreateFormProps {
mode: CreateFilter['mode'];
params: CreateFilter['params'];

onSubmit?: Void<Nullish<FilterById>>;
onSubmit?: (id: string) => void;
}

const FilterCreateForm: React.FC<FilterCreateFormProps> = ({ mode, params, onSubmit }) => {
Expand Down Expand Up @@ -48,7 +46,7 @@ const FilterCreateForm: React.FC<FilterCreateFormProps> = ({ mode, params, onSub
const [data, err] = await createFilter(form);

if (data && !err) {
onSubmit?.(data);
onSubmit?.(data.id);
}
},
[createFilter, onSubmit],
Expand Down
4 changes: 2 additions & 2 deletions src/components/FilterDeleteForm/FilterDeleteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { tr } from './FilterDeleteForm.i18n';
interface FilterDeleteFormProps {
preset: FilterById;

onSubmit: (preset: FilterById) => void;
onSubmit: (params: string) => void;
onCancel: () => void;
}

Expand All @@ -23,7 +23,7 @@ const FilterDeleteForm: React.FC<FilterDeleteFormProps> = ({ preset, onSubmit, o
const [data, err] = await deleteFilter(preset.id);

if (data) {
onSubmit(preset);
onSubmit(preset.params);
} else if (err) {
Sentry.captureException(err);
}
Expand Down

0 comments on commit 50be538

Please sign in to comment.