-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Adrian Galvan <[email protected]>
- Loading branch information
1 parent
b9a1087
commit 5dab33f
Showing
7 changed files
with
229 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
clients/admin-ui/src/features/configure-consent/ConsentManagementModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/* eslint-disable react/no-array-index-key */ | ||
import { | ||
Accordion, | ||
AccordionButton, | ||
AccordionIcon, | ||
AccordionItem, | ||
AccordionPanel, | ||
Box, | ||
Button, | ||
Flex, | ||
Modal, | ||
ModalBody, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalOverlay, | ||
Spacer, | ||
Spinner, | ||
useDisclosure, | ||
} from "@fidesui/react"; | ||
import { FieldArray, Form, Formik } from "formik"; | ||
|
||
import { | ||
CustomCreatableSelect, | ||
CustomTextInput, | ||
Label, | ||
} from "~/features/common/form/inputs"; | ||
import { useGetSystemPurposeSummaryQuery } from "~/features/plus/plus.slice"; | ||
import { SystemPurposeSummary } from "~/types/api"; | ||
|
||
export const useConsentManagementModal = () => { | ||
const { isOpen, onOpen, onClose } = useDisclosure(); | ||
|
||
return { isOpen, onOpen, onClose }; | ||
}; | ||
|
||
type Props = { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
fidesKey: string; | ||
}; | ||
|
||
type FormValues = SystemPurposeSummary; | ||
|
||
export const ConsentManagementModal = ({ | ||
isOpen, | ||
onClose, | ||
fidesKey, | ||
}: Props) => { | ||
const { data: systemPurposeSummary, isLoading } = | ||
useGetSystemPurposeSummaryQuery(fidesKey); | ||
|
||
return ( | ||
<Modal | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
size="xxl" | ||
returnFocusOnClose={false} | ||
isCentered | ||
> | ||
<ModalOverlay /> | ||
<ModalContent maxWidth="800px"> | ||
<ModalHeader>Vendor</ModalHeader> | ||
<ModalBody> | ||
{isLoading ? ( | ||
<Flex | ||
width="100%" | ||
height="324px" | ||
alignItems="center" | ||
justifyContent="center" | ||
> | ||
<Spinner /> | ||
</Flex> | ||
) : ( | ||
<Formik<FormValues> | ||
initialValues={ | ||
systemPurposeSummary as unknown as SystemPurposeSummary | ||
} | ||
enableReinitialize | ||
onSubmit={() => {}} | ||
> | ||
{({ values }) => ( | ||
<Form> | ||
<Box mb={6}> | ||
<CustomTextInput | ||
label="Vendor Name" | ||
variant="stacked" | ||
name="name" | ||
disabled | ||
/> | ||
</Box> | ||
{Object.entries(values?.purposes || {}).length > 0 ? ( | ||
<Label> Purposes </Label> | ||
) : null} | ||
<FieldArray | ||
name="purposes" | ||
render={() => ( | ||
<Accordion allowMultiple> | ||
{Object.entries(values.purposes).map( | ||
([purposeName], index: number) => ( | ||
<AccordionItem key={index}> | ||
{({ isExpanded }) => ( | ||
<> | ||
<AccordionButton | ||
backgroundColor={ | ||
isExpanded ? "gray.50" : "unset" | ||
} | ||
> | ||
<Box flex="1" textAlign="left"> | ||
{purposeName} | ||
</Box> | ||
<AccordionIcon /> | ||
</AccordionButton> | ||
<AccordionPanel backgroundColor="gray.50"> | ||
<Box my={4}> | ||
<CustomCreatableSelect | ||
label="Data Uses" | ||
isMulti | ||
disableMenu | ||
isDisabled | ||
options={[]} | ||
variant="stacked" | ||
name={`purposes['${purposeName}'].data_uses`} | ||
/> | ||
</Box> | ||
<CustomCreatableSelect | ||
label="Legal Basis" | ||
isMulti | ||
disableMenu | ||
isDisabled | ||
options={[]} | ||
variant="stacked" | ||
name={`purposes['${purposeName}'].legal_bases`} | ||
/> | ||
</AccordionPanel> | ||
</> | ||
)} | ||
</AccordionItem> | ||
) | ||
)} | ||
</Accordion> | ||
)} | ||
/> | ||
<Box my={4}> | ||
<CustomCreatableSelect | ||
label="Features" | ||
isMulti | ||
options={[]} | ||
disableMenu | ||
isDisabled | ||
variant="stacked" | ||
name="features" | ||
/> | ||
</Box> | ||
<CustomCreatableSelect | ||
label="Data Categories" | ||
isMulti | ||
options={[]} | ||
disableMenu | ||
isDisabled | ||
variant="stacked" | ||
name="data_categories" | ||
/> | ||
</Form> | ||
)} | ||
</Formik> | ||
)} | ||
</ModalBody> | ||
|
||
<ModalFooter> | ||
<Button variant="outline" size="sm" onClick={onClose}> | ||
Close{" "} | ||
</Button> | ||
<Spacer /> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
clients/admin-ui/src/types/api/models/SystemPurposeSummary.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/** | ||
* A summary of privacy declaration information for a system aggregated by TCF purpose. | ||
*/ | ||
export type SystemPurposeSummary = { | ||
fides_key: string; | ||
name: string; | ||
purposes: Record<string, Record<string, Array<any>>>; | ||
features: Array<string>; | ||
data_categories: Array<string>; | ||
}; |