diff --git a/.eslintrc.js b/.eslintrc.js index 754b577..2793f27 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -58,6 +58,7 @@ module.exports = { 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'warn', 'import/prefer-default-export': 'off', + '@typescript-eslint/no-explicit-any': 'off', 'jsx-a11y/click-events-have-key-events': 'off', 'jsx-a11y/no-static-element-interactions': 'off', 'prefer-arrow-callback': [ diff --git a/src/api/indexPage/get-index-page-data.ts b/src/api/index-page/get-index-page-data.ts similarity index 52% rename from src/api/indexPage/get-index-page-data.ts rename to src/api/index-page/get-index-page-data.ts index bb29424..3ef5fb2 100644 --- a/src/api/indexPage/get-index-page-data.ts +++ b/src/api/index-page/get-index-page-data.ts @@ -1,32 +1,24 @@ import { apiRequestObject } from 'utils/api'; -import { REQUEST_TYPE } from 'constants/RequestType'; +import { REQUEST_TYPES } from 'constants/request-types'; import { removeUndefinedFromObject } from 'utils/object'; -const url = '/photos/'; +const API_URL = '/photos/'; -export const transformer = ({ - data -}: { - data: { - url: string; - title: string; - albumId: number; - }[]; -}) => { +export const transformer = ({ data }: any) => { // change or convert response - return data?.slice(0, 5)?.map((item) => + return data?.slice(0, 5)?.map(({ title, url, albumId }: any) => removeUndefinedFromObject({ // just 5 item - title: item.title || '', - url: item.url || '', - album: item.albumId === 1 ? 'A' : 'B' + url, + title, + album: albumId === 1 ? 'A' : 'B' }) ); }; export const getIndexPageData = apiRequestObject({ - url, - type: REQUEST_TYPE.GET, + url: API_URL, + type: REQUEST_TYPES.GET, inputTransformer: ({ albumId }: { albumId: number }) => ({ // change or convert your data albumId diff --git a/src/components/shared/snackbar/SnackbarWrapper.tsx b/src/components/shared/snackbar-wrapper/index.tsx similarity index 94% rename from src/components/shared/snackbar/SnackbarWrapper.tsx rename to src/components/shared/snackbar-wrapper/index.tsx index c720f0a..7fc7ce6 100644 --- a/src/components/shared/snackbar/SnackbarWrapper.tsx +++ b/src/components/shared/snackbar-wrapper/index.tsx @@ -2,7 +2,7 @@ import { useEffect } from 'react'; import { ToastContainer, toast, Slide, Zoom, Flip, Bounce } from 'react-toastify'; -import { SNACKBAR_POSITIONS, SNACKBAR_TYPES } from 'constants/Snackbar'; +import { SNACKBAR_POSITIONS, SNACKBAR_TYPES } from 'constants/snackbar'; import 'react-toastify/dist/ReactToastify.min.css'; @@ -40,7 +40,7 @@ export function SnackbarWrapper() { const toastId = type + message; if (type === SNACKBAR_TYPES.MESSAGE) { - return toast(message, { + toast(message, { icon, toastId, position, @@ -48,6 +48,7 @@ export function SnackbarWrapper() { theme: TOAST_COLOR_TYPES.DARK, transition: TOAST_TRANSITION_TYPES.SLIDE }); + return; } toast[type]?.(message, { diff --git a/src/constants/ErrorMessages.ts b/src/constants/error-messages.ts similarity index 100% rename from src/constants/ErrorMessages.ts rename to src/constants/error-messages.ts diff --git a/src/constants/reducerNames.ts b/src/constants/reducer-names.ts similarity index 100% rename from src/constants/reducerNames.ts rename to src/constants/reducer-names.ts diff --git a/src/constants/RequestType.ts b/src/constants/request-types.ts similarity index 69% rename from src/constants/RequestType.ts rename to src/constants/request-types.ts index fc9bed7..2ca162d 100644 --- a/src/constants/RequestType.ts +++ b/src/constants/request-types.ts @@ -1,4 +1,4 @@ -export const REQUEST_TYPE: { +export const REQUEST_TYPES: { GET: 'GET'; POST: 'POST'; } = { diff --git a/src/constants/SuccessMessages.ts b/src/constants/success-messages.ts similarity index 100% rename from src/constants/SuccessMessages.ts rename to src/constants/success-messages.ts diff --git a/src/hooks/useApi.ts b/src/hooks/useApi.ts index 698150e..4ce1a3a 100644 --- a/src/hooks/useApi.ts +++ b/src/hooks/useApi.ts @@ -3,14 +3,14 @@ import { useEffect, useMemo, useState } from 'react'; import { noop } from 'lodash'; import { redirect } from 'utils/url'; -import { userSelectors } from 'store/user/userSelectors'; -import { INDEX_PAGE_ROUTE } from 'routes/RedirectRoutes'; +import { userSelectors } from 'store/user/user-selectors'; +import { INDEX_PAGE_ROUTE } from 'routes/redirect-routes'; import { hasAPICache, setAPICache, getAPICacheData, checkAPICacheTime -} from 'services/api/cacheSystem'; +} from 'services/api/cache-system'; interface Properties { apiMethod: any; diff --git a/src/hooks/usePageData.ts b/src/hooks/usePageData.ts index 5bb2f3c..c3665f1 100644 --- a/src/hooks/usePageData.ts +++ b/src/hooks/usePageData.ts @@ -6,7 +6,7 @@ import { setAPICache, getAPICacheData, checkAPICacheTime -} from 'services/api/cacheSystem'; +} from 'services/api/cache-system'; interface Properties { apiData?: any; diff --git a/src/index.tsx b/src/index.tsx index 96593df..77ea7f9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,7 +5,7 @@ import { reportWebVitals } from 'reportWebVitals'; import { store } from 'store'; import { Routes } from 'routes'; -import { SnackbarWrapper } from 'components/shared/snackbar/SnackbarWrapper'; +import { SnackbarWrapper } from 'components/shared/snackbar-wrapper'; import 'animate.css'; import 'styles/index.scss'; diff --git a/src/pages/404.tsx b/src/pages/404.tsx index b222758..76bc97a 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -1,5 +1,5 @@ import { Link } from 'react-router-dom'; -import { INDEX_PAGE_ROUTE } from 'routes/RedirectRoutes'; +import { INDEX_PAGE_ROUTE } from 'routes/redirect-routes'; export function NotFoundPage() { return ( diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 77bf2d8..c5415c3 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -2,7 +2,7 @@ import { useState } from 'react'; import { useAPI } from 'hooks/useApi'; import { usePageData } from 'hooks/usePageData'; -import { getIndexPageData } from 'api/indexPage/get-index-page-data'; +import { getIndexPageData } from 'api/index-page/get-index-page-data'; export function IndexPage() { const [data, setData] = useState([]); diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 8c61e86..eaa02ae 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -6,10 +6,10 @@ import { } from 'react-router-dom'; import { NotFoundPage } from 'pages/404'; -import ScrollToTop from 'routes/ScrollToTop'; -import { PAGE_ROUTES } from 'routes/PageRoutes'; -import { PrivateRoute } from 'routes/PrivateRoute'; -import { NOT_FOUND_ROUTE } from 'routes/RedirectRoutes'; +import ScrollToTop from 'routes/scroll-to-top'; +import { PAGE_ROUTES } from 'routes/page-routes'; +import { PrivateRoute } from 'routes/private-route'; +import { NOT_FOUND_ROUTE } from 'routes/redirect-routes'; export function Routes() { return ( diff --git a/src/routes/PageRoutes.tsx b/src/routes/page-routes.tsx similarity index 79% rename from src/routes/PageRoutes.tsx rename to src/routes/page-routes.tsx index fd133fa..66740eb 100644 --- a/src/routes/PageRoutes.tsx +++ b/src/routes/page-routes.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { INDEX_PAGE_ROUTE } from 'routes/RedirectRoutes'; +import { INDEX_PAGE_ROUTE } from 'routes/redirect-routes'; // PAGES import { IndexPage } from 'pages'; diff --git a/src/routes/PrivateRoute.tsx b/src/routes/private-route.tsx similarity index 87% rename from src/routes/PrivateRoute.tsx rename to src/routes/private-route.tsx index 01e3406..edf8ee3 100644 --- a/src/routes/PrivateRoute.tsx +++ b/src/routes/private-route.tsx @@ -3,8 +3,8 @@ import { ReactNode } from 'react'; import { useSelector } from 'react-redux'; import { Route, Navigate } from 'react-router-dom'; -import { userSelectors } from 'store/user/userSelectors'; -import { NOT_FOUND_ROUTE, USER_LOGIN_ROUTE } from 'routes/RedirectRoutes'; +import { userSelectors } from 'store/user/user-selectors'; +import { NOT_FOUND_ROUTE, USER_LOGIN_ROUTE } from 'routes/redirect-routes'; interface Properties { deactivate: boolean; diff --git a/src/routes/RedirectRoutes.ts b/src/routes/redirect-routes.ts similarity index 100% rename from src/routes/RedirectRoutes.ts rename to src/routes/redirect-routes.ts diff --git a/src/routes/ScrollToTop.ts b/src/routes/scroll-to-top.ts similarity index 100% rename from src/routes/ScrollToTop.ts rename to src/routes/scroll-to-top.ts diff --git a/src/services/api/cacheSystem.ts b/src/services/api/cache-system.ts similarity index 100% rename from src/services/api/cacheSystem.ts rename to src/services/api/cache-system.ts diff --git a/src/services/api/index.ts b/src/services/api/index.ts index 2325920..34fa853 100644 --- a/src/services/api/index.ts +++ b/src/services/api/index.ts @@ -3,15 +3,15 @@ import axios, { AxiosRequestConfig } from 'axios'; import { store } from 'store'; import { redirect } from 'utils/url'; import { sendLog } from 'services/log'; -import { SNACKBAR_TYPES } from 'constants/Snackbar'; -import { userLogoutAction } from 'store/user/userSlice'; -import { generateSnackbar } from 'utils/generateSnackbar'; +import { SNACKBAR_TYPES } from 'constants/snackbar'; +import { userLogoutAction } from 'store/user/user-slice'; +import { generateSnackbar } from 'utils/generate-snackbar'; import { serviceGet, servicePost } from 'services/api/initialize'; import { INDEX_PAGE_ROUTE, NOT_FOUND_ROUTE, USER_LOGIN_ROUTE -} from 'routes/RedirectRoutes'; +} from 'routes/redirect-routes'; function handleResponse({ response, diff --git a/src/services/api/initialize.ts b/src/services/api/initialize.ts index 0a966a9..c374ecf 100644 --- a/src/services/api/initialize.ts +++ b/src/services/api/initialize.ts @@ -2,8 +2,8 @@ import QS from 'qs'; import axios from 'axios'; import { isMobile } from 'react-device-detect'; -import { generateSnackbar } from 'utils/generateSnackbar'; -import { CONNECTION_ERROR } from 'constants/ErrorMessages'; +import { generateSnackbar } from 'utils/generate-snackbar'; +import { CONNECTION_ERROR } from 'constants/error-messages'; const TOKEN = ''; // Read Your TOKEN const MAX_REQUEST_PER_SECOND = 20; diff --git a/src/store/index.ts b/src/store/index.ts index 62f6565..b7f1c6e 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,7 +1,7 @@ import { configureStore } from '@reduxjs/toolkit'; -import { REDUCER_NAMES } from 'constants/reducerNames'; +import { REDUCER_NAMES } from 'constants/reducer-names'; -import useReducer from 'store/user/userSlice'; +import useReducer from 'store/user/user-slice'; export const store = configureStore({ reducer: { diff --git a/src/store/user/userSelectors.ts b/src/store/user/user-selectors.ts similarity index 100% rename from src/store/user/userSelectors.ts rename to src/store/user/user-selectors.ts diff --git a/src/store/user/userSlice.ts b/src/store/user/user-slice.ts similarity index 88% rename from src/store/user/userSlice.ts rename to src/store/user/user-slice.ts index 80e1a58..d2368f2 100644 --- a/src/store/user/userSlice.ts +++ b/src/store/user/user-slice.ts @@ -1,5 +1,5 @@ import { createSlice } from '@reduxjs/toolkit'; -import { REDUCER_NAMES } from 'constants/reducerNames'; +import { REDUCER_NAMES } from 'constants/reducer-names'; const initialState = { isAuthenticated: false // for private route system diff --git a/src/styles/toastColor.css b/src/styles/toast-color.css similarity index 100% rename from src/styles/toastColor.css rename to src/styles/toast-color.css diff --git a/src/utils/api.ts b/src/utils/api.ts index 33b9e7d..52153d9 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,5 +1,5 @@ -import { REQUEST_TYPE } from 'constants/RequestType'; import { get, post, CancelToken } from 'services/api'; +import { REQUEST_TYPES } from 'constants/request-types'; type RequestList = { [key: string]: number; @@ -19,7 +19,7 @@ export function apiRequestObject({ url, transformer, inputTransformer, - type = REQUEST_TYPE.GET + type = REQUEST_TYPES.GET }: Properties) { const source = CancelToken.source(); @@ -56,7 +56,7 @@ export function apiRequestObject({ resolve(response); }; // GET - if (type === REQUEST_TYPE.GET) { + if (type === REQUEST_TYPES.GET) { get({ url, config: { @@ -67,7 +67,7 @@ export function apiRequestObject({ }).then(handleResponse); } // POST - if (type === REQUEST_TYPE.POST) { + if (type === REQUEST_TYPES.POST) { post({ url, data: modifiedData, diff --git a/src/utils/generateSnackbar.ts b/src/utils/generate-snackbar.ts similarity index 100% rename from src/utils/generateSnackbar.ts rename to src/utils/generate-snackbar.ts diff --git a/src/utils/socialShareUrls.ts b/src/utils/social-share-urls.ts similarity index 100% rename from src/utils/socialShareUrls.ts rename to src/utils/social-share-urls.ts