-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
667 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { FC } from 'react'; | ||
import EventForm from "@/widgets/Event/EventForm"; | ||
|
||
const EventCreate: FC = () => { | ||
return ( | ||
<div className='main__block block_column p_40 w_100p'> | ||
<h3 className='mb_30'>Создания события</h3> | ||
|
||
<EventForm/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EventCreate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { FC } from 'react'; | ||
import EventForm from "@/widgets/Event/EventForm"; | ||
import { useParams } from "react-router-dom"; | ||
|
||
const EventEdit: FC = () => { | ||
const { id } = useParams() | ||
|
||
return ( | ||
<div className='main__block block_column p_40 w_100p'> | ||
<h3 className='mb_30'>Редактирование события</h3> | ||
|
||
<EventForm id={ id ? Number(id) : undefined }/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EventEdit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FC, useEffect, useState } from 'react'; | ||
import Table from "@/shared/ui/Table/Table"; | ||
import { EventColumn } from "@/widgets"; | ||
import { Link } from "react-router-dom"; | ||
import { pathRoutes } from "@/app"; | ||
import { EventType } from "@/shared/types"; | ||
import { fetchAllEvent } from "@/shared/api/event"; | ||
|
||
const EventList: FC = () => { | ||
const [eventList, setEventList] = useState<EventType[] | []>([]) | ||
|
||
useEffect(() => { | ||
fetchAllEvent().then((res) => { | ||
setEventList(res.data) | ||
}) | ||
}, []); | ||
|
||
return ( | ||
<div className='main__block block_column p_40 w_100p'> | ||
<h3 className='mb_30'>Список событий</h3> | ||
<Table rows={ eventList } columns={ EventColumn } style={ { isHeader: true } }/> | ||
|
||
<div className="block_row justify-end w_100p mt_10"> | ||
<Link to={ pathRoutes.event.create }> | ||
<button className='button'>Создать</button> | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EventList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './EventCreate' | ||
export * from './EventEdit' | ||
export * from './EventList' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { AxiosResponse } from "axios"; | ||
import { EventType } from "@/shared/types"; | ||
import axiosInstance from "@/shared/api/axios"; | ||
|
||
export const fetchAllEvent = async () => { | ||
const response: AxiosResponse<EventType[]> = await axiosInstance.get( | ||
`/event`, | ||
) | ||
|
||
return response | ||
} | ||
|
||
export const fetchOneEvent = async (event_id: number) => { | ||
const response: AxiosResponse<EventType> = await axiosInstance.get( | ||
`/event/${ event_id }`, | ||
) | ||
|
||
return response | ||
} | ||
|
||
export const createEvent = async (event: EventType) => { | ||
const response: AxiosResponse<EventType> = await axiosInstance.post( | ||
`/event`, | ||
{ ...event }, | ||
) | ||
|
||
return response | ||
} | ||
|
||
export const updateEvent = async (event: EventType, event_id: number) => { | ||
const response: AxiosResponse<EventType> = await axiosInstance.put( | ||
`/event/${ event_id }`, | ||
{ ...event }, | ||
) | ||
|
||
return response | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export type EventType = { | ||
id?: number; | ||
name: string; | ||
desc: string; | ||
text?: string; | ||
keyboard?: string; | ||
state?: string; | ||
type: string; | ||
} | ||
|
||
export type EventTriggerType = { | ||
id?: number; | ||
event_id?: number; | ||
name: string; | ||
desc?: string; | ||
condition_attr?: string; | ||
condition?: string; | ||
condition_value?: number; | ||
condition_item?: number; | ||
chance?: number; | ||
trigger_type?: string; | ||
text?: string; | ||
reward?: string; | ||
mandatory?: boolean; | ||
hidden?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { GridColDef } from "@mui/x-data-grid"; | ||
import { Link } from "react-router-dom"; | ||
import { pathRoutes } from "@/app"; | ||
|
||
export const EventColumn: GridColDef[] = [ | ||
{ field: 'id', minWidth: 60, maxWidth: 60 }, | ||
{ | ||
field: 'name', minWidth: 180, flex: 1, renderCell: ({ row, formattedValue }) => { | ||
return <Link to={ `${ pathRoutes.event.edit }/${ row.id }` } className='td_underline'>{ formattedValue }</Link> | ||
} | ||
}, | ||
{ field: 'desc', minWidth: 180, flex: 1 }, | ||
{ field: 'text', minWidth: 180, flex: 1 }, | ||
{ field: 'type', minWidth: 120 }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { EffectConstants } from "@/widgets"; | ||
|
||
export const EventConstants = { | ||
type: [ | ||
{ value: 'quest', label: 'Квест' }, | ||
{ value: 'battle', label: 'Сражение' }, | ||
{ value: 'boss', label: 'Босс' }, | ||
], | ||
trigger_type: [ | ||
{ value: 'start', label: 'Условие начала' }, | ||
{ value: 'condition', label: 'Условие выполнения' }, | ||
], | ||
attribute: [ | ||
{ value: 'race_id', label: 'Раса (По id)' }, | ||
{ value: 'class_id', label: 'Класс (По id)' }, | ||
|
||
{ value: 'mana_view', label: 'Мана:', disabled: true }, | ||
...EffectConstants.attribute, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { boolean, number, object, string } from "yup"; | ||
|
||
export const EventCreateScheme = object().shape({ | ||
name: string().required('Введите название'), | ||
desc: string().required('Введите описание'), | ||
text: string().optional(), | ||
keyboard: string().nullable(), | ||
state: string().nullable(), | ||
type: string().required('Выберите тип'), | ||
}) | ||
|
||
export const EventTriggerCreateScheme = object().shape({ | ||
name: string().required('Введите название'), | ||
desc: string().required('Введите описание'), | ||
condition_attr: string().optional(), | ||
condition: string().optional(), | ||
condition_value: number().optional(), | ||
condition_item: number().optional(), | ||
chance: number().optional(), | ||
trigger_type: string().required('Выберите тип'), | ||
text: string().optional(), | ||
reward: string().optional(), | ||
mandatory: boolean().default(false), | ||
hidden: boolean().default(false), | ||
}) |
Oops, something went wrong.