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

Fix sonar issues in pages, containers, components folders #2968

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/components/accordion-with-image/AccordionWithImage.tsx
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ const AccordionWithImage: FC<AccordionWithImageProps> = ({ items }) => {
<Box className='section' data-testid='accordion' sx={styles.feature}>
<Box
component='img'
src={items[expandedItem || 0].image}
src={items[expandedItem ?? 0].image}
sx={styles.image}
/>
<Accordions
2 changes: 1 addition & 1 deletion src/components/async-autocomlete/AsyncAutocomplete.tsx
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ const AsyncAutocomplete = <
() =>
response.find(
(option) => (valueField ? option[valueField] : option) === value
) || null,
) ?? null,
[response, value, valueField]
)

15 changes: 10 additions & 5 deletions src/components/message/Message.styles.ts
Original file line number Diff line number Diff line change
@@ -24,11 +24,16 @@ export const styles = {
typography: TypographyVariantEnum.Body1,
p: '8px 16px'
}),
findMessageCard: (isMyMessage: boolean, isFiltered: boolean) => ({
backgroundColor: isFiltered
? `basic.${isMyMessage ? 'turquoiseDark' : 'turquoiseChat'}`
: `primary.${isMyMessage ? 500 : 100}`
}),
findMessageCard: (isMyMessage: boolean, isFiltered: boolean) => {
const basicShade = isMyMessage ? 'turquoiseDark' : 'turquoiseChat'
const primaryShade = isMyMessage ? 500 : 100

const backgroundColor = isFiltered
? `basic.${basicShade}`
: `primary.${primaryShade}`

return { backgroundColor }
},
date: (isMyMessage: boolean) => ({
typography: TypographyVariantEnum.Caption,
color: `primary.${isMyMessage ? 100 : 500}`,
2 changes: 1 addition & 1 deletion src/containers/chat/chat-item/ChatItem.tsx
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ const ChatItem: FC<ItemOfChatProps> = ({

const handleSelectedChat = () => {
setSelectedChat(chat)
closeDrawer && closeDrawer()
closeDrawer?.()
}

const formattedTime =
Original file line number Diff line number Diff line change
@@ -60,12 +60,14 @@ const OfferFilterList: FC<OfferFilterListProps> = ({
const handleFilterChange = (key: keyof FindOffersFilters) => () =>
updateFilterByKey(key)

const getOptionLabelForLanguage = (option: LanguageFilter | null): string => {
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
const getOptionLabelForLanguage = (option: LanguageFilter | null): string => {
const getOptionLabelForLanguage = (option: LanguageFilter | null) => {

Is a return type here necessary?

return option?.trim() ? option : t('common.languages.allLanguages')
}

const languagesFilter = (
<Box>
<AppAutoComplete
getOptionLabel={(option: LanguageFilter) =>
option || t('common.languages.allLanguages')
}
getOptionLabel={getOptionLabelForLanguage}
onChange={handleLanguagesChange}
options={languageValues}
value={filters.language}
Original file line number Diff line number Diff line change
@@ -119,14 +119,12 @@ const MyCooperationsDetails = () => {
updateInfo: updateInfo
})

const languages =
offer.languages &&
offer.languages.map((item: string) => (
<Box key={item} sx={style.languageItem}>
<DoneIcon color='success' />
<Typography>{item}</Typography>
</Box>
))
const languages = offer.languages?.map((item: string) => (
<Box key={item} sx={style.languageItem}>
sandrvvu marked this conversation as resolved.
Show resolved Hide resolved
<DoneIcon color='success' />
<Typography>{item}</Typography>
</Box>
))

const avatarSrc =
displayedUser.photo &&
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ export const validations = (disallowedValues: string[]) => ({
name: (value: string) => {
const trimmedValue = value.trim()
return (
emptyField({ value, helperText: textField(2, 35)(trimmedValue) }) ||
emptyField({ value, helperText: textField(2, 35)(trimmedValue) }) ??
valueNotIn(trimmedValue, disallowedValues)
)
}
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import { emptyField, textField } from '~/utils/validations/common'
export const validation = (disallowedValues: string[]) => (value: string) => {
const trimmedValue = value.trim()
return Boolean(
emptyField({ value, helperText: textField(2, 35)(trimmedValue) }) ||
emptyField({ value, helperText: textField(2, 35)(trimmedValue) }) ??
disallowedValues.includes(trimmedValue)
)
}
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ const LessonsContainer = () => {
)

const deleteLesson = useCallback(
(id?: string) => ResourceService.deleteLesson(id || ''),
(id?: string) => ResourceService.deleteLesson(id ?? ''),
[]
)

2 changes: 1 addition & 1 deletion src/containers/quiz/question-answer/Answer.tsx
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ const Answer: FC<AnswerProps> = ({
_,
checked
) => {
onCheckboxChange && onCheckboxChange(checked)
onCheckboxChange?.(checked)
}

const iconStyles = styles.icon(answerStatus)
Original file line number Diff line number Diff line change
@@ -5,21 +5,25 @@ import howItWorksStudentFourth from '~/assets/img/guest-home-page/howItWorksStud

export const howItWorksCards = [
{
id: 1,
image: howItWorksStudentSecond,
title: 'studentHomePage.howItWorks.selectATutor.title',
description: 'studentHomePage.howItWorks.selectATutor.description'
},
{
id: 2,
image: howItWorksStudentThird,
title: 'studentHomePage.howItWorks.sendRequest.title',
description: 'studentHomePage.howItWorks.sendRequest.description'
},
{
id: 3,
image: howItWorksStudentFourth,
title: 'studentHomePage.howItWorks.startLearning.title',
description: 'studentHomePage.howItWorks.startLearning.description'
},
{
id: 4,
image: howItWorksStudentFirst,
title: 'studentHomePage.howItWorks.writeFeedback.title',
description: 'studentHomePage.howItWorks.writeFeedback.description'
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@ const StudentHowItWorks = () => {

const { path } = authRoutes.findOffers

const cards = howItWorksCards.map((item, index) => {
const cards = howItWorksCards.map((item) => {
return (
<Box key={index} sx={styles.cardWrapper}>
<Box key={item.id} sx={styles.cardWrapper}>
<Box
alt={item.title}
component='img'
4 changes: 2 additions & 2 deletions src/pages/cookie-policy/CookiePolicy.jsx
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ import { styles } from './CookiePolicy.styles'
const CookiePolicy = () => {
const { t } = useTranslation()

const cookieItems = cookieItemsData.map((item, index) => {
const cookieItems = cookieItemsData.map((item) => {
return (
<Box key={index} sx={styles.wrapper}>
<Box key={item.id} sx={styles.wrapper}>
<Typography sx={styles.title}>{t(item.title)}</Typography>

<Typography sx={item.subtitle && styles.subtitle}>
8 changes: 8 additions & 0 deletions src/pages/cookie-policy/cookie-policy.constants.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
export const cookieItemsData = [
{
id: 1,
title: 'cookiePolicyPage.whatAreCookies.title',
description: 'cookiePolicyPage.whatAreCookies.description'
},
{
id: 2,
title: 'cookiePolicyPage.howWeUseCookies.title',
description: 'cookiePolicyPage.howWeUseCookies.description'
},
{
id: 3,
title: 'cookiePolicyPage.disablingCookies.title',
description: 'cookiePolicyPage.disablingCookies.description'
},
{
id: 4,
title: 'cookiePolicyPage.theCookiesWeSet.title',
subtitle: 'cookiePolicyPage.theCookiesWeSet.account.title',
description: 'cookiePolicyPage.theCookiesWeSet.account.description'
},
{
id: 5,
subtitle: 'cookiePolicyPage.theCookiesWeSet.login.title',
description: 'cookiePolicyPage.theCookiesWeSet.login.description'
},
{
id: 6,
subtitle: 'cookiePolicyPage.theCookiesWeSet.site.title',
description: 'cookiePolicyPage.theCookiesWeSet.site.description'
},
{
id: 7,
title: 'cookiePolicyPage.thirdPartyCookies.title',
subtitle: 'cookiePolicyPage.thirdPartyCookies.subtitle',
description: 'cookiePolicyPage.thirdPartyCookies.description'
},
{
id: 8,
title: 'cookiePolicyPage.moreInformation.title',
subtitle: 'cookiePolicyPage.moreInformation.subtitle'
}
38 changes: 24 additions & 14 deletions src/pages/find-offers/FindOffers.tsx
Original file line number Diff line number Diff line change
@@ -144,6 +144,29 @@ const FindOffers = () => {
})
}

const offersContent = useMemo(() => {
if (offersLoading) {
return <Loader pageLoad />
}

if (!items.length) {
return (
<NotFoundResults
data
description={t('findOffers.notFound.description')}
/>
)
}

return (
<OfferContainer
offerCards={items}
updateOffersInfo={updateInfo}
viewMode={cardsView}
/>
)
}, [offersLoading, items, updateInfo, cardsView, t])

return (
<PageWrapper>
<OfferRequestBlock />
@@ -192,20 +215,7 @@ const FindOffers = () => {
price={price}
/>
</AppDrawer>
{offersLoading ? (
<Loader pageLoad />
) : !items.length && !offersLoading ? (
<NotFoundResults
data
description={t('findOffers.notFound.description')}
/>
) : (
<OfferContainer
offerCards={items}
updateOffersInfo={updateInfo}
viewMode={cardsView}
/>
)}
{offersContent}
</Box>
<AppPagination
onChange={handlePageChange}