From 6ffe3360f50b1d07d571d3dcd1b39aff9f632994 Mon Sep 17 00:00:00 2001 From: Manumartin95 Date: Thu, 5 Oct 2023 10:41:13 +0200 Subject: [PATCH 1/2] feat: add filter prop to projects combo and update schema --- .../components/combos/activity-form-combos.tsx | 5 ++++- .../components/combos/projects-combo.tsx | 15 +++++++++------ .../availability-table-filters.schema.ts | 6 +++--- .../availability-table-filters.tsx | 4 +++- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/features/binnacle/features/activity/ui/components/activity-form/components/combos/activity-form-combos.tsx b/src/features/binnacle/features/activity/ui/components/activity-form/components/combos/activity-form-combos.tsx index 02b81bc2..34774e6d 100644 --- a/src/features/binnacle/features/activity/ui/components/activity-form/components/combos/activity-form-combos.tsx +++ b/src/features/binnacle/features/activity/ui/components/activity-form/components/combos/activity-form-combos.tsx @@ -68,7 +68,10 @@ export const ActivityFormCombos = forwardRef( onChange={(item) => { if (item?.name !== project?.name) onProjectChange() }} - organization={organization} + projectOrganizationFilters={{ + open: true, + organizationIds: organization ? [organization.id] : undefined + }} /> onChange?: (item: Project) => void + projectOrganizationFilters: ProjectOrganizationFilters } export const ProjectsCombo = forwardRef((props, ref) => { - const { name = 'project', organization, control, isDisabled, onChange } = props + const { name = 'project', control, isDisabled, projectOrganizationFilters, onChange } = props const { t } = useTranslation() const [items, setItems] = useState([]) const { isLoading, executeUseCase } = useGetUseCase(GetProjectsQry) useEffect(() => { - if (!organization) { + if ( + !projectOrganizationFilters.organizationIds || + projectOrganizationFilters.organizationIds.length === 0 + ) { setItems([]) return } - executeUseCase({ organizationIds: [organization.id], open: true }).then((projects) => { + executeUseCase(projectOrganizationFilters).then((projects) => { setItems(projects) }) - }, [executeUseCase, organization]) + }, [executeUseCase, projectOrganizationFilters]) return ( = ({ onChange }) => { /> { handleChange({ projectIds: project ? [project?.id] : undefined }) }} isDisabled={projectDisabled} + projectOrganizationFilters={{ + organizationIds: organization ? [organization.id] : undefined + }} /> From e595363d2a086dc1759f05fd533c349b444a3f04 Mon Sep 17 00:00:00 2001 From: Manumartin95 Date: Thu, 5 Oct 2023 10:47:07 +0200 Subject: [PATCH 2/2] feat: update organization path --- .../organization/infrastructure/http-organization-repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/binnacle/features/organization/infrastructure/http-organization-repository.ts b/src/features/binnacle/features/organization/infrastructure/http-organization-repository.ts index 209026f9..00543e8e 100644 --- a/src/features/binnacle/features/organization/infrastructure/http-organization-repository.ts +++ b/src/features/binnacle/features/organization/infrastructure/http-organization-repository.ts @@ -6,7 +6,7 @@ import { OrganizationFilters } from '../domain/organization-filters' @singleton() export class HttpOrganizationRepository implements OrganizationRepository { - protected static organizationPath = `/api/organizations` + protected static organizationPath = `/api/organization` constructor(private httpClient: HttpClient) {}