Fix TypeScript build errors in product detail and admin review

This commit is contained in:
2026-05-19 14:11:27 +07:00
parent e9a0cd0b2d
commit b266047a11
2 changed files with 8 additions and 5 deletions

View File

@ -168,7 +168,9 @@ function ProductDetailPageInner() {
}, [errorLoadText, params.productId, isDraft, isReview]);
useEffect(() => {
if (!product?.subCategory?.id || product.subCategory.category?.name) {
const subCategoryId = product?.subCategory?.id;
if (!subCategoryId || product?.subCategory?.category?.name) {
return;
}
@ -194,7 +196,7 @@ function ProductDetailPageInner() {
const rows: CategoryOption[] = Array.isArray(subcategoriesJson?.rows)
? subcategoriesJson.rows
: [];
if (rows.some((subCategory) => subCategory.id === product.subCategory?.id)) {
if (rows.some((subCategory) => subCategory.id === subCategoryId)) {
if (!cancelled) {
setResolvedMainCategoryName(category.name);
}

View File

@ -133,11 +133,12 @@ interface CompareRow {
function hasChangesForPaths(rows: CompareRow[], paths: string[]) {
return rows.some((row) => {
if (!row?.field || row.isUpdate !== true) return false;
const field = row.field;
return paths.some(
(path) =>
row.field === path ||
row.field.startsWith(`${path}.`) ||
row.field.startsWith(`${path}[`)
field === path ||
field.startsWith(`${path}.`) ||
field.startsWith(`${path}[`)
);
});
}