Skip to content

Commit cdec31e

Browse files
authored
Merge pull request #347 from qa-guru/QAGDEV-666
QAGDEV-666 – [FE] MakeVar, fix autocomplete search input
2 parents 3007991 + 9a633f5 commit cdec31e

File tree

53 files changed

+177
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+177
-172
lines changed

.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@
144144
"pattern": "@/**",
145145
"group": "external"
146146
},
147+
{
148+
"pattern": "theme",
149+
"group": "internal"
150+
},
151+
{
152+
"pattern": "cache",
153+
"group": "internal"
154+
},
147155
{
148156
"pattern": "{api,assets,features,pages,shared,theme}/**",
149157
"group": "internal"

src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { ApolloClient, HttpLink, ApolloLink, Observable } from "@apollo/client";
22
import { onError } from "@apollo/client/link/error";
33
import fetch from "cross-fetch";
4-
import { cache } from "cache";
54

5+
import { cache } from "cache";
66
import AuthService from "api/rest/auth-service";
77
import { FETCH_POLICY } from "shared/constants";
88

src/app/providers/with-context.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { ReactNode } from "react";
2+
import { ThemeProvider } from "@mui/material";
23

3-
import { CommentProvider } from "shared/context/comment-context";
4-
import SettingsProvider from "shared/context/setting-context";
4+
import { useSettings } from "shared/hooks";
5+
import { createCustomTheme } from "theme";
56

67
export const withContext = (component: () => ReactNode) => {
78
return function WithContextComponent() {
8-
return (
9-
<SettingsProvider>
10-
<CommentProvider>{component()}</CommentProvider>
11-
</SettingsProvider>
12-
);
9+
const { settings } = useSettings();
10+
11+
const theme = createCustomTheme({
12+
theme: settings.theme,
13+
responsiveFontSizes: settings.responsiveFontSizes,
14+
});
15+
16+
return <ThemeProvider theme={theme}>{component()}</ThemeProvider>;
1317
};
1418
};

src/cache.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { InMemoryCache, makeVar } from "@apollo/client";
22

3+
import { initialSettings, themeSettingsTypes } from "theme";
4+
import { THEMES } from "theme/constans";
35
import { Maybe, UserRole } from "api/graphql/generated/graphql";
46

57
export const userIdVar = makeVar<Maybe<string>>(null);
6-
78
export const userRolesVar = makeVar<Maybe<Maybe<UserRole>[]>>([]);
9+
export const commentVar = makeVar<Maybe<string | undefined>>(null);
10+
export const settingsVar = makeVar<themeSettingsTypes>(initialSettings);
11+
export const lightThemeVar = makeVar<boolean>(
12+
initialSettings.theme === THEMES.LIGHT
13+
);
814

915
export const cache = new InMemoryCache();

src/features/admin-panel/users-admin/views/input-filter/input-filter.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ import {
2020
import RoleSelection from "../role-selection";
2121

2222
const filterLabels = {
23-
firstName: "имя",
23+
name: "имя",
2424
email: "email",
2525
};
2626

2727
type FilterKey = keyof typeof filterLabels;
2828

2929
const InputFilter: FC = () => {
3030
const { setFilter } = useTableAdminFilter();
31-
const [activeFilter, setActiveFilter] = useState<FilterKey>("firstName");
31+
const [activeFilter, setActiveFilter] = useState<FilterKey>("name");
3232

3333
const { control, watch, reset, resetField } = useForm({
3434
defaultValues: {
@@ -78,8 +78,8 @@ const InputFilter: FC = () => {
7878
<InputAdornment position="start">
7979
<StyledIconsStack>
8080
<StyledIconInputButton
81-
isActive={activeFilter === "firstName"}
82-
onClick={() => handleFilterChange("firstName")}
81+
isActive={activeFilter === "name"}
82+
onClick={() => handleFilterChange("name")}
8383
>
8484
<Tooltip title="Имя">
8585
<Person fontSize="small" />

src/features/admin-panel/users-admin/views/input-select-trainings-purchases/input-select-trainings-purchases.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ const InputSelectTrainingsPurchases: FC<IInputSelectTrainingsPurchases> = ({
6262
const handleSelectChange = (trainings: ITrainingOption[]) => {
6363
setValue("trainings", trainings);
6464

65-
console.log("trainings", trainings);
66-
6765
updateUserTrainingPurchase({
6866
variables: {
6967
tariffCodes: trainings?.map(({ code }) => code!),

src/features/edit-training/containers/lectors/lectors-container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const UsersContainer: FC<ILectorsContainer> = ({ control, name, role }) => {
2929
sort: { field: UserSortField.Email, order: Order.Desc },
3030
filter: {
3131
role,
32-
firstName: filterName,
32+
name: filterName,
3333
},
3434
},
3535
fetchPolicy: FETCH_POLICY.NETWORK_ONLY,

src/features/edit-training/views/select-lectors/select-lectors.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,34 @@ const SelectLectors: FC<ISelectLectors> = ({
2121
}) => {
2222
const items = data?.users?.items || [];
2323

24+
const lectorOptions =
25+
items?.map((item) => ({
26+
...item,
27+
name: `${item?.firstName} ${item?.lastName}`,
28+
})) || [];
29+
2430
return (
2531
<FormControl fullWidth>
2632
<Controller
2733
name={name}
2834
control={control}
29-
render={({ field: { onChange, value = [] } }) => (
35+
render={({ field: { value, onChange } }) => (
3036
<Autocomplete
3137
multiple
32-
options={items}
33-
getOptionLabel={(option) => option.firstName}
38+
options={lectorOptions}
39+
getOptionLabel={(option) => option.name}
3440
isOptionEqualToValue={(option, value) => option.id === value.id}
3541
value={value || []}
3642
onInputChange={(_, newInputValue) => onSearchChange(newInputValue)}
3743
onChange={(_, newValue) => {
3844
onChange(newValue);
3945
}}
46+
disablePortal
4047
renderInput={(params) => (
4148
<TextField
4249
{...params}
4350
variant="outlined"
44-
placeholder="Начните вводить имя..."
51+
placeholder="Выберите преподавателя"
4552
InputProps={{
4653
...params.InputProps,
4754
endAdornment: (

src/features/header/containers/user/user-container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FC } from "react";
2-
import { userIdVar } from "cache";
32

3+
import { userIdVar } from "cache";
44
import { AppSpinner } from "shared/components/spinners";
55
import NoDataErrorMessage from "shared/components/no-data-error-message";
66
import { useUserQuery } from "api/graphql/generated/graphql";

src/features/header/views/header/header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { FC, useState } from "react";
2+
import { useReactiveVar } from "@apollo/client";
23

4+
import { lightThemeVar } from "cache";
35
import { IPages } from "features/header/types";
46
import { Maybe, UserRole } from "api/graphql/generated/graphql";
57
import ThemeSelector from "shared/components/theme-selector";
6-
import { useSettings } from "shared/hooks";
78
import CustomLink from "shared/components/custom-link";
89

910
import { useRoleFilterPages } from "../../hooks/use-role-filter-pages";
@@ -93,8 +94,7 @@ const configMobilePages: IPages[] = [
9394

9495
const Header: FC = () => {
9596
const [anchorElNav, setAnchorElNav] = useState<Maybe<HTMLElement>>(null);
96-
const { settings } = useSettings();
97-
const lightTheme = settings.theme === "light";
97+
const lightTheme = useReactiveVar(lightThemeVar);
9898

9999
const pages = useRoleFilterPages(configPages);
100100
const mobilePages = useRoleFilterPages(configMobilePages);

0 commit comments

Comments
 (0)