From 7464ceace2cdb869beb108e9d61269c59c8de3e5 Mon Sep 17 00:00:00 2001 From: Mav-Ivan <110425368+Mav-Ivan@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:16:26 +0300 Subject: [PATCH 1/3] fixed chat input field (#2620) --- .../chat/chat-text-area/ChatTextArea.styles.ts | 15 +++++++++++---- .../chat/chat-text-area/ChatTextArea.tsx | 4 +++- .../chat-dialog-window/ChatDialogWindow.tsx | 1 + src/pages/chat/Chat.styles.ts | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/containers/chat/chat-text-area/ChatTextArea.styles.ts b/src/containers/chat/chat-text-area/ChatTextArea.styles.ts index ebbebcc7b..c7b54f437 100644 --- a/src/containers/chat/chat-text-area/ChatTextArea.styles.ts +++ b/src/containers/chat/chat-text-area/ChatTextArea.styles.ts @@ -24,7 +24,7 @@ export const styles = { flex: 1, backgroundColor: 'basic.white', borderRadius: '6px', - p: { xs: '16px 10px', sm: '16px 32px' } + p: { xs: '7px 10px', sm: '7px 32px' } }, textArea: { userSelect: 'none', @@ -33,15 +33,22 @@ export const styles = { '&::-webkit-scrollbar-track, &::-webkit-scrollbar-thumb': { visibility: 'hidden' } - } + }, + position: 'relative', + bottom: '-12px' }, textAreaLabel: (value: string) => ({ shrink: false, style: { visibility: value ? VisibilityEnum.Hidden : VisibilityEnum.Visible, color: palette.primary[300], - top: '-6px' + top: '-12px' } }), - icon: { width: '32px', height: '32px', color: 'primary.800' } + icon: { width: '32px', height: '32px', color: 'primary.800' }, + emojiIcon: (dialogWindow: boolean) => ({ + p: '0px', + m: '0px', + pr: dialogWindow ? '15px' : '0px' + }) } diff --git a/src/containers/chat/chat-text-area/ChatTextArea.tsx b/src/containers/chat/chat-text-area/ChatTextArea.tsx index c8af0bf9d..0823e5dcd 100644 --- a/src/containers/chat/chat-text-area/ChatTextArea.tsx +++ b/src/containers/chat/chat-text-area/ChatTextArea.tsx @@ -34,6 +34,7 @@ interface ChatTextAreaProps extends Omit { } emojiPickerProps?: { perLine: number } adornmentPosition?: AdornmentPosition + dialogWindow?: boolean } const ChatTextArea: FC = ({ @@ -45,6 +46,7 @@ const ChatTextArea: FC = ({ sx = {}, emojiPickerProps, adornmentPosition = AdornmentPosition.End, + dialogWindow = false, ...props }) => { const { isMobile } = useBreakpoints() @@ -80,7 +82,7 @@ const ChatTextArea: FC = ({ const onClosePicker = () => setIsEmojiPickerOpen(false) const adornment = ( - + ) diff --git a/src/containers/offer-page/chat-dialog-window/ChatDialogWindow.tsx b/src/containers/offer-page/chat-dialog-window/ChatDialogWindow.tsx index 1de1066cb..b6dd38335 100644 --- a/src/containers/offer-page/chat-dialog-window/ChatDialogWindow.tsx +++ b/src/containers/offer-page/chat-dialog-window/ChatDialogWindow.tsx @@ -255,6 +255,7 @@ const ChatDialogWindow: FC = ({ chatInfo }) => { ) : ( Date: Tue, 22 Oct 2024 17:59:04 +0300 Subject: [PATCH 2/3] Fixed updating offer count when creating new offer in CompleteProfileBlock (#2627) * fixed updating offer data * fixed sonar issues * fixed comments & lint warnings * fix test * refactored sending re-request with useEffect --- .../complete-profile/CompleteProfileBlock.tsx | 23 +++++++++++++++++-- src/components/profile-item/ProfileItem.tsx | 17 ++++---------- .../offer-page/create-offer/CreateOffer.tsx | 13 ++++++++--- .../CreateOrEditOffer.tsx | 9 +++++--- .../CoursesFiltersDrawer.spec.jsx | 4 ++++ 5 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/components/complete-profile/CompleteProfileBlock.tsx b/src/components/complete-profile/CompleteProfileBlock.tsx index e7a0c4247..02d3e2b11 100644 --- a/src/components/complete-profile/CompleteProfileBlock.tsx +++ b/src/components/complete-profile/CompleteProfileBlock.tsx @@ -24,6 +24,9 @@ import { styles } from '~/components/complete-profile/CompleteProfileBlock.style import useAxios from '~/hooks/use-axios' import { OfferService } from '~/services/offer-service' import { defaultResponse } from '~/pages/my-offers/MyOffers.constants' +import { useDrawer } from '~/hooks/use-drawer' +import AppDrawer from '~/components/app-drawer/AppDrawer' +import CreateOffer from '~/containers/offer-page/create-offer/CreateOffer' interface CompleteProfileBlockProps { profileItems: ProfileItemType[] @@ -42,6 +45,9 @@ const CompleteProfileBlock: FC = ({ const homePage = useMatch(guestRoutes[userRole as UserRole].path) const [isOpen, setIsOpen] = useState(false) + const { openDrawer, closeDrawer, isOpen: isDrawerOpen } = useDrawer() + const [isOfferCreated, setIsOfferCreated] = useState(false) + useEffect(() => { if (openAccordion) { setIsOpen(true) @@ -56,11 +62,17 @@ const CompleteProfileBlock: FC = ({ [userId] ) - const { response } = useAxios({ + const { response, fetchData } = useAxios({ service: getMyOffers, defaultResponse }) + useEffect(() => { + if (isOfferCreated) { + void fetchData() + } + }, [isOfferCreated, fetchData]) + const checkIfHasNonEmptyFields = ( obj: Record ): boolean => { @@ -99,13 +111,14 @@ const CompleteProfileBlock: FC = ({ () => profileItems.map((item) => ( )), - [profileItems, checkProfileData, userRole] + [profileItems, checkProfileData, userRole, openDrawer] ) const handleToggleMenu = () => { @@ -151,6 +164,12 @@ const CompleteProfileBlock: FC = ({ {profileList} + + + ) diff --git a/src/components/profile-item/ProfileItem.tsx b/src/components/profile-item/ProfileItem.tsx index fefb2e32e..96b74987a 100644 --- a/src/components/profile-item/ProfileItem.tsx +++ b/src/components/profile-item/ProfileItem.tsx @@ -8,29 +8,25 @@ import { styles } from '~/components/profile-item/ProfileItem.styles' import useBreakpoints from '~/hooks/use-breakpoints' import { ProfileItemType } from '~/components/profile-item/complete-profile.constants' import { UserRoleEnum } from '~/types' -import CreateOffer from '~/containers/offer-page/create-offer/CreateOffer' -import { useDrawer } from '~/hooks/use-drawer' -import AppDrawer from '~/components/app-drawer/AppDrawer' interface ProfileItemProps { item: ProfileItemType isFilled?: boolean userRole: UserRoleEnum | '' + handleOpenDrawer?: () => void } const ProfileItem = ({ item, userRole, - isFilled = false + isFilled = false, + handleOpenDrawer }: ProfileItemProps) => { const { t } = useTranslation() const { isMobile } = useBreakpoints() const { id, icon } = item const navigate = useNavigate() - const { openDrawer, closeDrawer, isOpen } = useDrawer() - const handleOpenDrawer = () => openDrawer() - const isClickable = !isFilled && item.id !== 'schedule' const isOffer = item.id === 'offer' @@ -39,7 +35,7 @@ const ProfileItem = ({ navigate(`${item.path}#${item.id}`) } if (isOffer) { - handleOpenDrawer() + handleOpenDrawer!() } } @@ -64,11 +60,6 @@ const ProfileItem = ({ - {isOffer && ( - - - - )} {isFilled && ( void + updateOffer?: Dispatch> } -const CreateOffer: FC = ({ closeDrawer }) => { +const CreateOffer: FC = ({ closeDrawer, updateOffer }) => { const postOffer = useCallback( (data: CreateOrUpdateOfferData) => OfferService.createOffer({ ...data, FAQ: findFullObjects(data.FAQ) }), [] ) - return + return ( + + ) } export default CreateOffer diff --git a/src/containers/offer-page/create-or-edit-offer/CreateOrEditOffer.tsx b/src/containers/offer-page/create-or-edit-offer/CreateOrEditOffer.tsx index 345648da3..5dde4ca0f 100644 --- a/src/containers/offer-page/create-or-edit-offer/CreateOrEditOffer.tsx +++ b/src/containers/offer-page/create-or-edit-offer/CreateOrEditOffer.tsx @@ -1,4 +1,4 @@ -import { FC, useEffect } from 'react' +import { FC, useEffect, Dispatch, SetStateAction } from 'react' import { useTranslation } from 'react-i18next' import { useNavigate, useLocation } from 'react-router-dom' import LeakAddSharpIcon from '@mui/icons-material/LeakAddSharp' @@ -38,15 +38,17 @@ import { openAlert } from '~/redux/features/snackbarSlice' import { getErrorKey } from '~/utils/get-error-key' interface CreateOrUpdateOfferProps { - existingOffer: Offer | null + existingOffer?: Offer | null closeDrawer: () => void service: ServiceFunction + updateOffer?: Dispatch> } const CreateOrEditOffer: FC = ({ existingOffer = null, closeDrawer, - service + service, + updateOffer }) => { const { userRole } = useAppSelector((state) => state.appMain) const { setNeedConfirmation } = useConfirm() @@ -77,6 +79,7 @@ const CreateOrEditOffer: FC = ({ closeDrawer() if (hash == '#offer') { navigate(`${authRoutes.myProfile.path}#complete`) + updateOffer!(true) } else { navigate( createUrlPath( diff --git a/tests/unit/containers/my-courses/courses-filters-drawer/CoursesFiltersDrawer.spec.jsx b/tests/unit/containers/my-courses/courses-filters-drawer/CoursesFiltersDrawer.spec.jsx index ebe39ce2f..6d08be10c 100644 --- a/tests/unit/containers/my-courses/courses-filters-drawer/CoursesFiltersDrawer.spec.jsx +++ b/tests/unit/containers/my-courses/courses-filters-drawer/CoursesFiltersDrawer.spec.jsx @@ -54,6 +54,10 @@ const setup = async (filters) => { }) } +beforeEach(() => { + vi.clearAllMocks() +}) + describe('CoursesFiltersDrawer', () => { describe('with default filters', () => { beforeEach(async () => { From 9de22ee8db9ade8d153aeed2391a5f992b9b0cd7 Mon Sep 17 00:00:00 2001 From: Renatavl <86105228+Renatavl@users.noreply.github.com> Date: Tue, 22 Oct 2024 23:42:24 +0300 Subject: [PATCH 3/3] Button hot fix (#2617) --- src/components/offer-banner/OfferBanner.styles.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/offer-banner/OfferBanner.styles.ts b/src/components/offer-banner/OfferBanner.styles.ts index 1ee1d373d..37cf17935 100644 --- a/src/components/offer-banner/OfferBanner.styles.ts +++ b/src/components/offer-banner/OfferBanner.styles.ts @@ -37,7 +37,6 @@ export const styles = { gap: '16px' }, button: { - whiteSpace: 'nowrap', p: '15px 30px', width: 'auto', lineHeight: '19px'