Skip to content

Commit e591bce

Browse files
Merge pull request #283 from SheetMetalConnect/claude/refactor-analysis-tools-UmvQ7
Refactor analysis tools implementation
2 parents 1567519 + 56fe6f5 commit e591bce

File tree

10 files changed

+95
-55
lines changed

10 files changed

+95
-55
lines changed

src/hooks/useExceptions.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
2+
import { useTranslation } from 'react-i18next'
23
import { supabase } from '@/integrations/supabase/client'
34
import { useAuth } from '@/contexts/AuthContext'
45
import { toast } from 'sonner'
@@ -20,6 +21,7 @@ interface UseExceptionsOptions {
2021

2122
export function useExceptions(options: UseExceptionsOptions = {}) {
2223
const { status = 'all', limit = 50 } = options
24+
const { t } = useTranslation(['admin', 'common'])
2325
const { profile } = useAuth()
2426
const queryClient = useQueryClient()
2527

@@ -96,10 +98,10 @@ export function useExceptions(options: UseExceptionsOptions = {}) {
9698
onSuccess: () => {
9799
queryClient.invalidateQueries({ queryKey: ['exceptions'] })
98100
queryClient.invalidateQueries({ queryKey: ['exception-stats'] })
99-
toast.success('Exception acknowledged')
101+
toast.success(t('admin:exceptionInbox.exceptionAcknowledged'))
100102
},
101103
onError: (error) => {
102-
toast.error('Failed to acknowledge exception')
104+
toast.error(t('admin:exceptionInbox.actionFailed'))
103105
console.error(error)
104106
},
105107
})
@@ -131,10 +133,10 @@ export function useExceptions(options: UseExceptionsOptions = {}) {
131133
onSuccess: () => {
132134
queryClient.invalidateQueries({ queryKey: ['exceptions'] })
133135
queryClient.invalidateQueries({ queryKey: ['exception-stats'] })
134-
toast.success('Exception resolved')
136+
toast.success(t('admin:exceptionInbox.exceptionResolved'))
135137
},
136138
onError: (error) => {
137-
toast.error('Failed to resolve exception')
139+
toast.error(t('admin:exceptionInbox.actionFailed'))
138140
console.error(error)
139141
},
140142
})
@@ -157,10 +159,10 @@ export function useExceptions(options: UseExceptionsOptions = {}) {
157159
onSuccess: () => {
158160
queryClient.invalidateQueries({ queryKey: ['exceptions'] })
159161
queryClient.invalidateQueries({ queryKey: ['exception-stats'] })
160-
toast.success('Exception dismissed')
162+
toast.success(t('admin:exceptionInbox.exceptionDismissed'))
161163
},
162164
onError: (error) => {
163-
toast.error('Failed to dismiss exception')
165+
toast.error(t('admin:exceptionInbox.actionFailed'))
164166
console.error(error)
165167
},
166168
})

src/hooks/useExpectations.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
2+
import { useTranslation } from 'react-i18next'
23
import { supabase } from '@/integrations/supabase/client'
34
import { useAuth } from '@/contexts/AuthContext'
45
import { toast } from 'sonner'
@@ -19,6 +20,7 @@ interface UseExpectationsOptions {
1920

2021
export function useExpectations(options: UseExpectationsOptions = {}) {
2122
const { entityType, entityId, activeOnly = false, limit = 100 } = options
23+
const { t } = useTranslation(['admin', 'common'])
2224
const { profile } = useAuth()
2325
const queryClient = useQueryClient()
2426

@@ -113,10 +115,10 @@ export function useExpectations(options: UseExpectationsOptions = {}) {
113115
},
114116
onSuccess: () => {
115117
queryClient.invalidateQueries({ queryKey: ['expectations'] })
116-
toast.success('Expectation created')
118+
toast.success(t('admin:expectations.created'))
117119
},
118120
onError: (error) => {
119-
toast.error('Failed to create expectation')
121+
toast.error(t('admin:expectations.createFailed'))
120122
console.error(error)
121123
},
122124
})
@@ -150,10 +152,10 @@ export function useExpectations(options: UseExpectationsOptions = {}) {
150152
},
151153
onSuccess: () => {
152154
queryClient.invalidateQueries({ queryKey: ['expectations'] })
153-
toast.success('Expectation updated (history preserved)')
155+
toast.success(t('admin:expectations.updated'))
154156
},
155157
onError: (error) => {
156-
toast.error('Failed to update expectation')
158+
toast.error(t('admin:expectations.updateFailed'))
157159
console.error(error)
158160
},
159161
})

