Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Rewrite AutoCompleteDepartment to TypeScript #27198

Merged
merged 9 commits into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/meteor/client/components/AutoCompleteDepartment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export const AutoCompleteDepartment = ({
);

const department = useMemo(() => {
const findValue = typeof value === 'string' ? value : value.value || '';
return sortedByName.find((dep) => dep._id === findValue)?.value;
const valueFound = typeof value !== 'object' ? value : value.value || '';
return sortedByName.find((dep) => dep.value.value === valueFound)?.value;
}, [sortedByName, value]);

return (
Expand All @@ -76,7 +76,9 @@ export const AutoCompleteDepartment = ({
filter={departmentsFilter}
// Workaround for setFilter weird typing
setFilter={setDepartmentsFilter as (value: string | number | undefined) => void}
options={sortedByName.map((dep) => ({ value: dep._id, label: dep.name }))}
// TODO: Fix typing on fuselage
// Workaround for options wrong typing
aleksandernsilva marked this conversation as resolved.
Show resolved Hide resolved
options={sortedByName as any}
placeholder={t('Select_an_option')}
data-qa='autocomplete-department'
endReached={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const FilterByText: FilterByTextType = ({ setFilter, reload, customFields, setCu
guest,
servedBy,
status,
...(department?.value && department.value !== 'all' && { department: department.value }),
department: department?.value && department.value !== 'all' ? department.value : '',
from: from && moment(new Date(from)).utc().format('YYYY-MM-DDTHH:mm:ss'),
to: to && moment(new Date(to)).utc().format('YYYY-MM-DDTHH:mm:ss'),
tags: tags.map((tag) => tag.label),
Expand Down