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

Added redirect to chat #2998

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Conversation

Renatavl
Copy link
Contributor

@Renatavl Renatavl commented Dec 18, 2024

  • Added redirect to chat;
  • Added tests to increase test coverage

image

@Renatavl Renatavl added Frontend part feature Student Implementation that regard to the student labels Dec 18, 2024
@Renatavl Renatavl self-assigned this Dec 18, 2024
@Renatavl Renatavl linked an issue Dec 18, 2024 that may be closed by this pull request
@Renatavl Renatavl force-pushed the feature/1681/redirect-to-chat branch 5 times, most recently from c9f7f19 to 7a8aa09 Compare December 19, 2024 00:09
@Renatavl Renatavl force-pushed the feature/1681/redirect-to-chat branch from 7a8aa09 to af62560 Compare December 19, 2024 01:01
@@ -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(), [])
Copy link
Contributor

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({
Copy link
Contributor

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

Suggested change
} = useAxios({
} = useAxios<ChatResponse[]>({

setChatInfo({
author: userData,
authorRole: userData.role[0] as UserRoleEnum.Student | UserRoleEnum.Tutor,
chatId: existedChat?._id || '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
chatId: existedChat?._id || '',
chatId: existedChat?._id ?? '',

})

const onSendMessageClick = () => {
const existedChat = listOfChats.find((chat: ChatResponse) =>
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Frontend part Student Implementation that regard to the student
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(SP: 2) Redirect to chat at Tutor Profile
2 participants