Skip to content

Commit

Permalink
feat: auto select agent, use enum and rename variables (#1282)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmonnier9 authored Oct 17, 2024
1 parent c3d2924 commit 8248a7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
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

0 comments on commit 8248a7a

Please sign in to comment.