Skip to content

Commit

Permalink
fix: mise a jour de la suppression de doublon (#3956)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomarom authored Dec 26, 2024
1 parent 0bec091 commit 1071ea4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const EffectifDoublonDeleteAlertDialog = ({
isOpen: boolean;
onClose?: () => void;
cancelRef;
duplicateDetail: DuplicateEffectifDetail;
duplicateDetail?: DuplicateEffectifDetail;
}) => {
const queryClient = useQueryClient();
const { trackPlausibleEvent } = usePlausibleTracking();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const EffectifsDoublonsDetailTable = ({ data }: { data: any }) => {
const { ref, onMouseUp, onMouseDown, isDragging } = useDraggableScroll();
const { trackPlausibleEvent } = usePlausibleTracking();
const { isOpen: isOpenAlertDialog, onOpen: onOpenAlertDialog, onClose: onCloseAlertDialog } = useDisclosure();
const [currentEffectifDuplicate, setCurrentEffectifDuplicate] = useState<DuplicateEffectifDetail>();

const cancelRef = useRef();
const tableRef = useRef<HTMLTableElement>(null);
const topScrollRef = useRef<HTMLDivElement>(null);
Expand All @@ -86,6 +88,16 @@ const EffectifsDoublonsDetailTable = ({ data }: { data: any }) => {
}
}, [tableRef.current?.offsetWidth]);

const handleDialogOpen = (duplicate: DuplicateEffectifDetail) => {
setCurrentEffectifDuplicate(duplicate);
onOpenAlertDialog();
};

const handleDialogClose = () => {
setCurrentEffectifDuplicate(undefined);
onCloseAlertDialog();
};

const renderTableGroupHeader = (title: string, duplicates: DuplicateEffectifDetail[], icon: string) => (
<Thead color="bluefrances">
<Tr>
Expand Down Expand Up @@ -345,19 +357,13 @@ const EffectifsDoublonsDetailTable = ({ data }: { data: any }) => {
variant="secondary"
onClick={() => {
trackPlausibleEvent("suppression_doublons_effectifs");
onOpenAlertDialog();
handleDialogOpen(duplicate);
}}
>
<Box as="i" className="ri-delete-bin-line" mr={2} />
<Text as="span">Supprimer</Text>
</Button>
</Flex>
<EffectifDoublonDeleteAlertDialog
cancelRef={cancelRef}
isOpen={isOpenAlertDialog}
onClose={onCloseAlertDialog}
duplicateDetail={duplicate}
/>
</Th>
))}
</Tr>
Expand All @@ -371,6 +377,12 @@ const EffectifsDoublonsDetailTable = ({ data }: { data: any }) => {
</Box>
</Box>
</ScrollShadowBox>
<EffectifDoublonDeleteAlertDialog
cancelRef={cancelRef}
isOpen={isOpenAlertDialog}
onClose={handleDialogClose}
duplicateDetail={currentEffectifDuplicate}
/>
</>
);
};
Expand Down

0 comments on commit 1071ea4

Please sign in to comment.