Skip to content

Commit

Permalink
Merge pull request #828 from ita-social-projects/develop
Browse files Browse the repository at this point in the history
Merge develop to release
  • Loading branch information
YuriyHryshchenko authored Sep 25, 2023
2 parents 6cd4a44 + f74ca39 commit 04615f9
Show file tree
Hide file tree
Showing 59 changed files with 1,410 additions and 188 deletions.
40 changes: 22 additions & 18 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'slick-carousel/slick/slick.css';
import 'slick-carousel/slick/slick-theme.css';
import 'react-toastify/dist/ReactToastify.min.css';
import {
fetchCities,
fetchDirections,
fetchOrigins,
fetchPostsTypes,
Expand All @@ -46,12 +47,14 @@ export const App: React.FC = () => {
boundFetchOrigins,
boundFetchPostsTypes,
boundFetchRegions,
boundFetchCities,
boundAuthorities,
] = useActions([
fetchDirections,
fetchOrigins,
fetchPostsTypes,
fetchRegions,
fetchCities,
getAuthoritiesAsyncAction,
]);

Expand All @@ -62,6 +65,7 @@ export const App: React.FC = () => {
boundFetchOrigins();
boundFetchPostsTypes();
boundFetchRegions();
boundFetchCities();
};
fetchProperties();
if (!localStorage.getItem('lang')) localStorage.setItem('lang', 'uk');
Expand All @@ -84,24 +88,24 @@ export const App: React.FC = () => {
<div className="content">
<AuthProvider>
<ScreenProvider>
<BreadcrumbsProvider configs={breadcrumbsConfigs}>
<Header />
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<Suspense
fallback={
<div className="mainLoading">
<CircularProgress />
</div>
}
>
<RenderRoutes
routes={ROUTER_CONFIG}
adminRouterConfig={ADMIN_ROUTER_CONFIG}
/>
</Suspense>
</MuiPickersUtilsProvider>
<Footer />
</BreadcrumbsProvider>
<BreadcrumbsProvider configs={breadcrumbsConfigs}>
<Header />
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<Suspense
fallback={
<div className="mainLoading">
<CircularProgress />
</div>
}
>
<RenderRoutes
routes={ROUTER_CONFIG}
adminRouterConfig={ADMIN_ROUTER_CONFIG}
/>
</Suspense>
</MuiPickersUtilsProvider>
<Footer />
</BreadcrumbsProvider>
</ScreenProvider>
</AuthProvider>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/Editor/__snapshots__/PreviewInput.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`component renders properly with all props 1`] = `
style="width: 100%;"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl makeStyles-requiredAuthorField-13 MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled"
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl makeStyles-requiredAuthorField-14 MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled"
data-shrink="true"
>
Текст картки матеріалу
Expand All @@ -33,10 +33,10 @@ exports[`component renders properly with all props 1`] = `
/>
<fieldset
aria-hidden="true"
class="PrivateNotchedOutline-root-19 MuiOutlinedInput-notchedOutline"
class="PrivateNotchedOutline-root-21 MuiOutlinedInput-notchedOutline"
>
<legend
class="PrivateNotchedOutline-legendLabelled-21 PrivateNotchedOutline-legendNotched-22"
class="PrivateNotchedOutline-legendLabelled-23 PrivateNotchedOutline-legendNotched-24"
>
<span>
Текст картки матеріалу
Expand Down Expand Up @@ -85,10 +85,10 @@ exports[`component renders properly with only required props 1`] = `
/>
<fieldset
aria-hidden="true"
class="PrivateNotchedOutline-root-8 MuiOutlinedInput-notchedOutline"
class="PrivateNotchedOutline-root-9 MuiOutlinedInput-notchedOutline"
>
<legend
class="PrivateNotchedOutline-legendLabelled-10 PrivateNotchedOutline-legendNotched-11"
class="PrivateNotchedOutline-legendLabelled-11 PrivateNotchedOutline-legendNotched-12"
>
<span>
Текст картки матеріалу
Expand Down
1 change: 0 additions & 1 deletion src/components/Form/Buttons/BasicButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const BasicButton: React.FC<IBasicButtonProps> = ({
className={clsx(getRootClass(), className)}
type="submit"
variant="contained"
fullWidth
disabled={disabled}
onClick={onClick}
>
Expand Down
24 changes: 24 additions & 0 deletions src/components/Form/Buttons/CancelButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { Button } from '@material-ui/core';
import { useStyles } from './styles/CancelButton.style';

type CancelButtonPropsType = {
label: string;
onClick?: React.MouseEventHandler<HTMLButtonElement>;
};
export const CancelButton: React.FC<CancelButtonPropsType> = ({
label,
onClick,
}) => {
const classes = useStyles();

return (
<Button
className={classes.cancelButton}
variant="contained"
onClick={onClick}
>
{label}
</Button>
);
};
27 changes: 27 additions & 0 deletions src/components/Form/Buttons/__tests__/CancelButton.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import userEvent, { TargetElement } from '@testing-library/user-event';
import { CancelButton } from '../CancelButton';

describe('Test for CancelButton component', () => {
it('Should render a button', () => {
const { container } = render(<CancelButton label="Hello world" />);
expect(container.firstChild).toHaveClass('CancelButton-cancelButton-1');
});

it('Should render a label properly', () => {
render(<CancelButton label="Hello world" />);
const label = screen.getByText('Hello world');

expect(label).toBeInTheDocument();
});

it('Should handle onClick', () => {
const handleClick = jest.fn();
const { container } = render(
<CancelButton label="Hello World" onClick={handleClick} />,
);
userEvent.click(container.firstChild as TargetElement);
expect(handleClick).toBeCalled();
});
});
1 change: 1 addition & 0 deletions src/components/Form/Buttons/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { BasicButton } from './BasicButton';
export { CancelButton } from './CancelButton';
11 changes: 8 additions & 3 deletions src/components/Form/Buttons/styles/BasicButton.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@ export const useStyles = makeStyles(
basicAcceptButton: {
marginTop: theme.spacing(7),
padding: theme.spacing(3.7, 2.8),
fontFamily: 'Raleway',
fontWeight: 600,
fontSize: theme.spacing(3.6),
},
basicSignButton: {
padding: theme.spacing(3.2, 8.8),
borderRadius: theme.spacing(10),
flex: '0 1 300px',
marginRight: 0,
alignSelf: 'flex-end',
backgroundColor: '#FF5C00',
'& .MuiButton-label': {
color: theme.palette.common.white,
fontWeight: 700,
fontSize: '18px',
fontFamily: 'Raleway',
},
'&:hover': {
backgroundColor: '#ffaa00',
},
[theme.breakpoints.down('sm')]: {
flex: '0 1 auto',
padding: theme.spacing(2, 3.1),
'& .MuiButton-label': {
fontSize: '15px',
},
},
},
}),
{
Expand Down
25 changes: 25 additions & 0 deletions src/components/Form/Buttons/styles/CancelButton.style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { makeStyles, Theme } from '@material-ui/core';

export const useStyles = makeStyles(
(theme: Theme) => ({
cancelButton: {
flex: '0 1 300px',
backgroundColor: theme.palette.info.light,
'& .MuiButton-label': {
color: theme.palette.common.white,
fontWeight: 700,
fontSize: '18px',
},
'&:hover': {
backgroundColor: theme.palette.info.main,
},
[theme.breakpoints.down('sm')]: {
flex: '0 1 auto',
'& .MuiButton-label': {
fontSize: '15px',
},
},
},
}),
{ name: 'CancelButton' },
);
1 change: 0 additions & 1 deletion src/components/Page/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface IPageProps {

const Page: React.FC<IPageProps> = (props) => {
const classes = useStyles();
const { component } = props;

const { mobile } = useContext(ScreenContext);

Expand Down
16 changes: 16 additions & 0 deletions src/locales/uk/parts/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,20 @@ export const admin = {
maxImportantPostCountReached: `Досягнуто максимум важливих постів`,
createNewAuthor: `Створити нового автора`,
showNotesAmount: `Відобразити <dropDown/> записів`,
firstName: `Ім'я`,
lastName: `Прізвище`,
email: `Електонна пошта`,
socialNetworkLinks: `Посилання на персональні сторінки`,
minimumOneLinkRequired: `Необхідно додати мінімум одне посилання`,
mainPlaceOfWork: `Основне місце роботи`,
biography: `Біографія`,
fieldCantBeEmpty: `Поле не може бути порожнім`,
wrongEmail: `Неаправильна email адреса`,
allowedChar: `Дозволені символи: (пробіл)"№'()-.,/&%:@`,
pictureRequired: `Необхідно додати зображення`,
minRequired: `Необхідно ввести мінімум`,
maxRequired: `Можливо ввести максимум`,
symbols: `символів`,
changesList: `Зміни заголовку`,
noChangesLog: `Жодних змін не знайдено`,
};
1 change: 1 addition & 0 deletions src/locales/uk/parts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const common = {
enterTagName: 'Введіть назву тега',
showMore: 'Показати ще',
acceptChanges: 'Підтвердити зміни',
cancelChanges: 'Скасувати зміни',
selectedMaterials: 'Обрані матеріали',
publishedMaterials: 'Опубліковані матеріали',
unPublishedMaterials: 'Неопубліковані матеріали',
Expand Down
15 changes: 15 additions & 0 deletions src/models/changeLog/asyncAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createAsyncThunk } from '@reduxjs/toolkit';
import { fetchChangeLog } from 'old/lib/utilities/API/api';
import { IChangeLogOptions } from './types';

