Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Publisher][Agency Settings] Add new biological sex and race & ethnicity data source questions #1589

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions common/components/CheckboxOptions/CheckboxOptions.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import styled from "styled-components/macro";

import { typography } from "../GlobalStyles";
import { NewInput } from "../Input";

export const CheckboxContainer = styled.div``;

Expand All @@ -41,3 +42,9 @@ export const Checkbox = styled.input`
min-height: 16px;
border: 1px solid red;
`;

export const OtherInput = styled(NewInput)`
height: 120px;
gap: unset;
margin-bottom: 16px;
`;
74 changes: 56 additions & 18 deletions common/components/CheckboxOptions/CheckboxOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,24 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =============================================================================

import React from "react";
import React, { useState } from "react";

import * as Styled from "./CheckboxOptions.styles";

export type OtherDescriptionParams = {
value: string;
isEnabled: boolean;
placeholder?: string;
onChange: (value: string) => void;
};

export type CheckboxOption = {
key: string;
label: string;
checked: boolean;
disabled?: boolean;
icon?: string | React.ReactNode;
otherDescription?: OtherDescriptionParams;
onChangeOverride?: () => void;
};

Expand All @@ -39,26 +47,56 @@ export const CheckboxOptions: React.FC<CheckboxOptionsProps> = ({
options,
onChange,
}) => {
const [otherDescriptionValue, setOtherDescriptionValue] = useState("");

return (
<Styled.CheckboxContainer>
{options.map(
({ key, label, checked, disabled, icon, onChangeOverride }) => (
<Styled.CheckboxOptionsWrapper key={key}>
<Styled.Checkbox
id={key}
type="checkbox"
checked={checked}
onChange={() =>
onChangeOverride
? onChangeOverride()
: onChange({ key, checked })
}
disabled={disabled}
/>
<Styled.CheckboxLabel>
{label} {icon}
</Styled.CheckboxLabel>
</Styled.CheckboxOptionsWrapper>
({
key,
label,
checked,
disabled,
icon,
otherDescription,
onChangeOverride,
}) => (
<React.Fragment key={key}>
<Styled.CheckboxOptionsWrapper>
<Styled.Checkbox
id={key}
type="checkbox"
checked={checked}
onChange={() =>
onChangeOverride
? onChangeOverride()
: onChange({ key, checked })
}
disabled={disabled}
/>
<Styled.CheckboxLabel>
{label} {icon}
</Styled.CheckboxLabel>
</Styled.CheckboxOptionsWrapper>
{otherDescription?.isEnabled && (
<Styled.OtherInput
id="checkbox-other-description"
name="checkbox-other-description"
type="text"
multiline
placeholder={
otherDescription.placeholder ||
"Please provide additional information..."
}
value={otherDescriptionValue || otherDescription.value}
onChange={(e) => {
setOtherDescriptionValue(e.target.value);
otherDescription.onChange(e.target.value);
}}
fullWidth
/>
)}
</React.Fragment>
)
)}
</Styled.CheckboxContainer>
Expand Down
3 changes: 3 additions & 0 deletions common/components/Modal/Modal.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const InnerWrapper = styled.div<{
centerText?: boolean;
customPadding?: string;
noBottomDiv?: boolean;
maxHeight?: number;
}>`
background-color: ${palette.solid.white};
width: 100%;
Expand All @@ -77,6 +78,8 @@ export const InnerWrapper = styled.div<{
return `& > div:last-child {display: none;}`;
}
}};
${({ maxHeight }) =>
maxHeight && `max-height: ${maxHeight}px; overflow-y: auto;`};
`;

export const Icon = styled.img`
Expand Down
3 changes: 3 additions & 0 deletions common/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ModalProps = Partial<{
jurisdictionsSettingsConfigs?: boolean;
agencySettingsAndJurisdictionsTitleConfigs?: boolean;
noBottomDiv?: boolean;
maxHeight?: number;
}>;

export function Modal({
Expand All @@ -61,6 +62,7 @@ export function Modal({
jurisdictionsSettingsConfigs,
agencySettingsAndJurisdictionsTitleConfigs,
noBottomDiv,
maxHeight,
}: ModalProps) {
const primaryButtonColor = (): ButtonColor => {
if (modalType === "alert") return "red";
Expand All @@ -84,6 +86,7 @@ export function Modal({
centerText={centerText}
customPadding={customPadding}
noBottomDiv={noBottomDiv}
maxHeight={maxHeight}
>
{modalType === "success" && <Styled.Icon src={successIcon} alt="" />}
{modalType === "warning" && <Styled.Icon src={warningIcon} alt="" />}
Expand Down
5 changes: 3 additions & 2 deletions common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ export type AgencySettingType =
| "PURPOSE_AND_FUNCTIONS"
| "HOMEPAGE_URL"
| "ZIPCODE"
| "DATA_SHARING_TYPE";
| "DATA_SHARING_TYPE"
| "BIOLOGICAL_SEX_RACE_ETHNICITY_DATA_SOURCE";

export interface AgencySetting {
setting_type: AgencySettingType;
source_id: number;
value: string | string[];
value: string | string[] | object;
}

export interface PublicUserAgency {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,14 @@ export const EditModeButtonsContainer = styled.div<{ noMargin?: boolean }>`

// Basic Info

export const BasicInfoBlockTitle = styled(AgencySettingsBlockTitle)`
export const BasicInfoBlockTitle = styled(AgencySettingsBlockTitle)<{
withPadding?: boolean;
}>`
${typography.body};
justify-content: space-between;
align-items: center;

${({ withPadding }) => withPadding && `padding: 24px 0 4px;`}
`;

export const CheckboxSpacingWrapper = styled.div`
Expand Down Expand Up @@ -440,6 +444,22 @@ export const SupervisionSystemRow = styled(AgencySettingsInfoRow)<{
border: none;
`;

// Data Source
export const DataSourceContainer = styled.div`
border-top: 1px solid ${palette.highlight.grey5};
border-bottom: 1px solid ${palette.highlight.grey5};
margin-left: -40px;
margin-right: -40px;
padding: 16px 40px;
`;
export const DataSourceTitle = styled.div`
font-weight: 700;
padding-bottom: 8px;
`;
export const DataSourceQuestionWrapper = styled.div`
padding-bottom: 12px;
`;

// Jurisdictions
export const JurisdictionsInputWrapper = styled.div`
position: relative;
Expand Down
5 changes: 5 additions & 0 deletions publisher/src/components/AgencySettings/AgencySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
AgencySettingsWrapper,
} from "./AgencySettings.styles";
import { AgencySettingsBasicInfo } from "./AgencySettingsBasicInfo";
import AgencySettingsDataSource from "./AgencySettingsDataSource";
// TODO(#1537) Ungate zipcode and agency data sharing fields
// import AgencySettingsDataSharingType from "./AgencySettingsDataSharingType";
import AgencySettingsDescription from "./AgencySettingsDescription";
Expand All @@ -42,6 +43,7 @@ export enum ActiveSetting {
HomepageUrl = "HOMEPAGE_URL",
Supervisions = "SUPERVISIONS",
Jurisdictions = "JURISDICTIONS",
DataSource = "BIOLOGICAL_SEX_RACE_ETHNICITY_DATA_SOURCE",
}

export type SettingProps = {
Expand Down Expand Up @@ -103,6 +105,9 @@ export const AgencySettings: React.FC = observer(() => {
settingProps={generateSettingProps(ActiveSetting.Supervisions)}
/>
)}
<AgencySettingsDataSource
settingProps={generateSettingProps(ActiveSetting.DataSource)}
/>
<AgencySettingsJurisdictions
settingProps={generateSettingProps(ActiveSetting.Jurisdictions)}
/>
Expand Down
Loading
Loading