Ver código fonte

Show when a shared fix was edited during review (#507)

Bernt Christian Egeland 1 dia atrás
pai
commit
b65bc02720

+ 2 - 1
messages/de/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Kopiert",
       "received": "{count, plural, one {# Foto} other {# Fotos}} vom Handy",
       "badge": "Handy"
-    }
+    },
+    "editedNote": "Bei der Prüfung bearbeitet"
   },
   "fixes": {
     "title": "Lösungen anderer Werkstätten",

+ 2 - 1
messages/en/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Copied",
       "received": "{count, plural, one {# photo} other {# photos}} from your phone",
       "badge": "Phone"
-    }
+    },
+    "editedNote": "Edited during review"
   },
   "fixes": {
     "title": "Fixes from other workshops",

+ 2 - 1
messages/es/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Copiado",
       "received": "{count, plural, one {# foto} other {# fotos}} desde el móvil",
       "badge": "Móvil"
-    }
+    },
+    "editedNote": "Editada durante la revisión"
   },
   "fixes": {
     "title": "Soluciones de otros talleres",

+ 2 - 1
messages/fr/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Copié",
       "received": "{count, plural, one {# photo} other {# photos}} depuis votre téléphone",
       "badge": "Téléphone"
-    }
+    },
+    "editedNote": "Modifiée lors de la vérification"
   },
   "fixes": {
     "title": "Solutions d'autres ateliers",

+ 2 - 1
messages/it/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Copiato",
       "received": "{count, plural, one {# foto} other {# foto}} dal telefono",
       "badge": "Telefono"
-    }
+    },
+    "editedNote": "Modificata durante la revisione"
   },
   "fixes": {
     "title": "Soluzioni di altre officine",

+ 2 - 1
messages/lt/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Nukopijuota",
       "received": "{count, plural, one {# nuotrauka} few {# nuotraukos} other {# nuotraukų}} iš telefono",
       "badge": "Telefonas"
-    }
+    },
+    "editedNote": "Redaguota tikrinant"
   },
   "fixes": {
     "title": "Kitų servisų sprendimai",

+ 2 - 1
messages/nb/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Kopiert",
       "received": "{count, plural, one {# bilde} other {# bilder}} fra mobilen",
       "badge": "Mobil"
-    }
+    },
+    "editedNote": "Redigert under gjennomgang"
   },
   "fixes": {
     "title": "Løsninger fra andre verksteder",

+ 2 - 1
messages/nl/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Gekopieerd",
       "received": "{count, plural, one {# foto} other {# foto’s}} vanaf uw telefoon",
       "badge": "Telefoon"
-    }
+    },
+    "editedNote": "Bewerkt tijdens de controle"
   },
   "fixes": {
     "title": "Oplossingen van andere werkplaatsen",

+ 2 - 1
messages/pl/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Skopiowano",
       "received": "{count, plural, one {# zdjęcie} few {# zdjęcia} many {# zdjęć} other {# zdjęcia}} z telefonu",
       "badge": "Telefon"
-    }
+    },
+    "editedNote": "Poprawione podczas weryfikacji"
   },
   "fixes": {
     "title": "Rozwiązania innych warsztatów",

+ 2 - 1
messages/pt-BR/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Copiado",
       "received": "{count, plural, one {# foto} other {# fotos}} do celular",
       "badge": "Celular"
-    }
+    },
+    "editedNote": "Editada durante a revisão"
   },
   "fixes": {
     "title": "Soluções de outras oficinas",

+ 2 - 1
messages/pt-PT/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Copiado",
       "received": "{count, plural, one {# fotografia} other {# fotografias}} do telemóvel",
       "badge": "Telemóvel"
-    }
+    },
+    "editedNote": "Editada durante a revisão"
   },
   "fixes": {
     "title": "Soluções de outras oficinas",

+ 2 - 1
messages/ru/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Скопировано",
       "received": "{count, plural, one {# фото} few {# фото} many {# фото} other {# фото}} с телефона",
       "badge": "Телефон"
-    }
+    },
+    "editedNote": "Отредактировано при проверке"
   },
   "fixes": {
     "title": "Решения других мастерских",

+ 2 - 1
messages/tr/faultCodes.json

@@ -144,7 +144,8 @@
       "copied": "Kopyalandı",
       "received": "{count, plural, one {# fotoğraf} other {# fotoğraf}} telefondan",
       "badge": "Telefon"
-    }
+    },
+    "editedNote": "İnceleme sırasında düzenlendi"
   },
   "fixes": {
     "title": "Diğer atölyelerin çözümleri",

+ 17 - 0
src/__tests__/features/fault-codes/pages.test.tsx

@@ -257,6 +257,7 @@ function ownFix(patch: Partial<OwnFix> = {}): OwnFix {
     status: 'pending',
     reason: null,
     reviewedAt: null,
+    edited: false,
     ...patch,
   }
 }
@@ -388,6 +389,22 @@ describe('sharing what fixed a code', () => {
     expect(dialog.getByLabelText('What fixed it')).toHaveValue(FIXED_IT)
   })
 
