Skip to content

Commit

Permalink
Fixed bug with likes/bookmarks and locals
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslavUsenko committed Apr 18, 2024
1 parent e2a0b99 commit a0c4f50
Show file tree
Hide file tree
Showing 14 changed files with 595 additions and 590 deletions.
13 changes: 8 additions & 5 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"report": "Report",
"suggestion": "Suggestion",
"question": "Question"
}
},
"deleteAllButton": "Delete All selected tickets"
},
"dialog": {
"deleteFile": {
Expand Down Expand Up @@ -74,7 +75,7 @@
"confirm": {
"header": "Confirm",
"description": "Go to the provided email address and use the link to restore access to your account.",
"close": "Close"
"closed": "Closed"
}
},
"signUp": {
Expand Down Expand Up @@ -189,6 +190,7 @@
"author": "Author",
"faculty": "Faculty",
"dateOfCreation": "Date of creation",
"acceptChanges": "Accept changes",
"admin": {
"selectAssignee": "Select assignee"
},
Expand All @@ -203,7 +205,8 @@
"send": "send",
"edit": "edit",
"reply": "reply",
"delete": "delete"
"delete": "delete",
"messagePlaceholder": "message"
},
"dialog": {
"title": "Delete ticket",
Expand Down Expand Up @@ -242,15 +245,15 @@
"open": "Open",
"waiting": "Waiting",
"rejected": "Rejected",
"close": "Close"
"closed": "Closed"
},
"ticketStatus": {
"new": "New",
"accepted": "Accepted",
"open": "Open",
"waiting": "Waiting",
"rejected": "Rejected",
"close": "Close"
"closed": "Closed"
},
"statistic": {
"heading": "Statistic",
Expand Down
13 changes: 8 additions & 5 deletions public/locales/ua/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"report": "Скарга",
"suggestion": "Пропозиція",
"question": "Питання"
}
},
"deleteAllButton": "Видалити всі обрані звернення"
},
"dialog": {
"deleteFile": {
Expand Down Expand Up @@ -74,7 +75,7 @@
"confirm": {
"header": "Підтвердження",
"description": "Перейдіть за вказаною електронною адресою та скористайтеся посиланням, щоб відновити доступ до свого облікового запису.",
"close": "Закрити"
"closed": "Закрити"
}
},
"signUp": {
Expand Down Expand Up @@ -189,6 +190,7 @@
"author": "Автор",
"faculty": "Факультет",
"dateOfCreation": "Дата створення",
"acceptChanges": "Прийняти зміни",
"admin": {
"selectAssignee": "Оберіть відповідального"
},
Expand All @@ -203,7 +205,8 @@
"send": "відправити",
"edit": "редагувати",
"reply": "переслати",
"delete": "видалити"
"delete": "видалити",
"messagePlaceholder": "повідомлення"
},
"dialog": {
"title": "Видалити звернення",
Expand Down Expand Up @@ -242,15 +245,15 @@
"open": "Відкриті",
"waiting": "Очікуються",
"rejected": "Відхилені",
"close": "Вирішені"
"closed": "Вирішені"
},
"ticketStatus": {
"new": "Новий",
"accepted": "Прийнятий",
"open": "Відкритий",
"waiting": "Очікується",
"rejected": "Відхилений",
"close": "Вирішений"
"closed": "Вирішений"
},
"statistic": {
"heading": "Статистика",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { ChangeEvent } from "react";
import { useSearchParams } from "react-router-dom";
import { ChangeEvent } from 'react'
import { useSearchParams } from 'react-router-dom'

import useTheme from "@mui/material/styles/useTheme";
import useTheme from '@mui/material/styles/useTheme'

import IPalette from "theme/IPalette.interface";
import { statuses, urlKeys } from "constants";
import { useChangeURL } from "hooks/index";
import IPalette from 'theme/IPalette.interface'
import { statuses, urlKeys } from 'constants'
import { useChangeURL } from 'hooks/index'

export interface IStatus {
id: number;
name: string;
color: string;
checked: boolean;
onChange: (event: ChangeEvent<HTMLInputElement>, checked: boolean) => void;
id: number
name: string
color: string
checked: boolean
onChange: (event: ChangeEvent<HTMLInputElement>, checked: boolean) => void
}

export const useGetStatusesFullInfo = (
isAllStatuses: boolean
): [IStatus[], boolean[]] => {
const { palette }: IPalette = useTheme();
const { palette }: IPalette = useTheme()

const [searchParams] = useSearchParams();
const putStatusesInURL = useChangeURL();
const [searchParams] = useSearchParams()
const putStatusesInURL = useChangeURL()

const getStatusObject = (
id: number,
Expand All @@ -34,48 +34,48 @@ export const useGetStatusesFullInfo = (
color: palette.semantic[color],
checked,
onChange: handleChange(id),
});
})

const handleChange =
(index: number) =>
(event: ChangeEvent<HTMLInputElement>): void => {
const updatedChecked = [...checked];
updatedChecked[index] = event.target.checked;
const updatedChecked = [...checked]
updatedChecked[index] = event.target.checked

const selectedStatuses = statusesFullInfo
.filter(status => updatedChecked[status.id])
.map(status => status.name.toLowerCase())
.join(",");
.join(',')

putStatusesInURL(urlKeys.STATUSES, selectedStatuses, true);
};
putStatusesInURL(urlKeys.STATUSES, selectedStatuses, true)
}

