mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 10:19:22 +03:00
feat: added api proxy & image type
This commit is contained in:
parent
9a43ade63a
commit
d997f99239
1
constants.ts
Normal file
1
constants.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const BACKEND_URL: string = 'http://localhost:3333';
|
||||||
@ -1,8 +1,7 @@
|
|||||||
import { AxiosRequestConfig } from 'axios';
|
import { AxiosRequestConfig } from 'axios';
|
||||||
import * as constants from './constants';
|
|
||||||
|
|
||||||
const apiConfig: AxiosRequestConfig = {
|
const apiConfig: AxiosRequestConfig = {
|
||||||
baseURL: constants.API_BASE_URL,
|
baseURL: '/api/',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
export const API_BASE_URL: string = 'http://localhost:3333/api';
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import type { RouteComponentProps } from 'react-router-dom';
|
import type { RouteComponentProps } from 'react-router-dom';
|
||||||
import { LinkType } from '@educt/types';
|
import { CourseImage, LinkType } from '@educt/types';
|
||||||
import { CourseStatusEnum, UserRoleEnum } from '../enums';
|
import { CourseStatusEnum, UserRoleEnum } from '../enums';
|
||||||
|
|
||||||
export interface IAppConfig {
|
export interface IAppConfig {
|
||||||
@ -21,7 +21,7 @@ export interface ICourse {
|
|||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
status: CourseStatusEnum;
|
status: CourseStatusEnum;
|
||||||
image: null | {};
|
image: null | CourseImage;
|
||||||
teacher: Pick<IUser, 'id' | 'first_name' | 'last_name' | 'email'>;
|
teacher: Pick<IUser, 'id' | 'first_name' | 'last_name' | 'email'>;
|
||||||
category: ICategory;
|
category: ICategory;
|
||||||
lessons: ILesson[];
|
lessons: ILesson[];
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import { useRootStore } from '@educt/hooks/useRootStore';
|
|||||||
import CourseStatusBadge from '@educt/components/CourseStatusBadge';
|
import CourseStatusBadge from '@educt/components/CourseStatusBadge';
|
||||||
import { CourseStatusEnum } from '@educt/enums';
|
import { CourseStatusEnum } from '@educt/enums';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
|
import { API_BASE_URL } from '@educt/constants';
|
||||||
|
|
||||||
type CourseItemPropsType = {
|
type CourseItemPropsType = {
|
||||||
course: Omit<ICourse, 'teacher' | 'students' | 'lessons'>;
|
course: Omit<ICourse, 'teacher' | 'students' | 'lessons'>;
|
||||||
@ -111,7 +112,7 @@ const CourseItem: React.FC<CourseItemPropsType> = ({ course, onDelete, onSetStat
|
|||||||
w='100%'
|
w='100%'
|
||||||
borderTopLeftRadius='lg'
|
borderTopLeftRadius='lg'
|
||||||
borderTopRightRadius='lg'
|
borderTopRightRadius='lg'
|
||||||
src='https://bit.ly/2k1H1t6'
|
src={course.image ? `/api/assets/images/courses/${course.image.name}` : ''}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box p='0 10px' mt='10px' pb='20px'>
|
<Box p='0 10px' mt='10px' pb='20px'>
|
||||||
|
|||||||
8
src/types/index.d.ts
vendored
8
src/types/index.d.ts
vendored
@ -15,6 +15,14 @@ export type LinkType = {
|
|||||||
icon: IconType;
|
icon: IconType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type CourseImage = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
ext: string;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type ConfirmEmailContainerDataType = {
|
export type ConfirmEmailContainerDataType = {
|
||||||
newEmail: string;
|
newEmail: string;
|
||||||
expired_seconds: number;
|
expired_seconds: number;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
|
import * as constants from './constants';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
import { visualizer } from 'rollup-plugin-visualizer';
|
import { visualizer } from 'rollup-plugin-visualizer';
|
||||||
@ -18,6 +19,14 @@ export default defineConfig({
|
|||||||
root: './',
|
root: './',
|
||||||
publicDir: 'public',
|
publicDir: 'public',
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: constants.BACKEND_URL,
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: [{ find: '@educt', replacement: path.resolve(__dirname, 'src') }],
|
alias: [{ find: '@educt', replacement: path.resolve(__dirname, 'src') }],
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user