fix: error in changing agent representation type

This commit is contained in:
Mahyar Khanbolooki
2025-09-14 18:18:20 +03:30
parent 8a37d3f1ef
commit 29f53c703d
@@ -599,6 +599,7 @@ module.exports.getOne = [
Date.now()
)
notifyAdmin('updateNewRepresentations')
console.log("S")
return res.json(representation)
} else return res.json(representation)
} catch (e) {
@@ -871,10 +872,16 @@ module.exports.update_representation_by_admin = [
'computer_accessories',
'memory_products',
'car_audio_video',
'home_products'
'home_products',
]
const oldValues = [
'verity',
'panatech',
'both',
]
if (!Array.isArray(value)) return Promise.reject(new Error('نوع نمایندگی باید به صورت آرایه باشد'))
if (value.length === 0) return Promise.reject(new Error('حداقل یک نوع نمایندگی را انتخاب کنید'))
value = value.filter(x => !oldValues.includes(x))
const isValid = value.every(item => acceptedValues.includes(item))
if (!isValid) return Promise.reject(new Error('مقدار نامعتبر برای نوع نمایندگی'))
return true