diff --git a/db/migrations/06-add_udap_drac.sql b/db/migrations/06-add_udap_drac.sql index df0f2077..246e3533 100644 --- a/db/migrations/06-add_udap_drac.sql +++ b/db/migrations/06-add_udap_drac.sql @@ -1,3 +1,3 @@ ALTER TABLE udap ADD COLUMN marianne_text text; -ALTER TABLE udap ADD COLUMN drac_text date; -ALTER TABLE udap ADD COLUMN udap_text date; \ No newline at end of file +ALTER TABLE udap ADD COLUMN drac_text text; +ALTER TABLE udap ADD COLUMN udap_text text; \ No newline at end of file diff --git a/db/migrations/07-insert_drac.sql b/db/migrations/07-insert_drac.sql new file mode 100644 index 00000000..a3061094 --- /dev/null +++ b/db/migrations/07-insert_drac.sql @@ -0,0 +1,7 @@ + +UPDATE udap SET marianne_text='Préfet de la région Nouvelle-Aquitaine', drac_text='Direction régionale des affaires culturelles de Nouvelle-Aquitaine', udap_text='Unité départementale de l''architecture et du patrimone des Landes' WHERE id='udap-landes'; +UPDATE udap SET marianne_text='Préfet de la région Nouvelle-Aquitaine', drac_text='Direction régionale des affaires culturelles de Nouvelle-Aquitaine', udap_text='Unité départementale de l''architecture et du patrimone des Deux-Sèvres' WHERE id= 'udap-deux-sèvres'; +UPDATE udap SET marianne_text='Préfet de la région Nouvelle-Aquitaine', drac_text='Direction régionale des affaires culturelles de Nouvelle-Aquitaine', udap_text='Unité départementale de l''architecture et du patrimone de la Vienne' WHERE id= 'udap-vienne'; +UPDATE udap SET marianne_text='Préfet de la région Nouvelle-Aquitaine', drac_text='Direction régionale des affaires culturelles de Nouvelle-Aquitaine', udap_text='Unité départementale de l''architecture et du patrimone de la Charente-Maritime' WHERE id= 'udap-charente-maritime'; +UPDATE udap SET marianne_text='Préfet de la région Nouvelle-Aquitaine', drac_text='Direction régionale des affaires culturelles de Nouvelle-Aquitaine', udap_text='Unité départementale de l''architecture et du patrimone du Lot-et-Garonne' WHERE id='udap-lot-et-garonne'; +UPDATE udap SET marianne_text='Préfet de la région Nouvelle-Aquitaine', drac_text='Direction régionale des affaires culturelles de Nouvelle-Aquitaine', udap_text='Unité départementale de l''architecture et du patrimone de la Dordogne' WHERE id='udap-dordogne'; \ No newline at end of file diff --git a/packages/backend/openapi.json b/packages/backend/openapi.json index beb759b9..27d8863d 100644 --- a/packages/backend/openapi.json +++ b/packages/backend/openapi.json @@ -1 +1 @@ -{"openapi":"3.1.0","info":{"title":"CR VIF API","description":"CR VIF API Documentation","version":"1.0"},"components":{"schemas":{}},"paths":{"/api/create-user":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"udap_id":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"}},"required":["name","udap_id","email","password"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"udap_id":{"type":"string"},"udap":{"type":"object","properties":{"id":{"type":"string"},"department":{"type":"string"},"completeCoords":{"type":"string"},"visible":{"type":"boolean"},"name":{"type":"string"},"address":{"type":"string"},"zipCode":{"type":"string"},"city":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}},"required":["id","department"]}},"required":["id","name","udap_id","udap"]},"token":{"type":"string"},"refreshToken":{"type":"string"}},"required":["token","refreshToken"]}}}}}}},"/api/login":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"password":{"type":"string"}},"required":["email","password"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"udap_id":{"type":"string"},"udap":{"type":"object","properties":{"id":{"type":"string"},"department":{"type":"string"},"completeCoords":{"type":"string"},"visible":{"type":"boolean"},"name":{"type":"string"},"address":{"type":"string"},"zipCode":{"type":"string"},"city":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}},"required":["id","department"]}},"required":["id","name","udap_id","udap"]},"token":{"type":"string"},"refreshToken":{"type":"string"}},"required":["token","refreshToken"]}}}}}}},"/api/refresh-token":{"get":{"parameters":[{"schema":{"type":"string"},"in":"query","name":"token","required":true},{"schema":{"type":"string"},"in":"query","name":"refreshToken","required":false}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"udap_id":{"type":"string"},"udap":{"type":"object","properties":{"id":{"type":"string"},"department":{"type":"string"},"completeCoords":{"type":"string"},"visible":{"type":"boolean"},"name":{"type":"string"},"address":{"type":"string"},"zipCode":{"type":"string"},"city":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}},"required":["id","department"]}},"required":["id","name","udap_id","udap"]},"token":{"type":"string"},"refreshToken":{"type":"string"}},"required":["token","refreshToken"]}}}}}}},"/api/send-reset-password":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"}},"required":["email"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}}}}},"/api/reset-password":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"temporaryLink":{"type":"string"},"newPassword":{"type":"string"}},"required":["temporaryLink","newPassword"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}}}}},"/api/udaps":{"get":{"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"department":{"type":"string"},"completeCoords":{"type":"string"},"visible":{"type":"boolean"},"name":{"type":"string"},"address":{"type":"string"},"zipCode":{"type":"string"},"city":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}},"required":["id","department"]}}}}}}}},"/api/pdf/report":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"htmlString":{"type":"string"},"reportId":{"type":"string"},"recipients":{"type":"string"}},"required":["htmlString","reportId","recipients"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"string"}}}}}},"get":{"parameters":[{"schema":{"type":"string"},"in":"query","name":"reportId","required":true}],"responses":{"200":{"description":"Default Response"}}}}}} \ No newline at end of file +{"openapi":"3.1.0","info":{"title":"CR VIF API","description":"CR VIF API Documentation","version":"1.0"},"components":{"schemas":{}},"paths":{"/api/create-user":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"udap_id":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"}},"required":["name","udap_id","email","password"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"udap_id":{"type":"string"},"udap":{"type":"object","properties":{"id":{"type":"string"},"department":{"type":"string"},"completeCoords":{"type":"string"},"visible":{"type":"boolean"},"name":{"type":"string"},"address":{"type":"string"},"zipCode":{"type":"string"},"city":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}},"required":["id","department"]}},"required":["id","name","udap_id","udap"]},"token":{"type":"string"},"refreshToken":{"type":"string"}},"required":["token","refreshToken"]}}}}}}},"/api/login":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"password":{"type":"string"}},"required":["email","password"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"udap_id":{"type":"string"},"udap":{"type":"object","properties":{"id":{"type":"string"},"department":{"type":"string"},"completeCoords":{"type":"string"},"visible":{"type":"boolean"},"name":{"type":"string"},"address":{"type":"string"},"zipCode":{"type":"string"},"city":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}},"required":["id","department"]}},"required":["id","name","udap_id","udap"]},"token":{"type":"string"},"refreshToken":{"type":"string"}},"required":["token","refreshToken"]}}}}}}},"/api/refresh-token":{"get":{"parameters":[{"schema":{"type":"string"},"in":"query","name":"token","required":true},{"schema":{"type":"string"},"in":"query","name":"refreshToken","required":false}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"udap_id":{"type":"string"},"udap":{"type":"object","properties":{"id":{"type":"string"},"department":{"type":"string"},"completeCoords":{"type":"string"},"visible":{"type":"boolean"},"name":{"type":"string"},"address":{"type":"string"},"zipCode":{"type":"string"},"city":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}},"required":["id","department"]}},"required":["id","name","udap_id","udap"]},"token":{"type":"string"},"refreshToken":{"type":"string"}},"required":["token","refreshToken"]}}}}}}},"/api/send-reset-password":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"}},"required":["email"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}}}}},"/api/reset-password":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"temporaryLink":{"type":"string"},"newPassword":{"type":"string"}},"required":["temporaryLink","newPassword"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}}}}},"/api/udaps":{"get":{"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"department":{"type":"string"},"completeCoords":{"type":"string"},"visible":{"type":"boolean"},"name":{"type":"string"},"address":{"type":"string"},"zipCode":{"type":"string"},"city":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"}},"required":["id","department"]}}}}}}}},"/api/pdf/report":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"htmlString":{"type":"string"},"reportId":{"type":"string"},"recipients":{"type":"string"}},"required":["htmlString","reportId","recipients"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"string"}}}}}},"get":{"parameters":[{"schema":{"type":"string"},"in":"query","name":"reportId","required":true}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{}}}}}}}}}} \ No newline at end of file diff --git a/packages/electric-client/src/generated/client/index.ts b/packages/electric-client/src/generated/client/index.ts index 61da12cc..9a4d3b77 100644 --- a/packages/electric-client/src/generated/client/index.ts +++ b/packages/electric-client/src/generated/client/index.ts @@ -100,8 +100,8 @@ export const UdapSchema = z.object({ phone: z.string().nullable(), email: z.string().nullable(), marianne_text: z.string().nullable(), - drac_text: z.coerce.date().nullable(), - udap_text: z.coerce.date().nullable(), + drac_text: z.string().nullable(), + udap_text: z.string().nullable(), }) export type Udap = z.infer @@ -466,8 +466,8 @@ export const UdapWhereInputSchema: z.ZodType = z.object({ phone: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), email: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), marianne_text: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), - drac_text: z.union([ z.lazy(() => DateTimeNullableFilterSchema),z.coerce.date() ]).optional().nullable(), - udap_text: z.union([ z.lazy(() => DateTimeNullableFilterSchema),z.coerce.date() ]).optional().nullable(), + drac_text: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), + udap_text: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), user: z.lazy(() => UserListRelationFilterSchema).optional() }).strict(); @@ -526,8 +526,8 @@ export const UdapScalarWhereWithAggregatesInputSchema: z.ZodType StringNullableWithAggregatesFilterSchema),z.string() ]).optional().nullable(), email: z.union([ z.lazy(() => StringNullableWithAggregatesFilterSchema),z.string() ]).optional().nullable(), marianne_text: z.union([ z.lazy(() => StringNullableWithAggregatesFilterSchema),z.string() ]).optional().nullable(), - drac_text: z.union([ z.lazy(() => DateTimeNullableWithAggregatesFilterSchema),z.coerce.date() ]).optional().nullable(), - udap_text: z.union([ z.lazy(() => DateTimeNullableWithAggregatesFilterSchema),z.coerce.date() ]).optional().nullable(), + drac_text: z.union([ z.lazy(() => StringNullableWithAggregatesFilterSchema),z.string() ]).optional().nullable(), + udap_text: z.union([ z.lazy(() => StringNullableWithAggregatesFilterSchema),z.string() ]).optional().nullable(), }).strict(); export const UserWhereInputSchema: z.ZodType = z.object({ @@ -822,8 +822,8 @@ export const UdapCreateInputSchema: z.ZodType = z.object phone: z.string().optional().nullable(), email: z.string().optional().nullable(), marianne_text: z.string().optional().nullable(), - drac_text: z.coerce.date().optional().nullable(), - udap_text: z.coerce.date().optional().nullable(), + drac_text: z.string().optional().nullable(), + udap_text: z.string().optional().nullable(), user: z.lazy(() => UserCreateNestedManyWithoutUdapInputSchema).optional() }).strict(); @@ -839,8 +839,8 @@ export const UdapUncheckedCreateInputSchema: z.ZodType UserUncheckedCreateNestedManyWithoutUdapInputSchema).optional() }).strict(); @@ -856,8 +856,8 @@ export const UdapUpdateInputSchema: z.ZodType = z.object phone: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), email: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), marianne_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), - drac_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), - udap_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + drac_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + udap_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), user: z.lazy(() => UserUpdateManyWithoutUdapNestedInputSchema).optional() }).strict(); @@ -873,8 +873,8 @@ export const UdapUncheckedUpdateInputSchema: z.ZodType NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), email: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), marianne_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), - drac_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), - udap_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + drac_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + udap_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), user: z.lazy(() => UserUncheckedUpdateManyWithoutUdapNestedInputSchema).optional() }).strict(); @@ -890,8 +890,8 @@ export const UdapCreateManyInputSchema: z.ZodType = phone: z.string().optional().nullable(), email: z.string().optional().nullable(), marianne_text: z.string().optional().nullable(), - drac_text: z.coerce.date().optional().nullable(), - udap_text: z.coerce.date().optional().nullable() + drac_text: z.string().optional().nullable(), + udap_text: z.string().optional().nullable() }).strict(); export const UdapUpdateManyMutationInputSchema: z.ZodType = z.object({ @@ -906,8 +906,8 @@ export const UdapUpdateManyMutationInputSchema: z.ZodType NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), email: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), marianne_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), - drac_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), - udap_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + drac_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + udap_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), }).strict(); export const UdapUncheckedUpdateManyInputSchema: z.ZodType = z.object({ @@ -922,8 +922,8 @@ export const UdapUncheckedUpdateManyInputSchema: z.ZodType NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), email: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), marianne_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), - drac_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), - udap_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + drac_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + udap_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), }).strict(); export const UserCreateInputSchema: z.ZodType = z.object({ @@ -2065,8 +2065,8 @@ export const UdapCreateWithoutUserInputSchema: z.ZodType = z.object({ @@ -2081,8 +2081,8 @@ export const UdapUncheckedCreateWithoutUserInputSchema: z.ZodType = z.object({ @@ -2188,8 +2188,8 @@ export const UdapUpdateWithoutUserInputSchema: z.ZodType NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), email: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), marianne_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), - drac_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), - udap_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + drac_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + udap_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), }).strict(); export const UdapUncheckedUpdateWithoutUserInputSchema: z.ZodType = z.object({ @@ -2204,8 +2204,8 @@ export const UdapUncheckedUpdateWithoutUserInputSchema: z.ZodType NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), email: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), marianne_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), - drac_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), - udap_text: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + drac_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + udap_text: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), }).strict(); export const UserCreateManyUdapInputSchema: z.ZodType = z.object({ @@ -3124,11 +3124,11 @@ export const tableSchemas = { ], [ "drac_text", - "DATE" + "TEXT" ], [ "udap_text", - "DATE" + "TEXT" ] ]), relations: [ diff --git a/packages/electric-client/src/generated/client/pg-migrations.ts b/packages/electric-client/src/generated/client/pg-migrations.ts index 7f784ba0..243fc126 100644 --- a/packages/electric-client/src/generated/client/pg-migrations.ts +++ b/packages/electric-client/src/generated/client/pg-migrations.ts @@ -111,8 +111,8 @@ export default [ { "statements": [ "ALTER TABLE udap ADD COLUMN marianne_text text", - "ALTER TABLE udap ADD COLUMN drac_text date", - "ALTER TABLE udap ADD COLUMN udap_text date", + "ALTER TABLE udap ADD COLUMN drac_text text", + "ALTER TABLE udap ADD COLUMN udap_text text", "INSERT INTO \"public\".\"_electric_trigger_settings\" (\"namespace\", \"tablename\", \"flag\")\n VALUES ('public', 'udap', 1)\n ON CONFLICT DO NOTHING;", "DROP TRIGGER IF EXISTS update_ensure_public_udap_primarykey ON \"public\".\"udap\";", "CREATE OR REPLACE FUNCTION update_ensure_public_udap_primarykey_function()\nRETURNS TRIGGER AS $$\nBEGIN\n IF OLD.\"id\" IS DISTINCT FROM NEW.\"id\" THEN\n RAISE EXCEPTION 'Cannot change the value of column id as it belongs to the primary key';\n END IF;\n RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql;", diff --git a/packages/electric-client/src/generated/client/prismaClient.d.ts b/packages/electric-client/src/generated/client/prismaClient.d.ts index d3206898..477ce4f7 100644 --- a/packages/electric-client/src/generated/client/prismaClient.d.ts +++ b/packages/electric-client/src/generated/client/prismaClient.d.ts @@ -101,8 +101,8 @@ export type UdapPayload composites: {} } @@ -4288,8 +4288,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone: string | null email: string | null marianne_text: string | null - drac_text: Date | null - udap_text: Date | null + drac_text: string | null + udap_text: string | null } export type UdapMaxAggregateOutputType = { @@ -4304,8 +4304,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone: string | null email: string | null marianne_text: string | null - drac_text: Date | null - udap_text: Date | null + drac_text: string | null + udap_text: string | null } export type UdapCountAggregateOutputType = { @@ -4460,8 +4460,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone: string | null email: string | null marianne_text: string | null - drac_text: Date | null - udap_text: Date | null + drac_text: string | null + udap_text: string | null _count: UdapCountAggregateOutputType | null _min: UdapMinAggregateOutputType | null _max: UdapMaxAggregateOutputType | null @@ -6579,8 +6579,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: StringNullableFilter | string | null email?: StringNullableFilter | string | null marianne_text?: StringNullableFilter | string | null - drac_text?: DateTimeNullableFilter | Date | string | null - udap_text?: DateTimeNullableFilter | Date | string | null + drac_text?: StringNullableFilter | string | null + udap_text?: StringNullableFilter | string | null user?: UserListRelationFilter } @@ -6639,8 +6639,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: StringNullableWithAggregatesFilter | string | null email?: StringNullableWithAggregatesFilter | string | null marianne_text?: StringNullableWithAggregatesFilter | string | null - drac_text?: DateTimeNullableWithAggregatesFilter | Date | string | null - udap_text?: DateTimeNullableWithAggregatesFilter | Date | string | null + drac_text?: StringNullableWithAggregatesFilter | string | null + udap_text?: StringNullableWithAggregatesFilter | string | null } export type UserWhereInput = { @@ -6936,8 +6936,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: string | null email?: string | null marianne_text?: string | null - drac_text?: Date | string | null - udap_text?: Date | string | null + drac_text?: string | null + udap_text?: string | null user?: UserCreateNestedManyWithoutUdapInput } @@ -6953,8 +6953,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: string | null email?: string | null marianne_text?: string | null - drac_text?: Date | string | null - udap_text?: Date | string | null + drac_text?: string | null + udap_text?: string | null user?: UserUncheckedCreateNestedManyWithoutUdapInput } @@ -6970,8 +6970,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: NullableStringFieldUpdateOperationsInput | string | null email?: NullableStringFieldUpdateOperationsInput | string | null marianne_text?: NullableStringFieldUpdateOperationsInput | string | null - drac_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null - udap_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + drac_text?: NullableStringFieldUpdateOperationsInput | string | null + udap_text?: NullableStringFieldUpdateOperationsInput | string | null user?: UserUpdateManyWithoutUdapNestedInput } @@ -6987,8 +6987,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: NullableStringFieldUpdateOperationsInput | string | null email?: NullableStringFieldUpdateOperationsInput | string | null marianne_text?: NullableStringFieldUpdateOperationsInput | string | null - drac_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null - udap_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + drac_text?: NullableStringFieldUpdateOperationsInput | string | null + udap_text?: NullableStringFieldUpdateOperationsInput | string | null user?: UserUncheckedUpdateManyWithoutUdapNestedInput } @@ -7004,8 +7004,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: string | null email?: string | null marianne_text?: string | null - drac_text?: Date | string | null - udap_text?: Date | string | null + drac_text?: string | null + udap_text?: string | null } export type UdapUpdateManyMutationInput = { @@ -7020,8 +7020,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: NullableStringFieldUpdateOperationsInput | string | null email?: NullableStringFieldUpdateOperationsInput | string | null marianne_text?: NullableStringFieldUpdateOperationsInput | string | null - drac_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null - udap_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + drac_text?: NullableStringFieldUpdateOperationsInput | string | null + udap_text?: NullableStringFieldUpdateOperationsInput | string | null } export type UdapUncheckedUpdateManyInput = { @@ -7036,8 +7036,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: NullableStringFieldUpdateOperationsInput | string | null email?: NullableStringFieldUpdateOperationsInput | string | null marianne_text?: NullableStringFieldUpdateOperationsInput | string | null - drac_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null - udap_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + drac_text?: NullableStringFieldUpdateOperationsInput | string | null + udap_text?: NullableStringFieldUpdateOperationsInput | string | null } export type UserCreateInput = { @@ -8184,8 +8184,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: string | null email?: string | null marianne_text?: string | null - drac_text?: Date | string | null - udap_text?: Date | string | null + drac_text?: string | null + udap_text?: string | null } export type UdapUncheckedCreateWithoutUserInput = { @@ -8200,8 +8200,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: string | null email?: string | null marianne_text?: string | null - drac_text?: Date | string | null - udap_text?: Date | string | null + drac_text?: string | null + udap_text?: string | null } export type UdapCreateOrConnectWithoutUserInput = { @@ -8307,8 +8307,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: NullableStringFieldUpdateOperationsInput | string | null email?: NullableStringFieldUpdateOperationsInput | string | null marianne_text?: NullableStringFieldUpdateOperationsInput | string | null - drac_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null - udap_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + drac_text?: NullableStringFieldUpdateOperationsInput | string | null + udap_text?: NullableStringFieldUpdateOperationsInput | string | null } export type UdapUncheckedUpdateWithoutUserInput = { @@ -8323,8 +8323,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject phone?: NullableStringFieldUpdateOperationsInput | string | null email?: NullableStringFieldUpdateOperationsInput | string | null marianne_text?: NullableStringFieldUpdateOperationsInput | string | null - drac_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null - udap_text?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + drac_text?: NullableStringFieldUpdateOperationsInput | string | null + udap_text?: NullableStringFieldUpdateOperationsInput | string | null } export type UserCreateManyUdapInput = { diff --git a/packages/frontend/src/api.gen.ts b/packages/frontend/src/api.gen.ts index 0624b792..34ad218a 100644 --- a/packages/frontend/src/api.gen.ts +++ b/packages/frontend/src/api.gen.ts @@ -143,7 +143,7 @@ export namespace Endpoints { parameters: { query: { reportId: string }; }; - response: unknown; + response: Partial<{}>; }; // diff --git a/packages/frontend/src/components/SyncForm.tsx b/packages/frontend/src/components/SyncForm.tsx index 8f3b955d..583793ed 100644 --- a/packages/frontend/src/components/SyncForm.tsx +++ b/packages/frontend/src/components/SyncForm.tsx @@ -7,13 +7,13 @@ import { useNavigate, useRouter } from "@tanstack/react-router"; import Button from "@codegouvfr/react-dsfr/Button"; import { Center, Flex, styled } from "#styled-system/jsx"; import { fr } from "@codegouvfr/react-dsfr"; -import { sva } from "#styled-system/css"; +import { sva, cx, css } from "#styled-system/css"; import { useNetworkState } from "react-use"; import { useIntersectionObserver } from "../hooks/useIntersectionObserver"; import Input from "@codegouvfr/react-dsfr/Input"; import { Report } from "@cr-vif/electric-client/frontend"; import { useEffect } from "react"; -import { useElectricStatus } from "../contexts/AuthContext"; +import { ElectricStatus, useElectricStatus } from "../contexts/AuthContext"; export function SyncFormBanner({ form, baseObject }: { form: UseFormReturn; baseObject: Record }) { const newObject = useWatch({ control: form.control }); @@ -29,6 +29,7 @@ export function SyncFormBanner({ form, baseObject }: { form: UseFormReturn - +
{isCollapsed ? newObject.title : "Titre compte-rendu :"} - + {/*
*/} - + {isCollapsed ? ( <> @@ -108,9 +109,27 @@ export function SyncFormBanner({ form, baseObject }: { form: UseFormReturn { +const electricStatusToStatus: Record = { + error: "offline", + loading: "pending", + pending: "pending", + idle: "offline", + success: "saved", +}; + +export const useStatus = (overrideStatus?: SyncFormStatus) => { const electricStatus = useElectricStatus(); - const overrideStatus: SyncFormStatus = electricStatus === "loading" ? "offline" : status ?? "saved"; + if (electricStatus === "error") return "offline"; + + const formStatus = electricStatusToStatus[electricStatus]; + + if (formStatus === "pending") return "pending"; + + return overrideStatus || formStatus; +}; + +export const Status = ({ status, className }: { status?: SyncFormStatus; className?: string }) => { + const formStatus = useStatus(status === "pending" ? "pending" : undefined); return ( - {messages[overrideStatus]} + {messages[formStatus]} ); }; diff --git a/packages/frontend/src/contexts/AuthContext.tsx b/packages/frontend/src/contexts/AuthContext.tsx index ed788bf8..35f3b666 100644 --- a/packages/frontend/src/contexts/AuthContext.tsx +++ b/packages/frontend/src/contexts/AuthContext.tsx @@ -42,7 +42,7 @@ export const AuthProvider = ({ children }: PropsWithChildren) => { setDataAndSaveInStorage({ ...data, token: undefined, user: undefined }); } else { console.log("token refreshed"); - setDataAndSaveInStorage(resp); + setDataAndSaveInStorage({ ...data, ...resp }); } return resp; } catch (e) { @@ -124,5 +124,7 @@ export const useUser = () => { type AuthContextProps = Partial> & { setData: (data: Omit) => void; - electricStatus: "error" | "pending" | "success" | "idle" | "loading"; + electricStatus: ElectricStatus; }; + +export type ElectricStatus = "error" | "pending" | "success" | "idle" | "loading"; diff --git a/packages/frontend/src/routes/index.tsx b/packages/frontend/src/routes/index.tsx index 7521c62f..84204a0b 100644 --- a/packages/frontend/src/routes/index.tsx +++ b/packages/frontend/src/routes/index.tsx @@ -7,7 +7,7 @@ import { v4 } from "uuid"; import { Banner } from "#components/Banner"; import { EnsureUser } from "#components/EnsureUser"; import { Tabs } from "#components/Tabs"; -import { useElectricStatus, useUser } from "../contexts/AuthContext"; +import { ElectricStatus, useElectricStatus, useUser } from "../contexts/AuthContext"; import { db } from "../db"; import { AllReports, MyReports } from "../features/ReportList"; import { useNetworkState } from "react-use"; @@ -151,7 +151,16 @@ const Index = () => { const SimpleBanner = (props: CenterProps) => { const electricStatus = useElectricStatus(); - const status: SyncFormStatus = electricStatus === "loading" ? "offline" : "saved"; + + const electricStatusToStatus: Record = { + error: "offline", + loading: "pending", + pending: "pending", + idle: "offline", + success: "saved", + }; + + const status: SyncFormStatus = electricStatusToStatus[electricStatus] || "saved"; return ; };