diff --git a/.eslintrc.js b/.eslintrc.js index 4c0c2c768013e91386c543796b94bfe05a4f4429..518fe41d0379f3dde5e05f5645fc505ce9be3961 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,5 +14,6 @@ module.exports = { rules: { 'implicit-arrow-linebreak': 0, + 'react/prop-types': 0, }, }; diff --git a/src/core/context/UserContext.tsx b/src/core/context/UserContext.tsx index 34f1be736e985d9b13d176daa651b9e36746c9d7..0c8730888f2d7442b21a156755c96ab92c60975d 100644 --- a/src/core/context/UserContext.tsx +++ b/src/core/context/UserContext.tsx @@ -1,36 +1,5 @@ -import React, { createContext, ReactNode, useState } from 'react'; -import { Profile } from '../types'; - -// Interface definitions -interface IWarnings extends Document { - text: string; - date: Date; - given_by: { - _id: string; - name: string; - }; -} - -enum Role { - Admin, - Staff, - User, -} - -export interface IProfile { - external_id: string; - studentCardNumber?: string; - roomNumber?: string; - picture?: string; - role: Role.Admin | Role.Staff | Role.User; - email: string; - name: string; - warnings: [IWarnings] | []; -} - -type Props = { - children: ReactNode; -}; +import React, { createContext, useState } from 'react'; +import { Profile, Role } from '../types'; interface ContextProps { profile: Profile; @@ -48,7 +17,7 @@ const initialState: Profile = { name: 'Nagy Gizike', warnings: [], }; -export const userContext = createContext({} as IContextProps); +export const userContext = createContext({} as ContextProps); const { Provider } = userContext; export const UserStateProvider: React.FC = ({ children }) => { diff --git a/src/core/types.ts b/src/core/types.ts index 60db4824961d2d2cd83d780a989e6f8b2cb6b71b..23e1422b2a7f798168c27ff6a29b9d89c0b7e753 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -23,3 +23,9 @@ export interface Warnings { name: string; }; } + +export interface News { + title: string; + text: string; + publishedAt: string; +} diff --git a/src/hooks/types.ts b/src/hooks/types.ts index d639a344b70e94866b43d4923f40304dcbb6421c..ab423a80b1fbedf8aebb5dfd10604e9440956365 100644 --- a/src/hooks/types.ts +++ b/src/hooks/types.ts @@ -21,9 +21,3 @@ export interface RequestParams { export type ApiRequest<T> = (params: RequestParams) => AxiosPromise<T>; export type Refetch = (params?: RequestParams) => void; - -export interface INews { - title: string; - text: string; - publishedAt: string; -} diff --git a/src/hooks/useAddNews.ts b/src/hooks/useAddNews.ts index bbc5b5b5df9f740af6b330a5558e549083107460..51d2eb199c2749d2cbdf945825a17b80f0de649b 100644 --- a/src/hooks/useAddNews.ts +++ b/src/hooks/useAddNews.ts @@ -1,12 +1,12 @@ -import { INews } from './types'; +import { News } from '../core/types'; import useRequest from './useRequest'; import useRestQueries from './useRestQueries'; const useAddNews = () => { const { post } = useRestQueries(); - const request = post<INews>('/api/v1/news'); + const request = post<News>('/api/v1/news'); - return useRequest<INews>({ request }); + return useRequest<News>({ request }); }; export default useAddNews; diff --git a/src/hooks/useGetNewsList.ts b/src/hooks/useGetNewsList.ts index 2b36ca743948d4ea6d1320b33ab5117687707389..850572353916fa2cc58ba0ab293c4b32e50c4fc7 100644 --- a/src/hooks/useGetNewsList.ts +++ b/src/hooks/useGetNewsList.ts @@ -1,12 +1,12 @@ -import { INews } from './types'; +import { News } from '../core/types'; import useRequest from './useRequest'; import useRestQueries from './useRestQueries'; -const useGetNewsList = (data?: INews[]) => { +const useGetNewsList = (data?: News[]) => { const { get } = useRestQueries(); - const request = get<INews[]>('/api/v1/news'); + const request = get<News[]>('/api/v1/news'); - return useRequest<INews[]>({ request, initialData: data }); + return useRequest<News[]>({ request, initialData: data }); }; export default useGetNewsList;