Skip to content

Commit 82cb50c

Browse files
committed
added corfirm-delete dialogue popup for deleting seller item
1 parent b8202a6 commit 82cb50c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/components/shared/Seller/ShopItem.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useState, SetStateAction, useContext, useEffect, useRef } from "react";
44
import { useTranslations, useLocale } from "next-intl";
55
import { Button } from "../Forms/Buttons/Buttons";
66
import { TextArea, Input, FileInput, Select } from "../Forms/Inputs/Inputs";
7-
import { Notification } from "../confirm";
7+
import { ConfirmDialogX, Notification } from "../confirm";
88
import { ISeller, SellerItem, StockLevelType } from "@/constants/types";
99
import { addOrUpdateSellerItem, deleteSellerItem, fetchSellerItems } from "@/services/sellerApi";
1010
import removeUrls from "@/utils/sanitize";
@@ -200,6 +200,7 @@ export const ShopItem: React.FC<{
200200
const [previewImage, setPreviewImage] = useState<string>(
201201
formData?.image || '',
202202
);
203+
const [showPopup, setShowPopup] = useState(false);
203204
const [showDialog, setShowDialog] = useState<boolean>(false);
204205
const [file, setFile] = useState<File | null>(null);
205206
const { reload, setReload, showAlert } = useContext(AppContext);
@@ -300,7 +301,7 @@ export const ShopItem: React.FC<{
300301
const resp = await deleteSellerItem(item_id);
301302
if (resp) {
302303
setReload(true);
303-
setShowDialog(true);
304+
// setShowDialog(true);
304305
setIsAddItemEnabled(false);
305306
showAlert(t('SCREEN.SELLER_REGISTRATION.VALIDATION.SUCCESSFUL_SELLER_ITEM_DELETED'));
306307
}
@@ -418,7 +419,7 @@ export const ShopItem: React.FC<{
418419
padding: '5px 8px',
419420
width: "100%"
420421
}}
421-
onClick={()=>handleDelete(formData._id)}
422+
onClick={()=>setShowPopup(true)}
422423
/>
423424
<Button
424425
label={t('SHARED.SAVE')}
@@ -461,6 +462,13 @@ export const ShopItem: React.FC<{
461462
</div>
462463
</div>
463464
</div>
465+
{showPopup && (
466+
<ConfirmDialogX
467+
toggle={() => setShowPopup(false)}
468+
handleClicked={()=> handleDelete(formData._id)}
469+
message={t('SHARED.MAP_CENTER.VALIDATION.MAP_CENTER_SUCCESS_MESSAGE')}
470+
/>
471+
)}
464472
</>
465473
);
466474
};

0 commit comments

Comments
 (0)