Skip to content

Commit

Permalink
fix: sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
web-mi committed Feb 4, 2024
1 parent 2f202eb commit 0e0ebe4
Show file tree
Hide file tree
Showing 29 changed files with 496 additions and 379 deletions.
18 changes: 13 additions & 5 deletions src/components/agencySelection/AgencySelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DEFAULT_POSTCODE } from '../registration/prefillPostcode';
import { RadioButton } from '../radioButton/RadioButton';
import { Loading } from '../app/Loading';
import { Text, LABEL_TYPES } from '../text/Text';
import { AgencyInfo } from './AgencyInfo';
import { InfoTooltip } from '../infoTooltip/InfoTooltip';
import { PreselectedAgency } from '../../containers/registration/components/PreSelectedAgency/PreselectedAgency';
import { Headline } from '../headline/Headline';
import { parsePlaceholderString } from '../../utils/parsePlaceholderString';
Expand Down Expand Up @@ -390,16 +390,24 @@ export const AgencySelection = (props: AgencySelectionProps) => {
value={agency.id.toString()}
checked={index === 0}
inputId={agency.id.toString()}
label={translate(
>
{translate(
[
`agency.${agency.id}.name`,
agency.name
],
{ ns: 'agencies' }
)}
/>
<AgencyInfo
agency={agency}
</RadioButton>
<InfoTooltip
translation={{
ns: 'agencies',
prefix: 'agency'
}}
info={agency}
showTeamAgencyInfo={
agency.teamAgency
}
isProfileView={
props.isProfileView
}
Expand Down
43 changes: 17 additions & 26 deletions src/components/appointment/Appointments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Text } from '../text/Text';
import { useTranslation } from 'react-i18next';
import { LegalLinksContext } from '../../globalState/provider/LegalLinksProvider';
import { ListInfo } from '../listInfo/ListInfo';
import LegalLinks from '../legalLinks/LegalLinks';

export const Appointments = () => {
const { t: translate } = useTranslation();
Expand Down Expand Up @@ -311,37 +312,27 @@ export const Appointments = () => {
</ScrollableSectionBody>
<ScrollableSectionFooter>
<div className="profile__footer">
{legalLinks.map((legalLink, index) => (
<React.Fragment
key={legalLink.getUrl({
aid: specificAgency?.id
})}
>
{index > 0 && (
<Text
type="infoSmall"
className="profile__footer__separator"
text=" | "
/>
)}
<a
key={legalLink.getUrl({
aid: specificAgency?.id
})}
href={legalLink.getUrl({
aid: specificAgency?.id
})}
target="_blank"
rel="noreferrer"
>
<LegalLinks
legalLinks={legalLinks}
params={{ aid: specificAgency?.id }}
delimiter={
<Text
type="infoSmall"
className="profile__footer__separator"
text=" | "
/>
}
>
{(label, url) => (
<a href={url} target="_blank" rel="noreferrer">
<Text
className="profile__footer__item"
type="infoSmall"
text={translate(legalLink.label)}
text={label}
/>
</a>
</React.Fragment>
))}
)}
</LegalLinks>
</div>
</ScrollableSectionFooter>
</ScrollableSection>
Expand Down
15 changes: 6 additions & 9 deletions src/components/askerInfo/AskerInfoToolsOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,12 @@ export const AskerInfoToolsOptions = (
{infoAboutToolsModal.map((tool: APIToolsInterface) => (
<Checkbox
key={tool.title}
className="textarea__checkbox"
item={{
inputId: tool.toolId,
name: tool.title,
labelId: tool.title,
label: tool.title,
description: tool.description,
checked: !!tool.sharedWithAdviceSeeker
}}
inputId={tool.toolId}
name={tool.title}
labelId={tool.title}
label={tool.title}
description={tool.description}
checked={!!tool.sharedWithAdviceSeeker}
checkboxHandle={(e) =>
updateSharedToolsModal(e.target, true)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/budibase/budibaseLogout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export const budibaseLogout = () => {
},
method: 'POST',
credentials: 'include'
})
}).catch(console.error)
);
};
99 changes: 61 additions & 38 deletions src/components/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,80 @@
import * as React from 'react';
import { ReactComponent as CheckmarkIcon } from '../../resources/img/icons/checkmark.svg';
import './checkbox.styles';
import { MouseEvent, KeyboardEvent, FC } from 'react';

export interface CheckboxItem {
inputId: string;
name: string;
labelId: string;
labelClass?: string;
label: string;
value?: string;
label?: string;
description?: string;
value?: string;
checked: boolean;
checkboxHandle: (
e:
| MouseEvent<HTMLInputElement | SVGSVGElement>
| KeyboardEvent<HTMLInputElement>
) => void;
onKeyPress?: (e: KeyboardEvent<HTMLInputElement>) => void;
}

export const Checkbox = (props) => {
const checkboxItem = props.item;

return (
<div className="checkbox__wrapper formWrapper__inputRow">
<input
onClick={(e) => props.checkboxHandle(e)}
onKeyPress={(e) => props.onKeyPress(e)}
id={checkboxItem.inputId}
className="checkbox__input"
type="checkbox"
name={checkboxItem.name}
value={checkboxItem.value}
defaultChecked={checkboxItem.checked}
/>
{checkboxItem.checked && (
export const Checkbox: FC<CheckboxItem> = ({
checkboxHandle,
onKeyPress,
checked,
inputId,
name,
value,
label,
labelId,
labelClass,
description,
children
}) => (
<div className="checkbox__wrapper formWrapper__inputRow">
<div className="checkbox__icon__container">
{checked && (
<CheckmarkIcon
className="checkbox__icon"
onClick={(e) => {
const checkboxElement = document.getElementById(
checkboxItem.inputId
) as HTMLInputElement;
checkboxElement.checked = !checkboxElement.checked;
props.checkboxHandle(e);
}}
onClick={checkboxHandle}
/>
)}
<label
id={checkboxItem.labelId}
className={`checkbox__label ${checkboxItem.labelClass}`}
htmlFor={checkboxItem.inputId}
dangerouslySetInnerHTML={{
__html: `${checkboxItem.label}${
checkboxItem.description
? `<br>${checkboxItem.description}`
: ''
}`
}}
<input
onClick={checkboxHandle}
onKeyPress={onKeyPress || checkboxHandle}
id={inputId}
className="checkbox__input"
type="checkbox"
name={name}
value={value}
defaultChecked={checked}
/>
</div>
);
};
<label
id={labelId}
className={`checkbox__label ${labelClass}`}
htmlFor={inputId}
dangerouslySetInnerHTML={
label && {
__html: `${label}${
description ? `<br />${description}` : ''
}`
}
}
>
{!label ? (
<>
{children}
{description && (
<>
<br />
{description}
</>
)}
</>
) : null}
</label>
</div>
);
19 changes: 14 additions & 5 deletions src/components/checkbox/checkbox.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@ $checkbox-size: 24px;
line-height: 24px;
}

&__icon__container {
display: inline-block;
position: relative;
background-color: $white;
width: $checkbox-size;
height: $checkbox-size;
border-radius: $checkbox-border-radius;
margin-top: -2px; // Center align to label
}

&__input {
position: relative;
top: -2px; // Center align to label
width: $checkbox-size;
height: $checkbox-size;
flex-shrink: 0;
appearance: none;
border: 1px solid $form-primary;
cursor: pointer;
border-radius: $checkbox-border-radius;
background-color: $white;
background-color: transparent;
z-index: 2;

&:hover {
border: 1px solid $form-secondary;
Expand All @@ -50,8 +60,7 @@ $checkbox-size: 24px;
left: 0;
padding: 2px;
position: absolute;
top: -1px;
left: 0;
z-index: 0;
top: 1px;
z-index: 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AgencyDataInterface } from '../../globalState/interfaces';
import './consultingTypeAgencySelection.styles';
import '../profile/profile.styles';
import { RadioButton } from '../radioButton/RadioButton';
import { AgencyInfo } from '../agencySelection/AgencyInfo';
import { InfoTooltip } from '../infoTooltip/InfoTooltip';
import {
VALIDITY_INVALID,
VALIDITY_VALID
Expand Down Expand Up @@ -185,13 +185,21 @@ const AgencySelection = ({
agency.id === selectedAgency.id
}
inputId={agency.id.toString()}
label={translate(
onKeyDown={onKeyDown}
>
{translate(
[`agency.${agency.id}.name`, agency.name],
{ ns: 'agencies' }
)}
onKeyDown={onKeyDown}
</RadioButton>
<InfoTooltip
translation={{
ns: 'agencies',
prefix: 'agency'
}}
info={agency}
showTeamAgencyInfo={agency.teamAgency}
/>
<AgencyInfo agency={agency} />
</div>
<AgencyLanguages agencyId={agency.id} />
</div>
Expand Down
Loading

0 comments on commit 0e0ebe4

Please sign in to comment.