fix product issue
This commit is contained in:
parent
70da187a52
commit
0d4ae03789
@ -330,25 +330,8 @@ const EditCompanyProfile = () => {
|
||||
);
|
||||
|
||||
if (newChecked.has(productValue)) {
|
||||
// Unchecking: move product from selected to available
|
||||
// Unchecking: only remove from checked, don't add to available products
|
||||
newChecked.delete(productValue);
|
||||
|
||||
if (product) {
|
||||
// Add product back to available products
|
||||
setAvailableProducts(prev => {
|
||||
const alreadyExists = prev.some(p =>
|
||||
(p.value && p.value === product.value) ||
|
||||
(p.id && p.id === product.id) ||
|
||||
(p.product_id && p.product_id === product.product_id)
|
||||
);
|
||||
|
||||
if (!alreadyExists) {
|
||||
console.log('ADDING TO AVAILABLE - new length will be:', prev.length + 1);
|
||||
return [...prev, product];
|
||||
}
|
||||
return prev;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Re-checking: add the product back to checked
|
||||
newChecked.add(productValue);
|
||||
@ -1134,7 +1117,7 @@ const EditCompanyProfile = () => {
|
||||
className="w-full px-3 py-2 border border-[#D1D5DB] rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-[#92722A] focus:border-transparent"
|
||||
/>
|
||||
<svg
|
||||
className="absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"
|
||||
className="absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-[#D8C27A]"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
@ -1216,6 +1199,7 @@ const EditCompanyProfile = () => {
|
||||
className="p-3 hover:bg-[#F9FAFB] flex justify-between items-center"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
{!isNewlyAdded && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleCheckboxToggle(product.value)}
|
||||
@ -1227,6 +1211,7 @@ const EditCompanyProfile = () => {
|
||||
<MdOutlineCheckBoxOutlineBlank className="text-[#92722A] text-lg" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{product.action_done_by === "admin_users" ? (
|
||||
<MdAdminPanelSettings
|
||||
|
||||
Loading…
Reference in New Issue
Block a user