Skip to content

Commit 0d37f6d

Browse files
author
CsB-Polymesh
committed
added confirmation
1 parent 5b49c86 commit 0d37f6d

1 file changed

Lines changed: 35 additions & 5 deletions

File tree

src/layouts/AssetManager/components/AssetControlCenter/components/sections/VenueFilteringSection.tsx

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from 'react';
2-
import { Icon } from '~/components';
2+
import { BigNumber } from '@polymeshassociation/polymesh-sdk';
3+
import { ConfirmationModal, Icon } from '~/components';
34
import { ComingSoonModal } from '../modals';
45
import { useAssetActionsContext } from '../../context';
56
import type { TabProps, VenueConfig } from '../../types';
@@ -24,6 +25,8 @@ export const VenueFilteringSection: React.FC<VenueFilteringSectionProps> = ({
2425
}) => {
2526
const [comingSoonModalOpen, setComingSoonModalOpen] = useState(false);
2627
const [comingSoonFeature, setComingSoonFeature] = useState('');
28+
const [removeConfirmOpen, setRemoveConfirmOpen] = useState(false);
29+
const [venueIdToRemove, setVenueIdToRemove] = useState<string | null>(null);
2730
const { setVenueFiltering, transactionInProcess } = useAssetActionsContext();
2831

2932
const handleToggleVenueFiltering = async () => {
@@ -43,10 +46,24 @@ export const VenueFilteringSection: React.FC<VenueFilteringSectionProps> = ({
4346
setComingSoonModalOpen(true);
4447
};
4548

46-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
47-
const handleRemoveVenue = (_venueId: string) => {
48-
setComingSoonFeature('remove venue restriction');
49-
setComingSoonModalOpen(true);
49+
const handleRemoveVenue = (venueId: string) => {
50+
setVenueIdToRemove(venueId);
51+
setRemoveConfirmOpen(true);
52+
};
53+
54+
const confirmRemoveVenue = async () => {
55+
if (venueIdToRemove) {
56+
try {
57+
await setVenueFiltering({
58+
disallowedVenues: [new BigNumber(venueIdToRemove)],
59+
});
60+
setVenueIdToRemove(null);
61+
} catch (error) {
62+
notifyError(
63+
`Error removing venue restriction: ${(error as Error).message}`,
64+
);
65+
}
66+
}
5067
};
5168

5269
const venueConfig: VenueConfig = {
@@ -108,6 +125,19 @@ export const VenueFilteringSection: React.FC<VenueFilteringSectionProps> = ({
108125
onClose={() => setComingSoonModalOpen(false)}
109126
feature={comingSoonFeature}
110127
/>
128+
129+
<ConfirmationModal
130+
isOpen={removeConfirmOpen}
131+
onClose={() => {
132+
setRemoveConfirmOpen(false);
133+
setVenueIdToRemove(null);
134+
}}
135+
onConfirm={confirmRemoveVenue}
136+
title="Remove Venue Restriction"
137+
message={`Are you sure you want to remove venue ${venueIdToRemove} from the allowed venues list?`}
138+
confirmLabel="Remove Venue"
139+
isProcessing={transactionInProcess}
140+
/>
111141
</>
112142
);
113143
};

0 commit comments

Comments
 (0)