diff --git a/src/components/DocumentViewer.jsx b/src/components/DocumentViewer.jsx
index 0857f3d..26c9dcb 100644
--- a/src/components/DocumentViewer.jsx
+++ b/src/components/DocumentViewer.jsx
@@ -7,6 +7,14 @@ const DocumentViewer = ({ documents, sellerId, refreshDocs }) => {
const { token } = useAuth();
const [previewDoc, setPreviewDoc] = useState(null);
+ const resolveUrl = (url) => {
+ if (!url) return '';
+ if (url.startsWith('/') || url.startsWith('//')) {
+ return `${API_BASE_URL}${url}`;
+ }
+ return url;
+ };
+
const handleApprove = async (docId) => {
try {
const res = await fetch(`${API_BASE_URL}/sellers/${sellerId}/documents/${docId}/approve/`, {
@@ -26,7 +34,7 @@ const DocumentViewer = ({ documents, sellerId, refreshDocs }) => {
const handleDownload = (doc) => {
const link = document.createElement('a');
- link.href = doc.url;
+ link.href = resolveUrl(doc.url);
link.download = doc.filename;
document.body.appendChild(link);
link.click();
@@ -68,7 +76,7 @@ const DocumentViewer = ({ documents, sellerId, refreshDocs }) => {
textAlign: 'center'
}}>
{doc.filename.match(/\.(jpg|jpeg|png)$/i) ? (
-
+
) : (
[Document Preview: {doc.filename}]
)}
@@ -116,13 +124,13 @@ const DocumentViewer = ({ documents, sellerId, refreshDocs }) => {