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

Add OwnerKind type #1073

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions frontend/src/models/HousingFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
LocalityKind,
Occupancy,
OCCUPANCY_VALUES,
OWNER_KIND_VALUES,
OwnerAge,
OwnerKind,
OwnershipKind,
RoomCount,
VacancyRate
Expand Down Expand Up @@ -63,12 +65,11 @@ export const noCampaignOption: SelectOption = {
};
export type NoCampaign = typeof noCampaignOption.value;

export const ownerKindOptions: SelectOption[] = [
{ value: 'Particulier', label: 'Particulier' },
{ value: 'Investisseur', label: 'Investisseur' },
{ value: 'SCI', label: 'SCI' },
{ value: 'Autre', label: 'Autres' }
];
export const ownerKindOptions: SelectOption<OwnerKind>[] =
OWNER_KIND_VALUES.map((kind) => ({
value: kind,
label: kind
}));

export const campaignsCountOptions: SelectOption<CampaignCount>[] = [
{ value: '0', label: 'Dans aucune campagne en cours' },
Expand Down
3 changes: 2 additions & 1 deletion packages/models/src/HousingFiltersDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EnergyConsumption } from './EnergyConsumption';
import { HousingKind } from './HousingKind';
import { CampaignCount } from './CampaignCount';
import { RoomCount } from './RoomCount';
import { OwnerKind } from './OwnerKind';

export interface HousingFiltersDTO {
housingIds?: string[];
Expand All @@ -21,7 +22,7 @@ export interface HousingFiltersDTO {
campaignsCounts?: CampaignCount[];
campaignIds?: Array<string | null>;
ownerIds?: string[];
ownerKinds?: string[];
ownerKinds?: OwnerKind[];
ownerAges?: OwnerAge[];
multiOwners?: boolean[];
beneficiaryCounts?: BeneficiaryCount[];
Expand Down
11 changes: 11 additions & 0 deletions packages/models/src/OwnerKind.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const OWNER_KIND_VALUES = [
'Particulier',
'SCI, Copropriété, Autres personnes morales',
'Promoteur, Investisseur privé',
'Etat et collectivité territoriale',
'Bailleur social, Aménageur, Investisseur public',
'Autres',
'Absence de propriétaire'
] as const;

export type OwnerKind = (typeof OWNER_KIND_VALUES)[number];
1 change: 1 addition & 0 deletions packages/models/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export * from './NoteDTO';
export * from './Occupancy';
export * from './OwnerAge';
export * from './OwnerDTO';
export * from './OwnerKind';
export * from './OwnershipKind';
export * from './Pagination';
export * from './ProspectDTO';
Expand Down
5 changes: 4 additions & 1 deletion packages/schemas/src/housing-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
LIVING_AREA_VALUES,
OCCUPANCY_VALUES,
OWNER_AGE_VALUES,
OWNER_KIND_VALUES,
OWNERSHIP_KIND_VALUES,
ROOM_COUNT_VALUES,
VACANCY_RATE_VALUES
Expand Down Expand Up @@ -44,7 +45,9 @@ export const housingFilters: ObjectSchema<HousingFiltersDTO> = object({
ownerIds: array()
.transform(commaSeparatedString)
.of(string().uuid().required()),
ownerKinds: array().transform(commaSeparatedString).of(string().required()),
ownerKinds: array()
.transform(commaSeparatedString)
.of(string().oneOf(OWNER_KIND_VALUES).required()),
ownerAges: array()
.transform(commaSeparatedString)
.of(string().oneOf(OWNER_AGE_VALUES).required()),
Expand Down
3 changes: 2 additions & 1 deletion packages/schemas/src/test/housing-filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
LIVING_AREA_VALUES,
OCCUPANCY_VALUES,
OWNER_AGE_VALUES,
OWNER_KIND_VALUES,
OWNERSHIP_KIND_VALUES,
ROOM_COUNT_VALUES,
VACANCY_RATE_VALUES
Expand All @@ -28,7 +29,7 @@ describe('Housing filters', () => {
campaignsCounts: fc.array(fc.constantFrom(...CAMPAIGN_COUNT_VALUES)),
campaignIds: fc.array(fc.oneof(fc.constant(null), fc.uuid())),
ownerIds: fc.array(fc.uuid()),
ownerKinds: fc.array(fc.string({ minLength: 1 })),
ownerKinds: fc.array(fc.constantFrom(...OWNER_KIND_VALUES)),
ownerAges: fc.array(fc.constantFrom(...OWNER_AGE_VALUES)),
multiOwners: fc.array(fc.boolean()),
beneficiaryCounts: fc.array(fc.constantFrom(...BENEFIARY_COUNT_VALUES)),
Expand Down
Loading