+  it('says when a reviewer corrected the fix', () => {
+    renderPage(
+      <FaultCodeDetail
+        data={pageData({
+          fixes: {
+            available: true,
+            published: [],
+            own: [ownFix({ status: 'published', edited: true })],
+          },
+        })}
+        layout="page"
+      />
+    )
+    expect(card('Share your fix').getByText(/Edited during review/)).toBeInTheDocument()
+  })
+
   it('says why a fix was not published, and withdraws it', async () => {
     h.withdraw.mockResolvedValueOnce({ success: true, data: { withdrawn: true } })
     const rejected = ownFix({ status: 'rejected', reason: 'The photo shows a number plate.' })

+ 7 - 2
src/__tests__/features/fault-codes/service.test.ts

@@ -216,7 +216,7 @@ describe('shared fixes for a workshop', () => {
   it('remembers only the id of a fix it shared, and shows it waiting for review', async () => {
     h.shareFix.mockResolvedValueOnce({ ok: true, id: 'f1' })
     h.fixStatus.mockResolvedValueOnce([
-      fix('f1', { status: 'pending', reason: null, reviewedAt: null }),
+      fix('f1', { status: 'pending', reason: null, reviewedAt: null, edited: false }),
     ])
     const photo = new Blob(['jpeg'], { type: 'image/jpeg' })
     const result = await shareFix('org1', {
@@ -265,7 +265,12 @@ describe('shared fixes for a workshop', () => {
     h.links.set('fault-code-fix:P0420|gone', { remoteId: 'gone', metadata: null })
     h.publishedFixes.mockResolvedValueOnce([fix('theirs'), fix('mine')])
     h.fixStatus.mockResolvedValueOnce([
-      fix('mine', { status: 'published', reason: null, reviewedAt: '2026-11-06T09:00:00Z' }),
+      fix('mine', {
+        status: 'published',
+        reason: null,
+        reviewedAt: '2026-11-06T09:00:00Z',
+        edited: false,
+      }),
     ])
     const fixes = await fixesFor('org1', 'P0420')
     expect(fixes.available).toBe(true)

+ 2 - 0
src/__tests__/features/integrations/torqvoice-codes.test.ts

@@ -384,6 +384,7 @@ describe('Torqvoice Codes shared fixes', () => {
             status: 'rejected',
             reason: 'The photo shows a plate.',
             reviewed_at: '2026-11-06T09:00:00Z',
+            edited: true,
           },
         ],
       })
@@ -395,6 +396,7 @@ describe('Torqvoice Codes shared fixes', () => {
       status: 'rejected',
       reason: 'The photo shows a plate.',
       reviewedAt: '2026-11-06T09:00:00Z',
+      edited: true,
     })
   })
 

+ 3 - 1
src/features/fault-codes/Components/ShareFixCard.tsx

@@ -117,7 +117,9 @@ export function ShareFixCard({
                     {statusLabel[fix.status]}
                   </span>
                   <span className="text-xs text-muted-foreground">
-                    {t('sentOn', { date: formatDate(fix.createdAt) })}
+                    {fix.edited
+                      ? `${t('sentOn', { date: formatDate(fix.createdAt) })} · ${t('editedNote')}`
+                      : t('sentOn', { date: formatDate(fix.createdAt) })}
                   </span>
                 </div>
                 {fix.status === 'rejected' && fix.reason && (

+ 2 - 0
src/features/fault-codes/Lib/service.server.ts

@@ -494,6 +494,7 @@ function ownFixOf(fix: FaultCodeOwnFix): OwnFix {
     status: fix.status,
     reason: fix.reason,
     reviewedAt: fix.reviewedAt,
+    edited: fix.edited,
   }
 }
 
@@ -561,6 +562,7 @@ export async function shareFix(
       status: 'pending',
       reason: null,
       reviewedAt: null,
+      edited: false,
     },
   }
 }

+ 2 - 0
src/features/fault-codes/Lib/types.ts

@@ -125,6 +125,8 @@ export interface OwnFix extends SharedFix {
   /** Why it was not published, in the reviewer's words. */
   reason: string | null
   reviewedAt: string | null
+  /** A reviewer at Torqvoice corrected the text, the vehicle or the photos. */
+  edited: boolean
 }
 
 /** The fixes on a code's page. */

+ 2 - 0
src/features/integrations/Lib/types.ts

@@ -721,6 +721,8 @@ export interface FaultCodeOwnFix extends FaultCodeFix {
   /** The reviewer's reason, when it was not published. */
   reason: string | null
   reviewedAt: string | null
+  /** A reviewer corrected the text, the vehicle or the photos. */
+  edited: boolean
 }
 
 export interface FaultCodeFixInput {

+ 3 - 0
src/integrations/torqvoice-codes/server.ts

@@ -171,6 +171,8 @@ const ownFixSchema = fixSchema.extend({
   status: z.enum(['pending', 'published', 'rejected']).catch('pending'),
   reason: z.string().nullish().catch(null),
   reviewed_at: z.string().nullish().catch(null),
+  // A reviewer at Torqvoice corrected the text, the vehicle or the photos.
+  edited: z.boolean().optional().catch(false),
 })
 const fixesReplySchema = z.object({ fixes: z.array(fixSchema) })
 const ownFixesReplySchema = z.object({ fixes: z.array(ownFixSchema) })
@@ -516,6 +518,7 @@ async function fixStatus(ctx: ConnectorContext, ids: string[]): Promise<FaultCod
     status: f.status,
     reason: f.reason ?? null,
     reviewedAt: f.reviewed_at ?? null,
+    edited: f.edited ?? false,
   }))
 }