Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/components/document-preview/doc-preview.tsx`:
- Around line 140-145: The effect in useEffect that checks status === 'Only
.docx files are supported' is brittle; change the component to rely on a stable
flag or status code rather than a magic string: add or read a typed status value
(e.g., errorCode or UploadStatus enum) from the editor state or propagate a
constant like DOCX_UNSUPPORTED_CODE and update the effect to check that (or use
a deterministic helper like isDocxUnsupportedStatus(status)); then call
setError(...) and setLoading(false) when that code/helper indicates the
unsupported-docx condition (update any producers of status to emit the
code/constant as needed) using the existing setError and setLoading functions.
---
Nitpick comments:
In `@web/src/components/document-preview/doc-preview.tsx`:
- Around line 166-221: The component currently renders several hardcoded
user-facing strings in doc-preview.tsx (e.g., the toolbar texts "Loading...",
`Page ${pageCount || '-'}`, aria-labels "Zoom out"/"Zoom in", and error panel
strings "Preview is not available for this Word document" and
"`@extend-ai/react-docx` supports modern .docx files only.")—replace these with
i18n lookups by importing and calling useTranslation from react-i18next at the
top of the component, define keys (e.g., toolbar.loading, toolbar.page,
toolbar.zoomOut, toolbar.zoomIn, error.previewUnavailable, error.supportNote)
and use t('...') where loading, pageCount, zoomScale, handleZoomOut, and
handleZoomIn are used so all visible text and aria-labels come from translation
strings.
- Around line 166-169: The page count label is ambiguous; update the JSX in the
doc-preview component (the span that currently renders {loading ? 'Loading...' :
error ? '' : `Page ${pageCount || '-'}`}) to show a clearer total or
context-aware label: either render `${pageCount || '-'} pages` when only total
is known, or if a current page variable exists (e.g., currentPage or pageIndex),
render `Page <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi>c</mi><mi>u</mi><mi>r</mi><mi>r</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>P</mi><mi>a</mi><mi>g</mi><mi>e</mi></mrow><mi>o</mi><mi>f</mi></mrow><annotation encoding="application/x-tex">{currentPage} of </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="mord mathnormal">u</span><span class="mord mathnormal">rre</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.13889em;">tP</span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">e</span></span><span class="mord mathnormal">o</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span></span></span></span>{pageCount}`; keep the loading and error
branches unchanged and ensure you handle falsy pageCount by showing '-' as
before.
- Around line 36-55: clampZoom incorrectly computes the next zoom step when
scale is not exactly in ZOOM_STEPS because it finds an adjacent index then adds
direction again (causing a skip); change clampZoom to compute the target index
directly: if scale exists in ZOOM_STEPS use foundIndex + direction, otherwise if
direction === 1 set targetIndex = first index where ZOOM_STEPS[i] > scale, and
if direction === -1 set targetIndex = last index where ZOOM_STEPS[i] < scale;
then clamp targetIndex between 0 and ZOOM_STEPS.length-1 and return
ZOOM_STEPS[targetIndex] (use the function name clampZoom and the constant
ZOOM_STEPS to locate the code).