export const getChangeLog = createAsyncThunk(
'getChangeLogActions',
async (options: IChangeLogOptions, { rejectWithValue }) => {
try {
const { data } = await fetchChangeLog(options);
return data;
} catch (error) {
return rejectWithValue(error);
}
},
);
3 changes: 3 additions & 0 deletions src/models/changeLog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* eslint-disable import/no-cycle */
export { changeLogReducer, setChangesSize } from './reducer';
export { selectSize } from './selectors';
32 changes: 32 additions & 0 deletions src/models/changeLog/reducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { getAsyncActionsReducer } from 'models/helpers/asyncActions';
import { ChangeLogType } from 'old/lib/utilities/API/types';
import { getChangeLog } from './asyncAction';

const initialState: ChangeLogType = {
size: 0,
content: [],
};

const changeLog = createSlice({
name: 'changesLog',
initialState,
reducers: {
setChangesSize: (state, action: PayloadAction<number>) => {
const setChangeObj = state;
setChangeObj.size = action.payload;
},
setPage: (state, action: PayloadAction<number>) => {
const setPageObj = state;
setPageObj.totalElements = action.payload;
},
},
extraReducers: {
...getAsyncActionsReducer(getChangeLog as any),
},
});

const { setChangesSize, setPage } = changeLog.actions;

