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

fix: agency list update registration #3

Merged
merged 2 commits into from
Feb 28, 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
2 changes: 1 addition & 1 deletion cypress/e2e/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Login', () => {
cy.contains('Datenschutzerklärung');
});

it.only('displays the login for resorts', () => {
it('displays the login for resorts', () => {
cy.visit('/suchtberatung');
cy.contains('Login');
});
Expand Down
18 changes: 6 additions & 12 deletions cypress/e2e/registration/topic.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,23 +871,20 @@ describe('Registration', () => {

cy.get('.agencySelection__proposedAgency').should(
'have.length',
5
2
);
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-11'
).should('exist');
).should('not.exist');
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-13'
).should('exist');
).should('not.exist');
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-21'
).should('exist');
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-22'
).should('exist');
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-23'
).should('exist');
});
});
describe('With valid cid parameters', () => {
Expand Down Expand Up @@ -1080,23 +1077,20 @@ describe('Registration', () => {

cy.get('.agencySelection__proposedAgency').should(
'have.length',
5
2
);
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-11'
).should('exist');
).should('not.exist');
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-13'
).should('exist');
).should('not.exist');
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-21'
).should('exist');
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-22'
).should('exist');
cy.get(
'.agencySelection__proposedAgency .radioButton__input#agency-23'
).should('exist');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ export const ConsultingTypeAgencySelection = ({
agencies: possibleAgencies,
consultingTypes: possibleConsultingTypes,
topicIds: possibleTopicIds
} = useConsultantRegistrationData();
} = useConsultantRegistrationData({
consultingTypeId:
selectedConsultingTypeOption?.value &&
parseInt(selectedConsultingTypeOption.value),
topicId:
selectedTopicOption?.value && parseInt(selectedTopicOption.value)
});

useEffect(() => {
apiGetTopicsData()
Expand Down Expand Up @@ -185,7 +191,11 @@ export const ConsultingTypeAgencySelection = ({
defaultValue: selectedTopicOption
};

if (possibleAgencies.length <= 1 && possibleConsultingTypes.length <= 1) {
if (
possibleAgencies.length <= 1 &&
possibleConsultingTypes.length <= 1 &&
possibleTopicIds.length <= 1
) {
return null;
}

Expand Down Expand Up @@ -218,23 +228,24 @@ export const ConsultingTypeAgencySelection = ({
</div>
)}

{selectedConsultingTypeOption && agencyOptions.length > 1 && (
<div className="agencySelection">
{consultingTypeOptions.length <= 1 && (
<Text
text={translate(
'registration.consultingTypeAgencySelection.agency.infoText'
)}
type="standard"
{(selectedConsultingTypeOption || selectedTopicOption) &&
agencyOptions.length > 1 && (
<div className="agencySelection">
{consultingTypeOptions.length <= 1 && (
<Text
text={translate(
'registration.consultingTypeAgencySelection.agency.infoText'
)}
type="standard"
/>
)}
<AgencySelection
agencies={agencyOptions}
onChange={handleChange}
selectedAgency={agency}
/>
)}
<AgencySelection
agencies={agencyOptions}
onChange={handleChange}
selectedAgency={agency}
/>
</div>
)}
</div>
)}
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/formAccordion/FormAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const FormAccordion = ({
const { setSpecificAgency, specificAgency } = useContext(
AgencySpecificContext
);
const { consultingTypes } = useConsultantRegistrationData();
const { consultingTypes } = useConsultantRegistrationData({});

const [activeItem, setActiveItem] = useState<number>(1);

Expand Down
2 changes: 1 addition & 1 deletion src/components/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const Login = () => {
agencies: possibleAgencies,
consultingTypes: possibleConsultingTypes,
topicIds: possibleTopicIds
} = useConsultantRegistrationData();
} = useConsultantRegistrationData({});

const registerOverlay = useMemo(
(): OverlayItem => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export const useAgenciesForRegistration = ({
const {
agencies: consultantAgencies,
consultingTypes: consultantConsultingTypes
} = useConsultantRegistrationData();
} = useConsultantRegistrationData({
topicId: topic?.id,
consultingTypeId: consultingType?.id
});

const [isLoading, setIsLoading] = useState(true);
const [agencies, setAgencies] = useState<AgencyDataInterface[]>([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import {
import { useAppConfig } from '../../../hooks/useAppConfig';
import { UrlParamsContext } from '../../../globalState/provider/UrlParamsProvider';

export const useConsultantRegistrationData = () => {
interface ConsultantRegistrationDataArgs {
consultingTypeId?: number;
topicId?: number;
}

export const useConsultantRegistrationData = ({
consultingTypeId,
topicId
}: ConsultantRegistrationDataArgs) => {
const settings = useAppConfig();
const {
consultingType: preselectedConsultingType,
Expand Down Expand Up @@ -89,12 +97,21 @@ export const useConsultantRegistrationData = () => {
.filter((agency) =>
consultingTypeIds.includes(agency.consultingType)
)
// Filter agencies by selected topic
.filter(
(a) =>
slugFallback ||
!consultingTypeId ||
a.consultingType === consultingTypeId
)
// Filter agencies by preselected topic
.filter(
(a) =>
!preselectedTopic ||
a.topicIds?.includes(preselectedTopic?.id)
)
// Filter agencies by selected topic
.filter((a) => !topicId || a.topicIds?.includes(topicId))
// Filter agencies by preselected agency
.filter((a) => !preselectedAgency || preselectedAgency.id === a.id);
setAgencies(possibleAgencies);
Expand All @@ -106,6 +123,8 @@ export const useConsultantRegistrationData = () => {
: consultingTypes
);
}, [
topicId,
consultingTypeId,
consultant,
preselectedConsultingType,
preselectedAgency,
Expand Down
7 changes: 7 additions & 0 deletions src/resources/i18n/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,13 @@
"label": "Themenfeld"
}
},
"topic": {
"headline": "Bitte wählen Sie ein Themenfeld",
"infoText": "Ihr_e Berater_in ist in mehreren Themenfeldern tätig. Bitte wählen Sie Ihr gewünschtes Themenfeld.",
"select": {
"label": "Themenfeld"
}
},
"agency": {
"headline": "Bitte wählen Sie eine Beratungsstelle",
"infoText": "Ihr_e Berater_in ist in mehreren Beratungsstellen tätig. Bitte wählen Sie Ihre gewünschte Beratungsstelle."
Expand Down
4 changes: 4 additions & 0 deletions src/resources/i18n/de@informal/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,10 @@
"headline": "Bitte wähle ein Themenfeld",
"infoText": "Dein_e Berater_in ist in mehreren Themenfeldern tätig. Bitte wähle Dein gewünschtes Themenfeld."
},
"topic": {
"headline": "Bitte wähle ein Themenfeld",
"infoText": "Dein_e Berater_in ist in mehreren Themenfeldern tätig. Bitte wähle Dein gewünschtes Themenfeld."
},
"agency": {
"headline": "Bitte wähle eine Beratungsstelle",
"infoText": "Dein_e Berater_in ist in mehreren Beratungsstellen tätig. Bitte wähle Deine gewünschte Beratungsstelle."
Expand Down
5 changes: 5 additions & 0 deletions src/resources/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,11 @@
"infoText": "Your consultant is active in several subject areas. Please select your desired subject area.",
"select.label": "Topic"
},
"topic": {
"headline": "Please select a topic",
"infoText": "Your consultant is active in several subject areas. Please select your desired subject area.",
"select.label": "Topic"
},
"agency": {
"headline": "Please select a counseling center",
"infoText": "Your consultant is active in several counseling centers. Please select your desired counseling center."
Expand Down
Loading