fix product issue
This commit is contained in:
parent
70da187a52
commit
0d4ae03789
@ -330,25 +330,8 @@ const EditCompanyProfile = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (newChecked.has(productValue)) {
|
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);
|
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 {
|
} else {
|
||||||
// Re-checking: add the product back to checked
|
// Re-checking: add the product back to checked
|
||||||
newChecked.add(productValue);
|
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"
|
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
|
<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"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
@ -1216,6 +1199,7 @@ const EditCompanyProfile = () => {
|
|||||||
className="p-3 hover:bg-[#F9FAFB] flex justify-between items-center"
|
className="p-3 hover:bg-[#F9FAFB] flex justify-between items-center"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
{!isNewlyAdded && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => handleCheckboxToggle(product.value)}
|
onClick={() => handleCheckboxToggle(product.value)}
|
||||||
@ -1227,6 +1211,7 @@ const EditCompanyProfile = () => {
|
|||||||
<MdOutlineCheckBoxOutlineBlank className="text-[#92722A] text-lg" />
|
<MdOutlineCheckBoxOutlineBlank className="text-[#92722A] text-lg" />
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
{product.action_done_by === "admin_users" ? (
|
{product.action_done_by === "admin_users" ? (
|
||||||
<MdAdminPanelSettings
|
<MdAdminPanelSettings
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user