Skip to content

Commit

Permalink
feat: update openapi signalement post pg migration
Browse files Browse the repository at this point in the history
  • Loading branch information
MaGOs92 committed Jul 5, 2024
1 parent 4867d2f commit a83eee4
Show file tree
Hide file tree
Showing 23 changed files with 163 additions and 98 deletions.
2 changes: 1 addition & 1 deletion components/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Breadcrumbs({
if (innerPath === "signalements" && router.query.idSignalement) {
const signalementId = router.query.idSignalement;
const signalement = signalements.find(
(signalement) => signalement._id === signalementId
(signalement) => signalement.id === signalementId
);
signalementLabel = signalement && getSignalementLabel(signalement);
}
Expand Down
3 changes: 2 additions & 1 deletion components/signalement/numero/signalement-update-numero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Numero, Position, Voie, VoiesService } from "@/lib/openapi";
import {
Signalement,
Position as PositionSignalement,
NumeroChangesRequestedDTO,
} from "@/lib/openapi-signalement";

interface SignalementUpdateNumeroProps {
Expand Down Expand Up @@ -93,7 +94,7 @@ function SignalementUpdateNumero({
const [numeroEditorValue, setNumeroEditorValue] = useState(existingLocation);

const { numero, suffixe, positions, parcelles, nomVoie } =
signalement.changesRequested;
signalement.changesRequested as NumeroChangesRequestedDTO;

useEffect(() => {
const refKeys = Object.keys(refs);
Expand Down
10 changes: 5 additions & 5 deletions components/signalement/signalement-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ function SignalementList({

<InfiniteScrollList items={scrollableItems}>
{(signalement) => (
<Table.Row key={signalement._id} paddingRight={8} minHeight={48}>
<Table.Row key={signalement.id} paddingRight={8} minHeight={48}>
<Table.Cell flex="0 1 40px">
<Checkbox
checked={selectedSignalements.includes(signalement._id)}
onChange={() => onToggleSelect([signalement._id])}
checked={selectedSignalements.includes(signalement.id)}
onChange={() => onToggleSelect([signalement.id])}
/>
</Table.Cell>
<Table.TextCell flex="2">{signalement.label}</Table.TextCell>
Expand All @@ -100,14 +100,14 @@ function SignalementList({
<Menu.Group>
<Menu.Item
icon={SendToMapIcon}
onSelect={() => onSelect(signalement._id)}
onSelect={() => onSelect(signalement.id)}
>
Traiter
</Menu.Item>
<Menu.Item
icon={TrashIcon}
intent="danger"
onSelect={() => onIgnore(signalement._id)}
onSelect={() => onIgnore(signalement.id)}
>
Ignorer
</Menu.Item>
Expand Down
9 changes: 7 additions & 2 deletions components/signalement/signalement-viewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Pane, Paragraph } from "evergreen-ui";
import React from "react";
import { positionsTypesList } from "@/lib/positions-types-list";
import { Signalement } from "@/lib/openapi-signalement";
import {
NumeroChangesRequestedDTO,
Signalement,
ToponymeChangesRequestedDTO,
} from "@/lib/openapi-signalement";
import { Numero, Toponyme, Voie } from "@/lib/openapi";

interface SignalementViewerProps {
Expand All @@ -26,7 +30,8 @@ function SignalementViewer({
existingLocation,
}: SignalementViewerProps) {
const { numero, suffixe, nomVoie, positions, parcelles, nom } =
signalement.changesRequested;
signalement.changesRequested as NumeroChangesRequestedDTO &
ToponymeChangesRequestedDTO;

return (
<Pane padding={16}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import MarkersContext from "@/contexts/markers";
import {
Signalement,
Position as PositionSignalement,
ToponymeChangesRequestedDTO,
} from "@/lib/openapi-signalement";

interface SignalementUpdateToponymeProps {
Expand Down Expand Up @@ -45,7 +46,8 @@ function SignalementUpdateToponyme({
handleClose,
commune,
}: SignalementUpdateToponymeProps) {
const { nom, positions, parcelles } = signalement.changesRequested;
const { nom, positions, parcelles } =
signalement.changesRequested as ToponymeChangesRequestedDTO;

const nomInputRef = useRef<HTMLDivElement>(null);
const positionsInputRef = useRef<HTMLDivElement>(null);
Expand Down
7 changes: 5 additions & 2 deletions components/signalement/voie/signalement-update-voie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import ReactDOM from "react-dom";
import { CommuneType } from "@/types/commune";
import SignalementCard from "../signalement-card";
import VoieEditor from "@/components/bal/voie-editor";
import { Signalement } from "@/lib/openapi-signalement";
import {
Signalement,
VoieChangesRequestedDTO,
} from "@/lib/openapi-signalement";
import { Voie } from "@/lib/openapi";

interface SignalementUpdateVoieProps {
Expand All @@ -21,7 +24,7 @@ function SignalementUpdateVoie({
handleSubmit,
handleClose,
}: SignalementUpdateVoieProps) {
const { nom } = signalement.changesRequested;
const { nom } = signalement.changesRequested as VoieChangesRequestedDTO;
const formInputRef = useRef<HTMLDivElement>(null);

const [changes, setChanges] = useState({
Expand Down
12 changes: 8 additions & 4 deletions lib/openapi-signalement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,27 @@ export { OpenAPI } from './core/OpenAPI';
export type { OpenAPIConfig } from './core/OpenAPI';

export type { Author } from './models/Author';
export type { AuthorDTO } from './models/AuthorDTO';
export type { ChangesRequested } from './models/ChangesRequested';
export type { AuthorInput } from './models/AuthorInput';
export type { Client } from './models/Client';
export type { CreateClientDTO } from './models/CreateClientDTO';
export { CreateSignalementDTO } from './models/CreateSignalementDTO';
export { CreateSourceDTO } from './models/CreateSourceDTO';
export type { DeleteNumeroChangesRequestedDTO } from './models/DeleteNumeroChangesRequestedDTO';
export { ExistingLocation } from './models/ExistingLocation';
export { ExistingNumero } from './models/ExistingNumero';
export { ExistingToponyme } from './models/ExistingToponyme';
export { ExistingVoie } from './models/ExistingVoie';
export type { ObjectId } from './models/ObjectId';
export type { NumeroChangesRequestedDTO } from './models/NumeroChangesRequestedDTO';
export type { PaginatedSignalementsDTO } from './models/PaginatedSignalementsDTO';
export type { Point } from './models/Point';
export { Position } from './models/Position';
export type { PositionCoordinatesDTO } from './models/PositionCoordinatesDTO';
export type { PositionDTO } from './models/PositionDTO';
export { Signalement } from './models/Signalement';
export { Source } from './models/Source';
export type { Source } from './models/Source';
export type { ToponymeChangesRequestedDTO } from './models/ToponymeChangesRequestedDTO';
export { UpdateSignalementDTO } from './models/UpdateSignalementDTO';
export type { VoieChangesRequestedDTO } from './models/VoieChangesRequestedDTO';

export { ClientsService } from './services/ClientsService';
export { SignalementsService } from './services/SignalementsService';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
/* tslint:disable */
/* eslint-disable */

export type AuthorDTO = {
export type AuthorInput = {
email?: string | null;
captchaToken: string;
};

17 changes: 0 additions & 17 deletions lib/openapi-signalement/models/ChangesRequested.ts

This file was deleted.

11 changes: 5 additions & 6 deletions lib/openapi-signalement/models/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
/* tslint:disable */
/* eslint-disable */

import type { ObjectId } from './ObjectId';

export type Client = {
_id: ObjectId;
_createdAt: number;
_updatedAt: number;
_deletedAt?: number | null;
id: string;
createdAt: string;
updatedAt: string;
deletedAt?: string | null;
nom: string;
processedSignalements?: Array<string> | null;
};

16 changes: 11 additions & 5 deletions lib/openapi-signalement/models/CreateSignalementDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
/* tslint:disable */
/* eslint-disable */

import type { AuthorDTO } from './AuthorDTO';
import type { ExistingLocation } from './ExistingLocation';
import type { AuthorInput } from './AuthorInput';
import type { DeleteNumeroChangesRequestedDTO } from './DeleteNumeroChangesRequestedDTO';
import type { ExistingNumero } from './ExistingNumero';
import type { ExistingToponyme } from './ExistingToponyme';
import type { ExistingVoie } from './ExistingVoie';
import type { NumeroChangesRequestedDTO } from './NumeroChangesRequestedDTO';
import type { ToponymeChangesRequestedDTO } from './ToponymeChangesRequestedDTO';
import type { VoieChangesRequestedDTO } from './VoieChangesRequestedDTO';

export type CreateSignalementDTO = {
codeCommune: string;
type: CreateSignalementDTO.type;
author?: AuthorDTO | null;
existingLocation?: ExistingLocation | null;
changesRequested: Record<string, any> | null;
author?: AuthorInput | null;
existingLocation?: (ExistingNumero | ExistingVoie | ExistingToponyme) | null;
changesRequested: (NumeroChangesRequestedDTO | DeleteNumeroChangesRequestedDTO | ToponymeChangesRequestedDTO | VoieChangesRequestedDTO) | null;
};

export namespace CreateSignalementDTO {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* tslint:disable */
/* eslint-disable */

export type ObjectId = {
export type DeleteNumeroChangesRequestedDTO = {
comment: string;
};

16 changes: 16 additions & 0 deletions lib/openapi-signalement/models/NumeroChangesRequestedDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { PositionDTO } from './PositionDTO';

export type NumeroChangesRequestedDTO = {
numero: string;
suffixe?: string;
nomVoie: string;
parcelles: Array<string>;
positions: Array<PositionDTO>;
comment?: string | null;
};

4 changes: 1 addition & 3 deletions lib/openapi-signalement/models/PaginatedSignalementsDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
/* tslint:disable */
/* eslint-disable */

import type { Signalement } from './Signalement';

export type PaginatedSignalementsDTO = {
data: Array<Signalement>;
data: Array<any[]>;
page: number;
limit: number;
total: number;
Expand Down
10 changes: 10 additions & 0 deletions lib/openapi-signalement/models/PositionCoordinatesDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type PositionCoordinatesDTO = {
coordinates: Array<number>;
type: string;
};

12 changes: 12 additions & 0 deletions lib/openapi-signalement/models/PositionDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { PositionCoordinatesDTO } from './PositionCoordinatesDTO';

export type PositionDTO = {
point: PositionCoordinatesDTO;
type: string;
};

18 changes: 10 additions & 8 deletions lib/openapi-signalement/models/Signalement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@
/* eslint-disable */

import type { Author } from './Author';
import type { ChangesRequested } from './ChangesRequested';
import type { Client } from './Client';
import type { DeleteNumeroChangesRequestedDTO } from './DeleteNumeroChangesRequestedDTO';
import type { ExistingNumero } from './ExistingNumero';
import type { ExistingToponyme } from './ExistingToponyme';
import type { ExistingVoie } from './ExistingVoie';
import type { ObjectId } from './ObjectId';
import type { NumeroChangesRequestedDTO } from './NumeroChangesRequestedDTO';
import type { Source } from './Source';
import type { ToponymeChangesRequestedDTO } from './ToponymeChangesRequestedDTO';
import type { VoieChangesRequestedDTO } from './VoieChangesRequestedDTO';

export type Signalement = {
_id: ObjectId;
_createdAt: number;
_updatedAt: number;
_deletedAt?: number | null;
id: string;
createdAt: string;
updatedAt: string;
deletedAt?: string | null;
codeCommune: string;
type: Signalement.type;
author?: Author | null;
source: Source;
existingLocation?: (ExistingNumero | ExistingVoie | ExistingToponyme) | null;
changesRequested: ChangesRequested;
changesRequested: (NumeroChangesRequestedDTO | DeleteNumeroChangesRequestedDTO | ToponymeChangesRequestedDTO | VoieChangesRequestedDTO);
status?: Signalement.status | null;
source: Source;
processedBy?: Client | null;
};

Expand Down
23 changes: 6 additions & 17 deletions lib/openapi-signalement/models/Source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,13 @@
/* tslint:disable */
/* eslint-disable */

import type { ObjectId } from './ObjectId';

export type Source = {
_id: ObjectId;
_createdAt: number;
_updatedAt: number;
_deletedAt?: number | null;
id: string;
createdAt: string;
updatedAt: string;
deletedAt?: string | null;
nom: string;
type: Source.type;
type: string;
signalements?: Array<string> | null;
};

export namespace Source {

export enum type {
PUBLIC = 'PUBLIC',
PRIVATE = 'PRIVATE',
}


}

14 changes: 14 additions & 0 deletions lib/openapi-signalement/models/ToponymeChangesRequestedDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { PositionDTO } from './PositionDTO';

export type ToponymeChangesRequestedDTO = {
nom: string;
parcelles: Array<string>;
positions: Array<PositionDTO>;
comment?: string | null;
};

10 changes: 10 additions & 0 deletions lib/openapi-signalement/models/VoieChangesRequestedDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type VoieChangesRequestedDTO = {
nom: string;
comment?: string | null;
};

Loading

0 comments on commit a83eee4

Please sign in to comment.