const COMMON_STATUSES = [
{ id: 0, name: statuses.ACCEPTED, color: "warning" },
{ id: 1, name: statuses.OPEN, color: "info" },
{ id: 2, name: statuses.WAITING, color: "waiting" },
{ id: 3, name: statuses.CLOSE, color: "success" },
{ id: 4, name: statuses.REJECTED, color: "error" },
];
{ id: 0, name: statuses.ACCEPTED, color: 'warning' },
{ id: 1, name: statuses.OPEN, color: 'info' },
{ id: 2, name: statuses.WAITING, color: 'waiting' },
{ id: 3, name: statuses.CLOSED, color: 'success' },
{ id: 4, name: statuses.REJECTED, color: 'error' },
]

const ADDITIONAL_STATUSES = isAllStatuses
? [{ id: 5, name: statuses.NEW, color: "new" }]
: [];
? [{ id: 5, name: statuses.NEW, color: 'new' }]
: []

const statusesList = [...COMMON_STATUSES, ...ADDITIONAL_STATUSES];
const statusesList = [...COMMON_STATUSES, ...ADDITIONAL_STATUSES]

const statusesName = statusesList.map(status => status.name);
const statusesName = statusesList.map(status => status.name)

const statusesQueryParams: string[] | undefined =
searchParams.get(urlKeys.STATUSES)?.split(",") ?? [];
searchParams.get(urlKeys.STATUSES)?.split(',') ?? []

const checked: boolean[] = statusesQueryParams
? statusesName.map(status => statusesQueryParams.includes(status))
: statusesName.map(() => false);
: statusesName.map(() => false)

const statusesFullInfo = statusesList.map(status =>
getStatusObject(status.id, status.name, status.color, !!checked[status.id])
);
)

return [statusesFullInfo, checked];
};
return [statusesFullInfo, checked]
}
48 changes: 24 additions & 24 deletions src/components/LogInModal/components/ConfirmStep/ConfirmStep.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
import { FC, Dispatch, SetStateAction } from "react";
import { useTranslation } from "react-i18next";
import { FC, Dispatch, SetStateAction } from 'react'
import { useTranslation } from 'react-i18next'

import useTheme from "@mui/material/styles/useTheme";
import Button from "@mui/material/Button";
import Typography from "@mui/material/Typography";
import Grid from "@mui/material/Grid";
import { Theme, SxProps } from "@mui/material/styles";
import useTheme from '@mui/material/styles/useTheme'
import Button from '@mui/material/Button'
import Typography from '@mui/material/Typography'
import Grid from '@mui/material/Grid'
import { Theme, SxProps } from '@mui/material/styles'

import IPalette from "theme/IPalette.interface";
import IPalette from 'theme/IPalette.interface'

interface ConfirmStepProps {
setOpen: Dispatch<SetStateAction<boolean>>;
wrapperStyle: SxProps<Theme>;
setOpen: Dispatch<SetStateAction<boolean>>
wrapperStyle: SxProps<Theme>
}

const ConfirmStep: FC<ConfirmStepProps> = ({ setOpen, wrapperStyle }) => {
const { t } = useTranslation();
const { palette }: IPalette = useTheme();
const { t } = useTranslation()
const { palette }: IPalette = useTheme()

const handleClose = () => {
setOpen(false);
};
setOpen(false)
}

return (
<Grid container sx={wrapperStyle}>
<Typography id="modal-modal-title" variant="h6" component="h2">
{t("login.confirm.header")}
<Typography id='modal-modal-title' variant='h6' component='h2'>
{t('login.confirm.header')}
</Typography>
<Typography
id="modal-modal-title"
id='modal-modal-title'
sx={{
fontSize: 16,
color: palette.whiteAlpha.default,
textAlign: "center",
textAlign: 'center',
}}
>
{t("login.confirm.description")}
{t('login.confirm.description')}
</Typography>
<Button variant="contained" color="primary" onClick={handleClose}>
{t("login.confirm.close")}
<Button variant='contained' color='primary' onClick={handleClose}>
{t('login.confirm.closed')}
</Button>
</Grid>
);
};
)
}

export { ConfirmStep };
export { ConfirmStep }
Loading

0 comments on commit a0c4f50

Please sign in to comment.