update: brand device

This commit is contained in:
2025-12-12 12:45:46 +07:00
parent 512282f367
commit 8afff23ffe
7 changed files with 1388 additions and 464 deletions

View File

@@ -12,12 +12,13 @@ const FileUploadHandler = ({
accept = '.pdf,.jpg,.jpeg,.png,.gif',
disabled = false,
// File management
fileList = [],
onFileUpload,
onFileRemove,
existingFile = null,
clearSignal = null,
debugProps = {},
uploadText = 'Click or drag file to this area to upload',
uploadHint = 'Support for PDF and image files only',
@@ -34,6 +35,12 @@ const FileUploadHandler = ({
const [isUploading, setIsUploading] = useState(false);
const [uploadedFile, setUploadedFile] = useState(null);
React.useEffect(() => {
if (clearSignal !== null && clearSignal > 0) {
setUploadedFile(null);
}
}, [clearSignal, debugProps]);
const getBase64 = (file) =>
new Promise((resolve, reject) => {
const reader = new FileReader();
@@ -140,6 +147,7 @@ const FileUploadHandler = ({
}
}
if (actualPath) {
let fileObject;
@@ -176,7 +184,6 @@ const FileUploadHandler = ({
setIsUploading(false);
return false;
} else {
console.error('Failed to extract file path from upload response:', uploadResponse);
NotifAlert({
icon: 'error',
title: 'Gagal',
@@ -186,7 +193,6 @@ const FileUploadHandler = ({
return false;
}
} catch (error) {
console.error('Upload error:', error);
NotifAlert({
icon: 'error',
title: 'Error',
@@ -204,16 +210,9 @@ const FileUploadHandler = ({
};
const handleRemove = () => {
console.log('🗑️ FileUploadHandler handleRemove called:', {
existingFile,
onFileRemove: typeof onFileRemove,
hasExistingFile: !!existingFile
});
if (existingFile && onFileRemove) {
onFileRemove(existingFile);
} else if (onFileRemove) {
// Call onFileRemove even without existingFile to trigger form cleanup
onFileRemove(null);
}
};
@@ -221,17 +220,9 @@ const FileUploadHandler = ({
const renderExistingFile = () => {
const fileToShow = existingFile || uploadedFile;
if (!fileToShow) {
console.log('❌ FileUploadHandler renderExistingFile: No file to render');
return null;
}
console.log('✅ FileUploadHandler renderExistingFile: File found', {
existingFile: !!existingFile,
uploadedFile: !!uploadedFile,
fileName: fileToShow.name,
shouldShowDeleteButton: true
});
const filePath = fileToShow.uploadPath || fileToShow.url || fileToShow.path_icon || fileToShow.path_solution;
const fileName = fileToShow.name || filePath?.split('/').pop() || 'Unknown file';
const fileType = getFileType(fileName);
@@ -257,7 +248,6 @@ const FileUploadHandler = ({
});
}
} else {
// For PDFs and other files, open in new tab
const folder = fileToShow.type_solution === 'pdf' ? 'pdf' : 'images';
const filename = filePath.split('/').pop();
const fileUrl = getFileUrl(folder, filename);
@@ -404,7 +394,9 @@ const FileUploadHandler = ({
</Upload>
)}
{renderExistingFile()}
{/* renderExistingFile() is disabled because SolutionField.jsx already handles file card rendering */}
{/* This prevents duplicate card rendering */}
{/* {renderExistingFile()} */}
{showPreview && (
<Modal