const changeLogReducer = changeLog.reducer;
export { setChangesSize, setPage, changeLogReducer };
9 changes: 9 additions & 0 deletions src/models/changeLog/selectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { RootStateType } from 'models/rootReducer';

export const selectSize = (state: RootStateType): number | undefined => {
return state.changesLog.size;
};

export const selectTotalPages = (state: RootStateType): number | undefined => {
return state.changesLog.totalPages;
};
7 changes: 7 additions & 0 deletions src/models/changeLog/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface IChangeLogOptions {
size?: number;
page?: number;
totalElements?: number;
totalPages?: number;
pageNumber?: number;
}
28 changes: 26 additions & 2 deletions src/models/experts/asyncActions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
/* eslint-disable */
import { createAsyncThunk } from '@reduxjs/toolkit';
import { IFetchExpertsOptions, IExpertsAutorsListOptions } from './types';
import { getAllExperts } from '../../old/lib/utilities/API/api';
import {
IFetchExpertsOptions,
IExpertsAutorsListOptions,
IExpertsDeleteAutor,
} from './types';
import {
deleteAuthorById,
getAllExperts,
} from '../../old/lib/utilities/API/api';
import { LOAD_EXPERTS_LIMIT } from '../../old/lib/constants/experts';
import { IExpert } from '../../old/lib/types';
import { ExpertResponseType } from '../../old/lib/utilities/API/types';
Expand Down Expand Up @@ -107,3 +114,20 @@ export const fetchExpertsAutorsList = createAsyncThunk(
}
},
);

export const deleteAuthor = createAsyncThunk(
'experts/deleteAuthor',
async (options: IExpertsDeleteAutor, { getState, rejectWithValue }) => {
try {
const { id } = options;
await deleteAuthorById(id);
const {
experts: { data },
} = getState() as any;
const ids = data.expertIds.filter((expertId: number) => expertId !== id);
return { ...data, expertIds: ids };
} catch (error) {
return rejectWithValue(error.response?.data);
}
},
);
7 changes: 6 additions & 1 deletion src/models/experts/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
ISortAutorsList,
ITextFields,
} from './types';
import { fetchExperts, fetchExpertsAutorsList } from './asyncActions';
import {
deleteAuthor,
fetchExperts,
fetchExpertsAutorsList,
} from './asyncActions';
import { getAsyncActionsReducer } from '../helpers/asyncActions';

const initialState: IExpertsState = {
Expand Down Expand Up @@ -66,6 +70,7 @@ export const expertsSlice = createSlice({
extraReducers: {
...getAsyncActionsReducer(fetchExperts as any),
...getAsyncActionsReducer(fetchExpertsAutorsList as any),
...getAsyncActionsReducer(deleteAuthor as any),
},
});

Expand Down
Loading

0 comments on commit 04615f9

Please sign in to comment.