144 lines
3.0 KiB
React
144 lines
3.0 KiB
React
|
|
import React, { useState } from "react";
|
||
|
|
import {
|
||
|
|
Modal,
|
||
|
|
ModalOverlay,
|
||
|
|
ModalContent,
|
||
|
|
ModalHeader,
|
||
|
|
ModalFooter,
|
||
|
|
ModalBody,
|
||
|
|
ModalCloseButton,
|
||
|
|
useDisclosure,
|
||
|
|
Button,
|
||
|
|
Box,
|
||
|
|
Text,
|
||
|
|
Image,
|
||
|
|
HStack,
|
||
|
|
} from "@chakra-ui/react";
|
||
|
|
|
||
|
|
import { AddIcon, DragHandleIcon } from "@chakra-ui/icons";
|
||
|
|
import DataTable from "../../../Components/DataTable/DataTable";
|
||
|
|
|
||
|
|
const SetDisplayOrder = ({data,}) => {
|
||
|
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||
|
|
|
||
|
|
const tableHeadRow = ["", "Title", "Icon", ];
|
||
|
|
|
||
|
|
console.log(data);
|
||
|
|
|
||
|
|
|
||
|
|
const [ extractedArray, setExtractedArray] = useState(data?.map((item, index) => ({
|
||
|
|
id:item?.id,
|
||
|
|
"": (
|
||
|
|
<Box w={"20px"} isTruncated={true}>
|
||
|
|
<DragHandleIcon />
|
||
|
|
</Box>
|
||
|
|
),
|
||
|
|
Title: (
|
||
|
|
<Box w={"300px"} isTruncated={true}>
|
||
|
|
<Text
|
||
|
|
justifyContent={"left"}
|
||
|
|
as={"span"}
|
||
|
|
color={"teal.900"}
|
||
|
|
fontWeight={"500"}
|
||
|
|
className="d-flex align-items-center web-text-small"
|
||
|
|
>
|
||
|
|
{item?.meritsHeader}
|
||
|
|
</Text></Box>
|
||
|
|
),
|
||
|
|
Icon: (
|
||
|
|
<HStack justify={'center'}>
|
||
|
|
<Image
|
||
|
|
src={`${import.meta.env.VITE_API_IMAGE_URL}/${item?.iconFilePath}`}
|
||
|
|
w={8}
|
||
|
|
h={8}
|
||
|
|
/></HStack>
|
||
|
|
// https://admin.tanami.betadelivery.com/public/icons/linkedin.png
|
||
|
|
),
|
||
|
|
})))
|
||
|
|
|
||
|
|
console.log(extractedArray);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
return (
|
||
|
|
<>
|
||
|
|
<Button
|
||
|
|
leftIcon={<AddIcon />}
|
||
|
|
size={"sm"}
|
||
|
|
fontSize={"xs"}
|
||
|
|
rounded={"sm"}
|
||
|
|
variant={"outline"}
|
||
|
|
colorScheme="forestGreen"
|
||
|
|
onClick={onOpen}
|
||
|
|
>
|
||
|
|
Set Display Order
|
||
|
|
</Button>
|
||
|
|
|
||
|
|
<Modal isCentered size={'xl'} isOpen={isOpen} onClose={onClose}>
|
||
|
|
<ModalOverlay />
|
||
|
|
<ModalContent >
|
||
|
|
<ModalHeader fontSize={"lg"}>Set Display Order</ModalHeader>
|
||
|
|
<ModalCloseButton />
|
||
|
|
<ModalBody>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<DataTable
|
||
|
|
emptyMessage={`We don't have any Sponers `}
|
||
|
|
tableHeadRow={tableHeadRow}
|
||
|
|
data={extractedArray}
|
||
|
|
setData={setExtractedArray}
|
||
|
|
isDraggable={true}
|
||
|
|
// isLoading={false}
|
||
|
|
// viewActionId={actionId}
|
||
|
|
// setViewActionId={setActionId}
|
||
|
|
// totalPages={10}
|
||
|
|
|
||
|
|
// setMouseEnteredId={setMouseEnteredId}
|
||
|
|
// setMouseEntered={setMouseEntered}
|
||
|
|
/>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</ModalBody>
|
||
|
|
|
||
|
|
<ModalFooter>
|
||
|
|
<Button
|
||
|
|
size={"sm"}
|
||
|
|
fontSize={"xs"}
|
||
|
|
rounded={"sm"}
|
||
|
|
variant={"outline"}
|
||
|
|
colorScheme="forestGreen"
|
||
|
|
mr={3}
|
||
|
|
onClick={onClose}
|
||
|
|
>
|
||
|
|
Reset order
|
||
|
|
</Button>
|
||
|
|
<Button
|
||
|
|
size={"sm"}
|
||
|
|
fontSize={"xs"}
|
||
|
|
rounded={"sm"}
|
||
|
|
colorScheme="forestGreen"
|
||
|
|
variant="solid"
|
||
|
|
>
|
||
|
|
Set order
|
||
|
|
</Button>
|
||
|
|
</ModalFooter>
|
||
|
|
</ModalContent>
|
||
|
|
</Modal>
|
||
|
|
</>
|
||
|
|
);
|
||
|
|
};
|
||
|
|
|
||
|
|
export default SetDisplayOrder;
|