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

feat: auto select agent, use enum and rename variables #1282

Merged
merged 1 commit into from
Oct 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import { MultiChoice } from '#components-ui/multi-choice';
import Question, { EQuestionType } from '#components/faq-parcours/question';
import { FAQTargets, allFaqArticlesByTarget } from '#models/article/faq';
import {
EFAQTargets,
FAQTargets,
allFaqArticlesByTarget,
} from '#models/article/faq';
import { AppScope, hasRights } from '#models/user/rights';
import { ISession } from '#models/user/session';
import { useRef, useState } from 'react';

Expand All @@ -17,7 +22,13 @@ export default function ParcoursQuestions({ question, session }: IProps) {

const scrollRef = useRef<HTMLSpanElement | null>(null);

const [userType, setUserType] = useState(initialQuestionType ? 'all' : '');
const [userType, setUserType] = useState(
hasRights(session, AppScope.isAgent)
? EFAQTargets.AGENT
: initialQuestionType
? 'all'
: ''
);
const [questionType, setQuestionType] = useState<EQuestionType>(
initialQuestionType || EQuestionType.NONE
);
Expand Down
12 changes: 6 additions & 6 deletions models/user/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export function getIAgentScope(session: ISession | null) {
}

export function getAgentFullName(session: ISession | null) {
const fullname = session?.user?.fullName;
const firstname = session?.user?.firstName;
const lastname = session?.user?.familyName;
const fullName = session?.user?.fullName;
const firstName = session?.user?.firstName;
const familyName = session?.user?.familyName;

if (fullname) {
return fullname.trim();
if (fullName) {
return fullName.trim();
}

return [firstname, lastname].filter(Boolean).join(' ').trim();
return [firstName, familyName].filter(Boolean).join(' ').trim();
}

export function getAgentDisplayName(session: ISession | null) {
Expand Down
Loading