src/i18n/locales/de/admin.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,14 @@
200200
"statsOpen": "Offene Ausnahmen",
201201
"statsAcknowledged": "Bestätigt",
202202
"statsResolved": "Heute Gelöst",
203-
"statsDismissed": "Abgelehnt"
203+
"statsDismissed": "Abgelehnt",
204+
"noOpenExceptions": "Keine offenen Ausnahmen",
205+
"all": "Alle",
206+
"avgResolutionTime": "Durchschn. Lösungszeit",
207+
"resolveDescription": "Dokumentieren Sie die Grundursache und die ergriffenen Korrekturmaßnahmen.",
208+
"dismissDescription": "Erklären Sie, warum diese Ausnahme nicht handlungsbedarf hat.",
209+
"markResolved": "Als gelöst markieren",
210+
"resolution": "Lösung"
204211
},
205212
"expectations": {
206213
"title": "Erwartungen",
@@ -221,7 +228,11 @@
221228
"noExpectationsDescription": "Erwartungen werden automatisch erstellt, wenn Aufträge ein Fälligkeitsdatum erhalten oder Vorgänge geplant werden.",
222229
"whatIsTitle": "Was ist eine Erwartung?",
223230
"whatIsDescription": "Eine Erwartung ist eine explizite Überzeugung darüber, was in der Zukunft passieren sollte. Wenn die Realität von der Erwartung abweicht, wird eine Ausnahme ausgelöst.",
224-
"onlyActiveEvaluated": "Nur aktive Erwartungen werden gegen die Realität ausgewertet"
231+
"onlyActiveEvaluated": "Nur aktive Erwartungen werden gegen die Realität ausgewertet",
232+
"created": "Erwartung erstellt",
233+
"createFailed": "Erwartung konnte nicht erstellt werden",
234+
"updated": "Erwartung aktualisiert (Verlauf beibehalten)",
235+
"updateFailed": "Erwartung konnte nicht aktualisiert werden"
225236
},
226237
"myActivity": {
227238
"title": "Meine Aktivität",

src/i18n/locales/de/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"optional": "optional",
5151
"done": "Fertig",
5252
"creating": "Erstellen...",
53-
"helpAndDocs": "Hilfe & Dokumentation"
53+
"helpAndDocs": "Hilfe & Dokumentation",
54+
"refresh": "Aktualisieren"
5455
},
5556
"forms": {
5657
"required": "Dieses Feld ist erforderlich",

src/i18n/locales/en/admin.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@
253253
"dismissedExceptions": "Dismissed",
254254
"noExceptions": "No exceptions found",
255255
"noExceptionsDescription": "When expectations are violated, exceptions will appear here",
256+
"noOpenExceptions": "No open exceptions",
257+
"all": "All",
258+
"avgResolutionTime": "Avg Resolution",
259+
"resolveDescription": "Document the root cause and corrective action taken.",
260+
"dismissDescription": "Explain why this exception is not actionable.",
261+
"markResolved": "Mark Resolved",
262+
"resolution": "Resolution",
256263
"violatedBelief": "Violated Belief",
257264
"expected": "Expected",
258265
"actual": "Actual",
@@ -308,7 +315,11 @@
308315
"noExpectationsDescription": "Expectations are created automatically when jobs get due dates or operations are scheduled.",
309316
"whatIsTitle": "What is an Expectation?",
310317
"whatIsDescription": "An expectation is an explicit belief about what should happen in the future. Unlike alerts, expectations are created before reality unfolds. When reality diverges from expectation, an exception is raised.",
311-
"onlyActiveEvaluated": "Only Active expectations are evaluated against reality"
318+
"onlyActiveEvaluated": "Only Active expectations are evaluated against reality",
319+
"created": "Expectation created",
320+
"createFailed": "Failed to create expectation",
321+
"updated": "Expectation updated (history preserved)",
322+
"updateFailed": "Failed to update expectation"
312323
},
313324
"myActivity": {
314325
"title": "My Activity",

src/i18n/locales/en/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"no": "No",
5353
"done": "Done",
5454
"creating": "Creating...",
55-
"helpAndDocs": "Help & Docs"
55+
"helpAndDocs": "Help & Docs",
56+
"refresh": "Refresh"
5657
},
5758
"forms": {
5859
"required": "This field is required",

src/i18n/locales/nl/admin.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,14 @@
437437
"statsOpen": "Open Uitzonderingen",
438438
"statsAcknowledged": "Bevestigd",
439439
"statsResolved": "Vandaag Opgelost",
440-
"statsDismissed": "Afgewezen"
440+
"statsDismissed": "Afgewezen",
441+
"noOpenExceptions": "Geen open uitzonderingen",
442+
"all": "Alles",
443+
"avgResolutionTime": "Gem. Oplostijd",
444+
"resolveDescription": "Documenteer de hoofdoorzaak en genomen corrigerende actie.",
445+
"dismissDescription": "Leg uit waarom deze uitzondering niet actiegericht is.",
446+
"markResolved": "Markeer als opgelost",
447+
"resolution": "Oplossing"
441448
},
442449
"expectations": {
443450
"title": "Verwachtingen",
@@ -458,7 +465,11 @@
458465
"noExpectationsDescription": "Verwachtingen worden automatisch aangemaakt wanneer opdrachten een vervaldatum krijgen of bewerkingen worden gepland.",
459466
"whatIsTitle": "Wat is een Verwachting?",
460467
"whatIsDescription": "Een verwachting is een expliciete overtuiging over wat in de toekomst zou moeten gebeuren. Wanneer de werkelijkheid afwijkt van de verwachting, wordt een uitzondering gemaakt.",
461-
"onlyActiveEvaluated": "Alleen actieve verwachtingen worden geëvalueerd tegen de werkelijkheid"
468+
"onlyActiveEvaluated": "Alleen actieve verwachtingen worden geëvalueerd tegen de werkelijkheid",
469+
"created": "Verwachting aangemaakt",
470+
"createFailed": "Aanmaken verwachting mislukt",
471+
"updated": "Verwachting bijgewerkt (historie behouden)",
472+
"updateFailed": "Bijwerken verwachting mislukt"
462473
},
463474
"myActivity": {
464475
"title": "Mijn activiteit",

src/i18n/locales/nl/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"optional": "optioneel",
5252
"done": "Gereed",
5353
"creating": "Aanmaken...",
54-
"helpAndDocs": "Help & Documentatie"
54+
"helpAndDocs": "Help & Documentatie",
55+
"refresh": "Vernieuwen"
5556
},
5657
"forms": {
5758
"required": "Dit veld is verplicht",

0 commit comments

Comments
 (0)