-
Notifications
You must be signed in to change notification settings - Fork 16
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
Added redirect to chat #2998
base: develop
Are you sure you want to change the base?
Added redirect to chat #2998
Conversation
Renatavl
commented
Dec 18, 2024
•
edited
Loading
edited
- Added redirect to chat;
- Added tests to increase test coverage
c9f7f19
to
7a8aa09
Compare
7a8aa09
to
af62560
Compare
Quality Gate passedIssues Measures |
@@ -37,6 +42,8 @@ interface ProfileInfoProps { | |||
const ProfileInfo = ({ userData, myRole }: ProfileInfoProps) => { | |||
const { t } = useTranslation() | |||
const navigate = useNavigate() | |||
const { setChatInfo } = useChatContext() | |||
const getChats = useCallback(() => chatService.getChats(), []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass just chatService.getChats
to service
prop of useAxios
hook
response: listOfChats, | ||
loading: isChatsLoading, | ||
fetchData | ||
} = useAxios({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add generic type to the useAxios
hook, and you will not have that weird types assertions in finding existing chat, because right now listOfChats
has never
type
} = useAxios({ | |
} = useAxios<ChatResponse[]>({ |
setChatInfo({ | ||
author: userData, | ||
authorRole: userData.role[0] as UserRoleEnum.Student | UserRoleEnum.Tutor, | ||
chatId: existedChat?._id || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chatId: existedChat?._id || '', | |
chatId: existedChat?._id ?? '', |
}) | ||
|
||
const onSendMessageClick = () => { | ||
const existedChat = listOfChats.find((chat: ChatResponse) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add curly braces to this function, because it doesn't fit into a single line