bug fixed
This commit is contained in:
parent
8f1524a4c9
commit
3e5e23ba91
@ -291,16 +291,19 @@ const SubmissionTable = ({ selectedQuarter, selectedYear }) => {
|
||||
minHeight: filtered.length === 0 || loading ? 'auto' : '200px',
|
||||
}}
|
||||
>
|
||||
<h2 className="px-4 pr-100 py-2 mt-3 text-[18px] leading-[28px] font-medium text-[#232528]">
|
||||
{titleText}
|
||||
</h2>
|
||||
<div className="space-y-[1px] overflow-x-auto">
|
||||
{/* <div className="px-6 pt-6 pb-4">
|
||||
<h2 className="text-[18px] leading-[28px] font-medium text-[#232528]">
|
||||
{titleText}
|
||||
</h2>
|
||||
</div> */}
|
||||
|
||||
<div className="flex justify-between items-center px-4 pr-6 py-2 mt-3">
|
||||
<h2 className="text-[18px] leading-[28px] font-medium text-[#232528]">
|
||||
{titleText}
|
||||
</h2>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigate('/admin/validations')}
|
||||
className="h-9 px-4 text-sm font-medium text-white rounded-md bg-[#9E792B] hover:bg-[#846522] shadow-[0_2px_8px_rgba(146,114,42,0.25)]"
|
||||
>
|
||||
View All Submissions
|
||||
</button>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center h-[500px] text-gray-500">
|
||||
Loading submissions...
|
||||
@ -310,18 +313,12 @@ const SubmissionTable = ({ selectedQuarter, selectedYear }) => {
|
||||
No Submission Found
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto pt-5 h-[550px]">
|
||||
<div className="w-full pt-5">
|
||||
<Table
|
||||
headers={headers}
|
||||
rows={tableRows}
|
||||
separated
|
||||
rowGapClass="border-spacing-y-1"
|
||||
pagination={{
|
||||
currentPage,
|
||||
onPageChange: setCurrentPage,
|
||||
pageSize,
|
||||
totalItems: filtered.length,
|
||||
}}
|
||||
columnWidths={columnWidths}
|
||||
renderCell={(value, _, columnIndex) => {
|
||||
if (columnIndex === 10) {
|
||||
@ -398,16 +395,6 @@ const SubmissionTable = ({ selectedQuarter, selectedYear }) => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end px-6 mt-2 mb-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigate('/admin/validations')}
|
||||
className="h-9 px-4 text-sm font-medium text-white rounded-md bg-[#9E792B] hover:bg-[#846522] shadow-[0_2px_8px_rgba(146,114,42,0.25)]"
|
||||
>
|
||||
View All Submissions
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Approve Confirmation Modal */}
|
||||
{showApproveModal && selectedSubmission && (
|
||||
<div className="fixed inset-0 flex items-center justify-center z-50 p-4 bg-black/30">
|
||||
|
||||
@ -40,7 +40,6 @@ const ProductDetails = ({
|
||||
|
||||
if (submissionStatus) {
|
||||
const status = String(submissionStatus).toLowerCase();
|
||||
console.log("Status",status)
|
||||
const toastConfig = {
|
||||
approved: {
|
||||
type: 'approved',
|
||||
|
||||
@ -104,7 +104,6 @@ const EstablishmentInfo = ({
|
||||
// Initialize from location state if available, otherwise use defaults
|
||||
if (location.state?.survey) {
|
||||
const { quarter, year, endDate } = location.state.survey;
|
||||
console.log('Initializing survey data from location.state:', { quarter, year, endDate });
|
||||
|
||||
// Save to localStorage
|
||||
const surveyPeriod = { quarter, year, endDate };
|
||||
|
||||
@ -354,7 +354,6 @@ const ProductData = ({
|
||||
|
||||
if (savedSurveyPeriod) {
|
||||
const { quarter: savedQuarter, year: savedYear } = JSON.parse(savedSurveyPeriod);
|
||||
console.log('Using survey period from localStorage:', { savedQuarter, savedYear });
|
||||
periodYear = savedYear || year;
|
||||
periodQuarter = savedQuarter || quarter;
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ const buildProductRows = (products = [], options = {}) => {
|
||||
_raw: { ...product }
|
||||
};
|
||||
|
||||
console.log(`Processed product ${index + 1}:`, row); // Debug log
|
||||
// console.log(`Processed product ${index + 1}:`, row); // Debug log
|
||||
return row;
|
||||
} catch (error) {
|
||||
console.error(`Error processing product at index ${index}:`, error, product);
|
||||
|
||||
@ -393,7 +393,7 @@ React.useEffect(() => {
|
||||
if (matches) {
|
||||
console.log('Matching item:', item);
|
||||
} else {
|
||||
console.log('Filtered out item:', item, { matchSearch, matchYear, matchQuarter, matchEmirate, matchStatus });
|
||||
('Filtered out item:', item, { matchSearch, matchYear, matchQuarter, matchEmirate, matchStatus });
|
||||
}
|
||||
|
||||
return matches;
|
||||
|
||||
@ -208,6 +208,8 @@ const CompanyProfile = () => {
|
||||
const [isLoadingProducts, setIsLoadingProducts] = React.useState(false);
|
||||
const [isRefreshing, setIsRefreshing] = React.useState(false);
|
||||
const [isUpdating, setIsUpdating] = React.useState(false);
|
||||
const [formSubmitted, setFormSubmitted] = React.useState(false);
|
||||
|
||||
|
||||
const handleCloseModal = () => {
|
||||
setModalMode(null);
|
||||
@ -342,10 +344,8 @@ const CompanyProfile = () => {
|
||||
const currentUserId = React.useMemo(() => {
|
||||
try {
|
||||
const profile = sessionStorage.getItem('user_profile');
|
||||
console.log("profile678",profile)
|
||||
if (!profile) return null;
|
||||
const parsed = JSON.parse(profile);
|
||||
console.log('Current user:', parsed);
|
||||
return parsed;
|
||||
} catch (error) {
|
||||
console.error('Error parsing user profile:', error);
|
||||
@ -1182,31 +1182,38 @@ const loadProducts = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleNextStep = React.useCallback(() => {
|
||||
if (activeStep === 3 && selectedProducts.length === 0) {
|
||||
// Show error if on products step and no products are selected
|
||||
const handleNextStep = React.useCallback(() => {
|
||||
// Set form as submitted when user tries to proceed
|
||||
setFormSubmitted(true);
|
||||
|
||||
// Handle product selection validation for step 3
|
||||
if (activeStep === 3) {
|
||||
if (!selectedProducts || selectedProducts.length === 0) {
|
||||
setProductError('Please select at least one product');
|
||||
showToast('error', 'Please select at least one product');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validateStepFields(activeStep)) {
|
||||
}
|
||||
|
||||
// Rest of your validation logic
|
||||
if (activeStep === 0 && form.userProfilePassword && form.userProfilePassword !== form.userProfileConfirmPassword) {
|
||||
setConfirmError('Passwords do not match');
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeStep === 0 && form.userProfilePassword) {
|
||||
const complexityMessage = validatePasswordComplexity(form.userProfilePassword || '');
|
||||
if (complexityMessage) {
|
||||
setPasswordError(complexityMessage);
|
||||
return;
|
||||
}
|
||||
if (activeStep === 0 && form.userProfilePassword && form.userProfilePassword !== form.userProfileConfirmPassword) {
|
||||
setConfirmError('Passwords do not match');
|
||||
return;
|
||||
}
|
||||
if (activeStep === 0 && form.userProfilePassword) {
|
||||
const complexityMessage = validatePasswordComplexity(form.userProfilePassword || '');
|
||||
if (complexityMessage) {
|
||||
setPasswordError(complexityMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setConfirmError('');
|
||||
setActiveStep((prev) => Math.min(prev + 1, formSteps.length - 1));
|
||||
}, [activeStep, form.userProfilePassword, form.userProfileConfirmPassword, formSteps.length, validateStepFields]);
|
||||
}
|
||||
|
||||
// If all validations pass, reset form submitted state and proceed
|
||||
setFormSubmitted(false);
|
||||
setConfirmError('');
|
||||
setActiveStep((prev) => Math.min(prev + 1, formSteps.length - 1));
|
||||
}, [activeStep, form.userProfilePassword, form.userProfileConfirmPassword, formSteps.length, validateStepFields, selectedProducts, showToast]);
|
||||
|
||||
const handleToggleStatus = async (establishmentId, currentStatus) => {
|
||||
try {
|
||||
|
||||
@ -17,9 +17,7 @@ const createEmptyProfile = () => ({
|
||||
contactName: '',
|
||||
contactAddress: '',
|
||||
contactCityTown: '',
|
||||
contactCityTownId: '',
|
||||
contactEmirate: '',
|
||||
contactEmirateId: '',
|
||||
contactMakaniNumber: '',
|
||||
contactPersonName: '',
|
||||
contactMobileNumber: '',
|
||||
@ -46,9 +44,7 @@ const mapApiEstablishmentToProfile = (apiData) => {
|
||||
contactName: data.factory_name || '',
|
||||
contactAddress: data.establishment_address || '',
|
||||
contactCityTown: data.establishment_city?.name || '',
|
||||
contactCityTownId: data.establishment_city?.id || '',
|
||||
contactEmirate: data.establishment_emirate?.name || '',
|
||||
contactEmirateId: data.establishment_emirate?.id || '',
|
||||
contactMakaniNumber: data.establishment_makani_number || '',
|
||||
contactPersonName: data.establishment_contact_person_name || '',
|
||||
contactMobileNumber: data.establishment_mobile_number || '',
|
||||
@ -128,8 +124,8 @@ const EditCompanyProfile = () => {
|
||||
2: [
|
||||
{ field: 'contactName', label: 'Name' },
|
||||
{ field: 'contactAddress', label: 'Address' },
|
||||
{ field: 'contactEmirateId', label: 'Emirate' },
|
||||
{ field: 'contactCityTownId', label: 'City/Town' },
|
||||
{ field: 'contactEmirate', label: 'Emirate' },
|
||||
{ field: 'contactCityTown', label: 'City/Town' },
|
||||
{ field: 'contactEmail', label: 'Email' },
|
||||
],
|
||||
3: [
|
||||
@ -177,12 +173,10 @@ const EditCompanyProfile = () => {
|
||||
}, [form, requiredFieldsByStep, selectedProducts]);
|
||||
|
||||
const handleFormChange = useCallback((field, value) => {
|
||||
if (field === 'contactCityTownId') {
|
||||
const foundCity = contactCityOptions.find(option => option.value === value);
|
||||
if (field === 'contactCityTown') {
|
||||
setForm(prev => ({
|
||||
...prev,
|
||||
contactCityTown: foundCity?.label || '',
|
||||
contactCityTownId: value
|
||||
contactCityTown: value
|
||||
}));
|
||||
return;
|
||||
}
|
||||
@ -197,7 +191,7 @@ const EditCompanyProfile = () => {
|
||||
if (field === 'userProfileConfirmPassword') {
|
||||
setConfirmError("");
|
||||
}
|
||||
}, [contactCityOptions]);
|
||||
}, []);
|
||||
|
||||
const handleNext = useCallback(() => {
|
||||
if (validateStepFields(activeStep)) {
|
||||
@ -212,17 +206,24 @@ const EditCompanyProfile = () => {
|
||||
}, [activeStep]);
|
||||
|
||||
// Load cities based on selected emirate using your service function
|
||||
const loadCities = useCallback(async (emirateId) => {
|
||||
if (!emirateId) {
|
||||
const loadCities = useCallback(async (emirateName) => {
|
||||
if (!emirateName) {
|
||||
setContactCityOptions([]);
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
setIsLoadingCities(true);
|
||||
const cities = await fetchCityTowns({ emirateId });
|
||||
// Find emirate ID by name first
|
||||
const selectedEmirate = emirateOptions.find(opt => opt.label === emirateName);
|
||||
if (!selectedEmirate) {
|
||||
setContactCityOptions([]);
|
||||
return [];
|
||||
}
|
||||
|
||||
const cities = await fetchCityTowns({ emirateId: selectedEmirate.value });
|
||||
|
||||
console.log('Loaded cities for emirate', emirateId, ':', cities);
|
||||
console.log('Loaded cities for emirate', emirateName, ':', cities);
|
||||
|
||||
setContactCityOptions(cities);
|
||||
return cities;
|
||||
@ -233,7 +234,7 @@ const EditCompanyProfile = () => {
|
||||
} finally {
|
||||
setIsLoadingCities(false);
|
||||
}
|
||||
}, []);
|
||||
}, [emirateOptions]);
|
||||
|
||||
// Load products using your service function
|
||||
const loadProducts = useCallback(async () => {
|
||||
@ -387,12 +388,10 @@ const EditCompanyProfile = () => {
|
||||
initialSnapshotRef.current = formData;
|
||||
|
||||
// Then load cities and products in parallel
|
||||
const [cities, allProducts] = await Promise.all([
|
||||
formData.contactEmirateId ? loadCities(formData.contactEmirateId) : Promise.resolve([]),
|
||||
const [allProducts] = await Promise.all([
|
||||
loadProducts()
|
||||
]);
|
||||
|
||||
console.log('Loaded cities:', cities);
|
||||
console.log('All products loaded:', allProducts);
|
||||
|
||||
// Set selected products from API response
|
||||
@ -431,14 +430,14 @@ const EditCompanyProfile = () => {
|
||||
};
|
||||
}, [establishmentId]); // Remove loadCities and loadProducts from dependencies
|
||||
|
||||
// Load contact cities when emirate ID changes
|
||||
// Load contact cities when emirate changes
|
||||
useEffect(() => {
|
||||
let isMounted = true;
|
||||
|
||||
const loadCitiesForEmirate = async () => {
|
||||
if (form.contactEmirateId) {
|
||||
if (form.contactEmirate) {
|
||||
try {
|
||||
const cities = await fetchCityTowns({ emirateId: form.contactEmirateId });
|
||||
const cities = await loadCities(form.contactEmirate);
|
||||
if (isMounted) {
|
||||
setContactCityOptions(cities);
|
||||
}
|
||||
@ -451,7 +450,7 @@ const EditCompanyProfile = () => {
|
||||
} else if (isMounted) {
|
||||
setContactCityOptions([]);
|
||||
// Clear city selection when emirate is cleared
|
||||
handleFormChange('contactCityTownId', '');
|
||||
handleFormChange('contactCityTown', '');
|
||||
}
|
||||
};
|
||||
|
||||
@ -460,7 +459,7 @@ const EditCompanyProfile = () => {
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [form.contactEmirateId]);
|
||||
}, [form.contactEmirate, loadCities]);
|
||||
|
||||
// Calculate totals when employment numbers change
|
||||
useEffect(() => {
|
||||
@ -482,6 +481,10 @@ const EditCompanyProfile = () => {
|
||||
|
||||
try {
|
||||
setLoading(true);
|
||||
|
||||
// Find emirate and city IDs by name for the API call
|
||||
const selectedEmirate = emirateOptions.find(opt => opt.label === form.contactEmirate);
|
||||
const selectedCity = contactCityOptions.find(opt => opt.label === form.contactCityTown);
|
||||
|
||||
const establishmentData = {
|
||||
establishment_code: form.uniqueLicenseNumber || "",
|
||||
@ -492,8 +495,8 @@ const EditCompanyProfile = () => {
|
||||
isic_code: form.industryCodeCurrent || "",
|
||||
description: form.industryDescription || "",
|
||||
establishment_address: form.contactAddress || "",
|
||||
establishment_city_town_id: form.contactCityTownId ? Number(form.contactCityTownId) : null,
|
||||
establishment_emirate_id: form.contactEmirateId ? Number(form.contactEmirateId) : null,
|
||||
establishment_city_town_id: selectedCity ? Number(selectedCity.value) : null,
|
||||
establishment_emirate_id: selectedEmirate ? Number(selectedEmirate.value) : null,
|
||||
establishment_postal_code: form.contactPostalCode || "",
|
||||
establishment_po_box: form.contactPoBox || "",
|
||||
establishment_makani_number: form.contactMakaniNumber || "",
|
||||
@ -670,43 +673,39 @@ const EditCompanyProfile = () => {
|
||||
/>
|
||||
<SelectField
|
||||
label="Emirate"
|
||||
name="contactEmirateId"
|
||||
value={form.contactEmirateId || ''}
|
||||
name="contactEmirate"
|
||||
value={form.contactEmirate || ''}
|
||||
onChange={(e) => {
|
||||
const selectedValue = e.target.value;
|
||||
const selectedEmirate = emirateOptions.find(opt => opt.value === selectedValue);
|
||||
|
||||
handleFormChange("contactEmirate", selectedEmirate?.label || '');
|
||||
handleFormChange("contactEmirateId", selectedValue);
|
||||
handleFormChange("contactEmirate", selectedValue);
|
||||
handleFormChange("contactCityTown", '');
|
||||
handleFormChange("contactCityTownId", '');
|
||||
}}
|
||||
options={emirateOptions.map(opt => ({
|
||||
value: opt.value,
|
||||
value: opt.label,
|
||||
label: opt.label
|
||||
}))}
|
||||
placeholder="Select Emirate"
|
||||
width="100%"
|
||||
required
|
||||
error={fieldErrors.contactEmirateId}
|
||||
error={fieldErrors.contactEmirate}
|
||||
/>
|
||||
<SelectField
|
||||
label="City/Town"
|
||||
name="contactCityTownId"
|
||||
value={form.contactCityTownId || ''}
|
||||
name="contactCityTown"
|
||||
value={form.contactCityTown || ''}
|
||||
onChange={(e) => {
|
||||
const selectedValue = e.target.value;
|
||||
handleFormChange("contactCityTownId", selectedValue);
|
||||
handleFormChange("contactCityTown", selectedValue);
|
||||
}}
|
||||
options={contactCityOptions.map(opt => ({
|
||||
value: opt.value,
|
||||
value: opt.label,
|
||||
label: opt.label
|
||||
}))}
|
||||
placeholder={form.contactEmirateId ? (isLoadingCities ? "Loading cities..." : "Select City/Town") : "Select emirate first"}
|
||||
placeholder={form.contactEmirate ? (isLoadingCities ? "Loading cities..." : "Select City/Town") : "Select emirate first"}
|
||||
width="100%"
|
||||
required
|
||||
disabled={!form.contactEmirateId || isLoadingCities}
|
||||
error={fieldErrors.contactCityTownId}
|
||||
disabled={!form.contactEmirate || isLoadingCities}
|
||||
error={fieldErrors.contactCityTown}
|
||||
/>
|
||||
<TextField
|
||||
label="Postal Code"
|
||||
@ -948,10 +947,9 @@ const EditCompanyProfile = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen">
|
||||
<HeaderBar />
|
||||
|
||||
<div className="p-10 mx-auto ">
|
||||
<div className="min-h-screen bg-[#F8FAFC]">
|
||||
<HeaderBar />
|
||||
<div className="max-w-[1280px] mx-auto px-4 py-6">
|
||||
<div className="bg-white overflow-hidden">
|
||||
{loading && <Loader />}
|
||||
|
||||
|
||||
@ -272,8 +272,6 @@ const UnitMaster = () => {
|
||||
unitData.created_by_name = currentUser.name;
|
||||
}
|
||||
|
||||
console.log('Saving unit data:', unitData);
|
||||
|
||||
try {
|
||||
setSaveLoading(true);
|
||||
|
||||
|
||||
@ -25,12 +25,24 @@ const Banner = () => {
|
||||
|
||||
{/* Buttons */}
|
||||
<div className="flex flex-col md:flex-row justify-center gap-4">
|
||||
<button className="bg-[#92722A] w-48 text-white text-md px-5 py-2 rounded-md hover:bg-[#a07f30] transition-all shadow-sm">
|
||||
Sign in to submit
|
||||
</button>
|
||||
<button className="border-2 border-[#92722A] text-[#92722A] text-md px-5 py-2 rounded-md hover:bg-[#f9f6ec] transition-all shadow-sm">
|
||||
How the survey works
|
||||
</button>
|
||||
<a
|
||||
href="/login"
|
||||
className="bg-[#92722A] w-48 text-white text-md px-5 py-2 rounded-md hover:bg-[#a07f30] transition-all shadow-sm inline-flex items-center justify-center no-underline"
|
||||
>
|
||||
Sign in to submit
|
||||
</a>
|
||||
<button
|
||||
onClick={() => {
|
||||
// Scroll to How it works section
|
||||
const howItWorksSection = document.getElementById('how-it-works');
|
||||
if (howItWorksSection) {
|
||||
howItWorksSection.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
}}
|
||||
className="border-2 border-[#92722A] text-[#92722A] text-md px-5 py-2 rounded-md hover:bg-[#f9f6ec] transition-all shadow-sm"
|
||||
>
|
||||
How the survey works
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
||||
@ -564,7 +564,7 @@ const Survey = () => {
|
||||
// First try to get quarter and year from currentSurveyPeriod in localStorage
|
||||
let quarter = '';
|
||||
let year = '';
|
||||
|
||||
const surveyRemarks = localStorage.getItem('surveyRemarks') || '';
|
||||
// Check for currentSurveyPeriod in localStorage
|
||||
const currentSurveyPeriod = localStorage.getItem('currentSurveyPeriod');
|
||||
if (currentSurveyPeriod) {
|
||||
@ -607,12 +607,19 @@ const Survey = () => {
|
||||
non_emirati_female: parseNumber(info.nonEmiratiFemale),
|
||||
total_emirati: parseNumber(info.totalEmirati),
|
||||
total_employees: parseNumber(info.totalEmployees),
|
||||
remarks: remarks, // Add remarks to the payload
|
||||
// remarks: surveyRemarks,
|
||||
// surveyRemarks: surveyRemarks, // Add survey remarks from local storage
|
||||
products: productsData.map((product) => {
|
||||
|
||||
const variationId = parseNumber(product.variationReason, null);
|
||||
const zeroTargetId = parseNumber(product.zeroTargetReason, null);
|
||||
const productId = parseNumber(product.id);
|
||||
|
||||
// Get remarks from the product object
|
||||
// Check in this order: product.remarks, product.originalData.remarks, product.originalData['product.remarks']
|
||||
const productRemarks = surveyRemarks;
|
||||
|
||||
|
||||
// Map monthly data to period-specific fields
|
||||
return {
|
||||
...(isResubmitFlow && productId ? { id: productId } : {}), // Only include ID during resubmit
|
||||
@ -621,12 +628,15 @@ const Survey = () => {
|
||||
annual_installed_capacity: stringify(product.capacity),
|
||||
|
||||
// Previous Quarter (Q4) - October, November, December
|
||||
previous_quantity_period_one: stringify(product.octQuantity || '0'),
|
||||
previous_quantity_period_two: stringify(product.novQuantity || '0'),
|
||||
previous_quantity_period_three: stringify(product.decQuantity || '0'),
|
||||
previous_cost_period_one: stringify(product.octCost || '0'),
|
||||
previous_cost_period_two: stringify(product.novCost || '0'),
|
||||
previous_cost_period_three: stringify(product.decCost || '0'),
|
||||
octQuantity: stringify(product.q4_oct_quantity || ''),
|
||||
novQuantity: stringify(product.q4_nov_quantity || ''),
|
||||
decQuantity: stringify(product.q4_dec_quantity || ''),
|
||||
octCost: stringify(product.q4_oct_cost || ''),
|
||||
novCost: stringify(product.q4_nov_cost || ''),
|
||||
decCost: stringify(product.q4_dec_cost || ''),
|
||||
|
||||
// Add remarks to the product payload
|
||||
remarks: surveyRemarks,
|
||||
|
||||
// Current Quarter (Q1) - January, February, March
|
||||
current_quantity_period_one: stringify(product.janQuantity || '0'),
|
||||
@ -681,7 +691,7 @@ const Survey = () => {
|
||||
other_variation_reason: stringify(product.otherVariationReason || ''),
|
||||
zero_target_reason_master_id: Number.isFinite(zeroTargetId) ? zeroTargetId : null,
|
||||
other_zero_target_reason: stringify(product.otherZeroTargetReason || ''),
|
||||
remarks: stringify(product.remarks || '')
|
||||
remarks: stringify(surveyRemarks)
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
||||
@ -20,8 +20,6 @@ export const getSubmissions = async (params = {}) => {
|
||||
...restParams
|
||||
} = params;
|
||||
|
||||
console.log('getSubmissions called with params:', { quarter, year, page, limit, ...restParams });
|
||||
|
||||
// Build query string
|
||||
const queryParams = new URLSearchParams();
|
||||
|
||||
|
||||
@ -15,11 +15,8 @@ export const getUnits = async () => {
|
||||
|
||||
export const createUnit = async (unitData) => {
|
||||
try {
|
||||
// Log the data being sent for debugging
|
||||
console.log('Creating unit with data:', unitData);
|
||||
|
||||
const response = await postRequest(UNIT_MASTER_ENDPOINT, unitData);
|
||||
console.log('Unit created successfully:', response.data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error creating unit:', error);
|
||||
@ -34,10 +31,7 @@ export const createUnit = async (unitData) => {
|
||||
|
||||
export const updateUnit = async (id, unitData) => {
|
||||
try {
|
||||
console.log('Updating unit with data:', unitData);
|
||||
|
||||
const response = await putRequest(`${UNIT_MASTER_ENDPOINT}/${id}`, unitData);
|
||||
console.log('Unit updated successfully:', response.data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error updating unit:', error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user