bug fixed
This commit is contained in:
parent
07e1c56da8
commit
28a56efa5a
@ -69,14 +69,11 @@ export const DetailedOverview = ({ submission, onBack }) => {
|
|||||||
setError(null);
|
setError(null);
|
||||||
const response = await fetchSubmissionDetail(submission.id);
|
const response = await fetchSubmissionDetail(submission.id);
|
||||||
if (response && response.data) {
|
if (response && response.data) {
|
||||||
console.log('Setting submission data:', response.data);
|
|
||||||
setSubmissionData(response.data);
|
setSubmissionData(response.data);
|
||||||
setQuarterPeriods(response.quarter_periods);
|
setQuarterPeriods(response.quarter_periods);
|
||||||
|
|
||||||
// Log the products array to verify it's being set correctly
|
// Log the products array to verify it's being set correctly
|
||||||
if (response.data.products) {
|
if (response.data.products) {
|
||||||
console.log('Products in response:', response.data.products);
|
|
||||||
console.log('Number of products:', response.data.products.length);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn('No data received in response');
|
console.warn('No data received in response');
|
||||||
@ -99,11 +96,7 @@ export const DetailedOverview = ({ submission, onBack }) => {
|
|||||||
}, [submission]);
|
}, [submission]);
|
||||||
|
|
||||||
const filteredProducts = useMemo(() => {
|
const filteredProducts = useMemo(() => {
|
||||||
console.log('Filtering products...');
|
|
||||||
console.log('Raw products data:', submissionData?.products);
|
|
||||||
|
|
||||||
if (!submissionData?.products || !Array.isArray(submissionData.products)) {
|
if (!submissionData?.products || !Array.isArray(submissionData.products)) {
|
||||||
console.log('No products array found in submissionData');
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,8 +134,6 @@ export const DetailedOverview = ({ submission, onBack }) => {
|
|||||||
totalItems: filtered.length,
|
totalItems: filtered.length,
|
||||||
currentPage: 1 // Reset to first page when filters change
|
currentPage: 1 // Reset to first page when filters change
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log('Filtered products:', filtered);
|
|
||||||
return filtered;
|
return filtered;
|
||||||
}, [searchTerm, selectedStatus, submissionData]);
|
}, [searchTerm, selectedStatus, submissionData]);
|
||||||
|
|
||||||
@ -229,12 +220,8 @@ export const DetailedOverview = ({ submission, onBack }) => {
|
|||||||
|
|
||||||
const rows = useMemo(() => {
|
const rows = useMemo(() => {
|
||||||
if (!filteredProducts || !Array.isArray(filteredProducts)) {
|
if (!filteredProducts || !Array.isArray(filteredProducts)) {
|
||||||
console.log('No filtered products available');
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Generating rows for filtered products:', paginatedProducts);
|
|
||||||
|
|
||||||
return paginatedProducts.map((product, index) => {
|
return paginatedProducts.map((product, index) => {
|
||||||
// Add null checks for product and product properties
|
// Add null checks for product and product properties
|
||||||
const productData = product.product || {};
|
const productData = product.product || {};
|
||||||
|
|||||||
@ -26,7 +26,6 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
|
|||||||
|
|
||||||
if (submissionStatus) {
|
if (submissionStatus) {
|
||||||
const status = String(submissionStatus).toLowerCase();
|
const status = String(submissionStatus).toLowerCase();
|
||||||
console.log("statuschecking", status);
|
|
||||||
const toastConfig = {
|
const toastConfig = {
|
||||||
approved: {
|
approved: {
|
||||||
type: 'approved',
|
type: 'approved',
|
||||||
@ -76,8 +75,6 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
|
|||||||
|
|
||||||
// Debug log to check product status and is_active
|
// Debug log to check product status and is_active
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('Product Status:', product?.status);
|
|
||||||
console.log('Product is_active:', product?.is_active);
|
|
||||||
}, [product?.status, product?.is_active]);
|
}, [product?.status, product?.is_active]);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -180,7 +177,6 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
|
|||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
// Add your resubmit logic here
|
// Add your resubmit logic here
|
||||||
console.log('Resubmit button clicked');
|
|
||||||
// You can navigate to the edit page or trigger a resubmit function
|
// You can navigate to the edit page or trigger a resubmit function
|
||||||
}}
|
}}
|
||||||
className="ml-auto px-3 py-1 bg-[#FEF2F2] text-[#7C2320] text-sm font-medium rounded hover:bg-[#FEF2F2] transition-colors"
|
className="ml-auto px-3 py-1 bg-[#FEF2F2] text-[#7C2320] text-sm font-medium rounded hover:bg-[#FEF2F2] transition-colors"
|
||||||
|
|||||||
@ -88,8 +88,6 @@ const EstablishmentInfo = ({
|
|||||||
};
|
};
|
||||||
// Debug log to see what data is being received
|
// Debug log to see what data is being received
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
console.log('EstablishmentInfo data:', data);
|
|
||||||
console.log('Establishment contact email from data:', data?.establishment_contact_email);
|
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
const info = React.useMemo(
|
const info = React.useMemo(
|
||||||
|
|||||||
@ -1095,14 +1095,14 @@ const ProductData = ({
|
|||||||
<p className="mt-1 text-xs text-red-600">{reasonsError}</p>
|
<p className="mt-1 text-xs text-red-600">{reasonsError}</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4">
|
{/* <div className="mt-4">
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Remarks</label>
|
<label className="block text-sm font-medium text-gray-700 mb-1">Remarks</label>
|
||||||
<Textarea
|
<Textarea
|
||||||
placeholder="Enter any additional remarks"
|
placeholder="Enter any additional remarks"
|
||||||
value={p.remarks || ''}
|
value={p.remarks || ''}
|
||||||
onChange={(e) => updateProductField(p.id, 'remarks', e.target.value)}
|
onChange={(e) => updateProductField(p.id, 'remarks', e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
</SectionBox>
|
</SectionBox>
|
||||||
|
|
||||||
|
|||||||
@ -748,14 +748,16 @@ const ReviewSubmit = ({
|
|||||||
|
|
||||||
<div className="bg-white rounded-md">
|
<div className="bg-white rounded-md">
|
||||||
<label className="flex items-start gap-3 text-sm text-[#4B5563]">
|
<label className="flex items-start gap-3 text-sm text-[#4B5563]">
|
||||||
<input
|
<div className="flex-shrink-0 mt-0.5">
|
||||||
type="checkbox"
|
<input
|
||||||
className="mt-1 h-4 w-4 text-[#92722A] border-gray-300 rounded"
|
type="checkbox"
|
||||||
checked={confirm}
|
className="h-4 w-4 text-[#92722A] border-gray-300 rounded focus:ring-[#92722A]"
|
||||||
disabled={hasSubmitted}
|
checked={confirm}
|
||||||
onChange={(e) => setConfirm(e.target.checked)}
|
disabled={hasSubmitted}
|
||||||
/>
|
onChange={(e) => setConfirm(e.target.checked)}
|
||||||
<span>I hereby confirm that all data entered is accurate and complete to the best of my knowledge.</span>
|
/>
|
||||||
|
</div>
|
||||||
|
<span className="leading-relaxed">I hereby confirm that all data entered is accurate and complete to the best of my knowledge.</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -379,7 +379,7 @@ const QuarterlyWindows = () => {
|
|||||||
type="button"
|
type="button"
|
||||||
className="h-8 w-8 grid place-items-center rounded hover:bg-gray-50 cursor-pointer"
|
className="h-8 w-8 grid place-items-center rounded hover:bg-gray-50 cursor-pointer"
|
||||||
title="Edit"
|
title="Edit"
|
||||||
aria-label="Edit quarter"
|
aria-label="Edit Quarterly Survey"
|
||||||
onClick={() => openEditModal(rowIndex)}
|
onClick={() => openEditModal(rowIndex)}
|
||||||
onMouseEnter={() => setHoveredEdit(rowIndex)}
|
onMouseEnter={() => setHoveredEdit(rowIndex)}
|
||||||
onMouseLeave={() => setHoveredEdit(null)}
|
onMouseLeave={() => setHoveredEdit(null)}
|
||||||
|
|||||||
@ -59,10 +59,8 @@ export const productService = {
|
|||||||
// Delete product
|
// Delete product
|
||||||
deleteProduct: async (id) => {
|
deleteProduct: async (id) => {
|
||||||
try {
|
try {
|
||||||
console.log(`Initiating delete for product ID: ${id}`);
|
|
||||||
// Use relative path since baseURL is already configured in apiClient
|
// Use relative path since baseURL is already configured in apiClient
|
||||||
const response = await deleteRequest(`/products/${id}`);
|
const response = await deleteRequest(`/products/${id}`);
|
||||||
console.log('Delete response:', response);
|
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error in productService.deleteProduct for ID ${id}:`, {
|
console.error(`Error in productService.deleteProduct for ID ${id}:`, {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user