Merge branch 'master' of https://bitbucket.org/jubilian/fcsc_ipi_frontend
This commit is contained in:
commit
96e866271e
@ -69,14 +69,11 @@ export const DetailedOverview = ({ submission, onBack }) => {
|
||||
setError(null);
|
||||
const response = await fetchSubmissionDetail(submission.id);
|
||||
if (response && response.data) {
|
||||
console.log('Setting submission data:', response.data);
|
||||
setSubmissionData(response.data);
|
||||
setQuarterPeriods(response.quarter_periods);
|
||||
|
||||
// Log the products array to verify it's being set correctly
|
||||
if (response.data.products) {
|
||||
console.log('Products in response:', response.data.products);
|
||||
console.log('Number of products:', response.data.products.length);
|
||||
}
|
||||
} else {
|
||||
console.warn('No data received in response');
|
||||
@ -99,11 +96,7 @@ export const DetailedOverview = ({ submission, onBack }) => {
|
||||
}, [submission]);
|
||||
|
||||
const filteredProducts = useMemo(() => {
|
||||
console.log('Filtering products...');
|
||||
console.log('Raw products data:', submissionData?.products);
|
||||
|
||||
if (!submissionData?.products || !Array.isArray(submissionData.products)) {
|
||||
console.log('No products array found in submissionData');
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -141,8 +134,6 @@ export const DetailedOverview = ({ submission, onBack }) => {
|
||||
totalItems: filtered.length,
|
||||
currentPage: 1 // Reset to first page when filters change
|
||||
}));
|
||||
|
||||
console.log('Filtered products:', filtered);
|
||||
return filtered;
|
||||
}, [searchTerm, selectedStatus, submissionData]);
|
||||
|
||||
@ -229,12 +220,8 @@ export const DetailedOverview = ({ submission, onBack }) => {
|
||||
|
||||
const rows = useMemo(() => {
|
||||
if (!filteredProducts || !Array.isArray(filteredProducts)) {
|
||||
console.log('No filtered products available');
|
||||
return [];
|
||||
}
|
||||
|
||||
console.log('Generating rows for filtered products:', paginatedProducts);
|
||||
|
||||
return paginatedProducts.map((product, index) => {
|
||||
// Add null checks for product and product properties
|
||||
const productData = product.product || {};
|
||||
|
||||
@ -26,7 +26,6 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
|
||||
|
||||
if (submissionStatus) {
|
||||
const status = String(submissionStatus).toLowerCase();
|
||||
console.log("statuschecking", status);
|
||||
const toastConfig = {
|
||||
approved: {
|
||||
type: 'approved',
|
||||
@ -76,8 +75,6 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
|
||||
|
||||
// Debug log to check product status and is_active
|
||||
useEffect(() => {
|
||||
console.log('Product Status:', product?.status);
|
||||
console.log('Product is_active:', product?.is_active);
|
||||
}, [product?.status, product?.is_active]);
|
||||
|
||||
const navigate = useNavigate();
|
||||
@ -180,7 +177,6 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
|
||||
<button
|
||||
onClick={() => {
|
||||
// Add your resubmit logic here
|
||||
console.log('Resubmit button clicked');
|
||||
// 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"
|
||||
|
||||
@ -88,8 +88,6 @@ const EstablishmentInfo = ({
|
||||
};
|
||||
// Debug log to see what data is being received
|
||||
React.useEffect(() => {
|
||||
console.log('EstablishmentInfo data:', data);
|
||||
console.log('Establishment contact email from data:', data?.establishment_contact_email);
|
||||
}, [data]);
|
||||
|
||||
const info = React.useMemo(
|
||||
|
||||
@ -209,12 +209,10 @@ const ProductData = ({
|
||||
const productsController = new AbortController();
|
||||
const unitsController = new AbortController();
|
||||
const loadReasons = async () => {
|
||||
console.log('Fetching variation reasons...');
|
||||
setIsLoadingReasons(true);
|
||||
setReasonsError('');
|
||||
try {
|
||||
const reasons = await fetchVariationReasons({ signal: variationController.signal });
|
||||
console.log('Variation reasons fetched:', reasons);
|
||||
setVariationReasons(reasons);
|
||||
setReasonsError('');
|
||||
} catch (error) {
|
||||
@ -249,7 +247,6 @@ const ProductData = ({
|
||||
setProductsError('');
|
||||
try {
|
||||
const productsList = await fetchProducts({ signal: productsController.signal });
|
||||
console.log('Products fetched:', productsList);
|
||||
setProductOptions(productsList);
|
||||
setProductsError('');
|
||||
} catch (error) {
|
||||
@ -431,7 +428,6 @@ const ProductData = ({
|
||||
productId
|
||||
);
|
||||
|
||||
console.log('API Response:', response);
|
||||
|
||||
if (!response) {
|
||||
console.warn('Empty response from getPreviousForecastData');
|
||||
@ -511,7 +507,6 @@ const ProductData = ({
|
||||
localStorage.getItem('establishmentId') ||
|
||||
localStorage.getItem('establishment_id');
|
||||
|
||||
console.log('Retrieved establishment ID:', establishmentId);
|
||||
|
||||
if (establishmentId && quarter && year) {
|
||||
// Get the actual product ID from the selected product object
|
||||
@ -605,10 +600,7 @@ const ProductData = ({
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('Fetching forecast data...');
|
||||
const forecastData = await fetchPreviousForecastData(productId, establishmentId);
|
||||
console.log('Forecast data received:', forecastData);
|
||||
|
||||
const forecastData = await fetchPreviousForecastData(productId, establishmentId);
|
||||
if (!forecastData) {
|
||||
console.warn('No forecast data received for product:', productId);
|
||||
return;
|
||||
@ -1095,14 +1087,14 @@ const ProductData = ({
|
||||
<p className="mt-1 text-xs text-red-600">{reasonsError}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
{/* <div className="mt-4">
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Remarks</label>
|
||||
<Textarea
|
||||
placeholder="Enter any additional remarks"
|
||||
value={p.remarks || ''}
|
||||
onChange={(e) => updateProductField(p.id, 'remarks', e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
</SectionBox>
|
||||
|
||||
|
||||
@ -172,11 +172,9 @@ const buildProductRows = (products = [], options = {}) => {
|
||||
try {
|
||||
// Find the full product details from productOptions if available
|
||||
const fullProduct = productOptions.find(p => p.id === product.productId || p.value === product.productId);
|
||||
console.log("fullProduct",fullProduct)
|
||||
// Extract product details with better fallbacks
|
||||
const productId = product.id || `product-${Math.random().toString(36).substr(2, 9)}`;
|
||||
const productName = fullProduct?.label || fullProduct?.name || product.productName || product.product?.name || product.product;
|
||||
console.log("productName",productName)
|
||||
const productCode = fullProduct?.code || product.productCode || product.code || product.product?.code || product.id || `CODE-${index + 1}`;
|
||||
console.log("productCode",productCode)
|
||||
// Use stored unitName if available, otherwise try to find it in unitOptions
|
||||
@ -748,14 +746,16 @@ const ReviewSubmit = ({
|
||||
|
||||
<div className="bg-white rounded-md">
|
||||
<label className="flex items-start gap-3 text-sm text-[#4B5563]">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="mt-1 h-4 w-4 text-[#92722A] border-gray-300 rounded"
|
||||
checked={confirm}
|
||||
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 className="flex-shrink-0 mt-0.5">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="h-4 w-4 text-[#92722A] border-gray-300 rounded focus:ring-[#92722A]"
|
||||
checked={confirm}
|
||||
disabled={hasSubmitted}
|
||||
onChange={(e) => setConfirm(e.target.checked)}
|
||||
/>
|
||||
</div>
|
||||
<span className="leading-relaxed">I hereby confirm that all data entered is accurate and complete to the best of my knowledge.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
@ -76,9 +76,7 @@ const AdminUsers = () => {
|
||||
const fetchUsers = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
console.log('Fetching admin users...'); // Debug log
|
||||
const response = await getAdminUser();
|
||||
console.log('API Response:', response); // Debug log
|
||||
|
||||
// Check if response is an array directly or if it's in a data property
|
||||
const usersData = Array.isArray(response) ? response :
|
||||
@ -104,7 +102,6 @@ const AdminUsers = () => {
|
||||
is_active: user.is_active, // Keep the original is_active for reference
|
||||
}));
|
||||
|
||||
console.log('Mapped users:', mappedUsers); // Debug log
|
||||
setUsers(mappedUsers);
|
||||
} else {
|
||||
const errorMsg = 'Invalid response format: Expected an array of users';
|
||||
@ -176,9 +173,7 @@ const AdminUsers = () => {
|
||||
|
||||
try {
|
||||
setLoading(true);
|
||||
console.log('Fetching user data for ID:', user.id); // Debug log
|
||||
const userData = await getAdminUserById(user.id);
|
||||
console.log('User data received:', userData); // Debug log
|
||||
|
||||
if (!userData) {
|
||||
throw new Error('No user data received');
|
||||
|
||||
@ -329,10 +329,8 @@ const EditCompanyProfile = ({ onClose: propOnClose }) => {
|
||||
// Fetch establishment details when ID is provided
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
console.log('Establishment ID:', establishmentId);
|
||||
|
||||
if (!establishmentId) {
|
||||
console.log('No establishment ID provided');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -379,7 +379,7 @@ const QuarterlyWindows = () => {
|
||||
type="button"
|
||||
className="h-8 w-8 grid place-items-center rounded hover:bg-gray-50 cursor-pointer"
|
||||
title="Edit"
|
||||
aria-label="Edit quarter"
|
||||
aria-label="Edit Quarterly Survey"
|
||||
onClick={() => openEditModal(rowIndex)}
|
||||
onMouseEnter={() => setHoveredEdit(rowIndex)}
|
||||
onMouseLeave={() => setHoveredEdit(null)}
|
||||
|
||||
@ -24,7 +24,6 @@ const SubmissionDeadlines = () => {
|
||||
|
||||
const handleSave = () => {
|
||||
// Future: Replace with save logic
|
||||
console.log('Saving submission deadlines', form);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -56,15 +56,10 @@ const UnitMaster = () => {
|
||||
const fetchUnits = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await getUnits();
|
||||
console.log("API Response:", response); // Log the full response
|
||||
|
||||
const response = await getUnits();
|
||||
const unitsData = response.data || [];
|
||||
console.log("Units Data:", unitsData); // Log the units data
|
||||
|
||||
// Process units to ensure mapped_products_count is included
|
||||
const processedUnits = unitsData.map(unit => {
|
||||
console.log("Processing unit:", unit); // Log each unit being processed
|
||||
return {
|
||||
...unit,
|
||||
mapped_products_count: unit.mapped_products_count !== undefined
|
||||
@ -73,7 +68,6 @@ const fetchUnits = async () => {
|
||||
};
|
||||
});
|
||||
|
||||
console.log("Processed Units:", processedUnits); // Log the processed units
|
||||
|
||||
// Sort by latest created_at date (newest first)
|
||||
const sortedUnits = [...processedUnits].sort(
|
||||
@ -119,8 +113,6 @@ const fetchUnits = async () => {
|
||||
: '-';
|
||||
const currentUserName = currentUser?.name || '';
|
||||
|
||||
console.log("Rendering row with item:", item); // Log the item being rendered
|
||||
|
||||
return [
|
||||
item.uom || item.unitName, // Unit Name
|
||||
item.uom_short_name || item.description, // Description
|
||||
|
||||
@ -396,7 +396,6 @@ const Survey = () => {
|
||||
}),
|
||||
};
|
||||
}, [establishmentData, parseNumber, productsData, stringify]);
|
||||
console.log("productsData",productsData)
|
||||
|
||||
const handleNext = () => {
|
||||
if (step < 3) {
|
||||
@ -420,7 +419,6 @@ const Survey = () => {
|
||||
|
||||
// Navigate to overview page after successful submission
|
||||
// navigate('/overview');
|
||||
console.log('Survey submission response:', response);
|
||||
showToast('success', response?.message || 'You have successfully submitted the survey.');
|
||||
setShowSuccessPopup(true);
|
||||
setHasSubmitted(true);
|
||||
|
||||
@ -59,10 +59,8 @@ export const productService = {
|
||||
// Delete product
|
||||
deleteProduct: async (id) => {
|
||||
try {
|
||||
console.log(`Initiating delete for product ID: ${id}`);
|
||||
// Use relative path since baseURL is already configured in apiClient
|
||||
const response = await deleteRequest(`/products/${id}`);
|
||||
console.log('Delete response:', response);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error(`Error in productService.deleteProduct for ID ${id}:`, {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user