Skip to content

Commit

Permalink
Merge pull request #125 from open-schools/feature/SCHOOL-819/family-t…
Browse files Browse the repository at this point in the history
…ickets-list

add tickets list page
  • Loading branch information
zavarin-michael authored Apr 26, 2024
2 parents b1821d3 + 691d867 commit 4d7f4b8
Show file tree
Hide file tree
Showing 19 changed files with 416 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import router, { useRouter } from 'next/router'
import { useRouter } from 'next/router'
import { Col, Row, Typography } from 'antd'
import Image from 'next/image'
import Link from 'next/link'
Expand All @@ -23,7 +23,7 @@ import { searchColumns } from './constants'
import { CurrentCircleRowType } from './interfaces'
import styles from './styles/styles.module.scss'
import { getVarsForAddressColumn } from '@domains/common/utils/geo'
import { QueryStatuses } from '@domains/common/constants/Enums'
import { StatusesEnum } from '@domains/common/constants/Enums'
import { ErrorType } from '@store/commonApi'
import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums'

Expand Down Expand Up @@ -98,7 +98,7 @@ const CurrentCircle = () => {
<div>Принято</div>
<span></span>
<Link
href={`/query?statuses=${QueryStatuses.ACCEPTED}&circles=${circle?.circle.name}${backQuery}`}
href={`/query?statuses=${StatusesEnum.ACCEPTED}&circles=${circle?.circle.name}${backQuery}`}
className={styles.colorCountAcceptedQueries}
>
{queriesCount.ACCEPTED}
Expand All @@ -108,7 +108,7 @@ const CurrentCircle = () => {
<div>На рассмотрении</div>
<span></span>
<Link
href={`/query?statuses=${QueryStatuses.IN_PROGRESS}&circles=${circle?.circle.name}${backQuery}`}
href={`/query?statuses=${StatusesEnum.IN_PROGRESS}&circles=${circle?.circle.name}${backQuery}`}
className={styles.colorCountInProgressQueries}
>
{queriesCount.IN_PROGRESS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
align-items: center;
margin-bottom: 20px;
gap: 10px;
cursor: pointer;

.text {
font-family: "Open Sans", sans-serif;
Expand All @@ -22,6 +21,7 @@
padding: 7px 10px 7px 5px;
border: 1px solid #D9D9D9;
border-radius: 20px;
cursor: pointer;

&:hover {
background-color: #f1f1f1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IBaseLayoutProps } from './interfaces'
import { OrganizationSelect } from '../OrganizationSelect'
import { useLayoutContext } from '@domains/user/providers/baseLayoutProvider'
import { COLLAPSED_DIVIDER_WIDTH, COLLAPSED_LAYOUT_WIDTH, DIVIDER_WIDTH, LAYOUT_WIDTH } from './styles/styles'
import { QueryStatuses } from '@domains/common/constants/Enums'
import { StatusesEnum } from '@domains/common/constants/Enums'
import Image from 'next/image'
import ExclamationCircleOutlined from '@public/icons/ExclamationCircleOutlined.svg'
import { Button } from '@domains/common/components/button'
Expand All @@ -36,7 +36,7 @@ export const BaseLayout: React.FC<IBaseLayoutProps> = (props) => {
<Layout className={styles.placement}>
<div className={styles.invitationsContainer}>
{invitations?.results.map((invite) => {
if (invite.status === QueryStatuses.SENT || invite.status === QueryStatuses.IN_PROGRESS) {
if (invite.status === StatusesEnum.SENT || invite.status === StatusesEnum.IN_PROGRESS) {
return (
<div className={styles.inviteContainer} key={invite.id}>
<div className={styles.leftContainer}>
Expand All @@ -50,7 +50,7 @@ export const BaseLayout: React.FC<IBaseLayoutProps> = (props) => {
handleChangeStatusInvitation(
mutation,
invite.id,
QueryStatuses.ACCEPTED,
StatusesEnum.ACCEPTED,
).then(() => {
refetch()
emit(EventKey.RefetchOrganizationsQuery)
Expand All @@ -65,7 +65,7 @@ export const BaseLayout: React.FC<IBaseLayoutProps> = (props) => {
handleChangeStatusInvitation(
mutation,
invite.id,
QueryStatuses.DECLINED,
StatusesEnum.DECLINED,
).then(refetch)
}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Menu } from 'antd'
import { FileDoneOutlined, ReadOutlined, TeamOutlined, UserAddOutlined } from '@ant-design/icons'
import { FileDoneOutlined, MailOutlined, ReadOutlined, TeamOutlined, UserAddOutlined } from '@ant-design/icons'
import React, { useEffect, useState } from 'react'
import { useRouter } from 'next/router'
import styles from './styles/styles.module.scss'
Expand All @@ -15,6 +15,7 @@ const menuList: MenuItemObj[] = [
new MenuItemObj('employee', 'Сотрудники', <UserAddOutlined style={{ fontSize: '150%' }} />, [
isOrganizationSelected,
]),
new MenuItemObj('ticket', 'Обращения', <MailOutlined style={{ fontSize: '150%' }} />, [isOrganizationSelected]),
]

const MenuCustom = () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/schools/domains/common/constants/Enums.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum QueryStatuses {
export enum StatusesEnum {
SENT = 'SENT',
ACCEPTED = 'ACCEPTED',
IN_PROGRESS = 'IN_PROGRESS',
Expand Down
2 changes: 2 additions & 0 deletions apps/schools/domains/common/constants/routerEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const enum AppRoutes {
EMPLOYEE_CREATE = 'employee_create',
MAIN = 'main',
MOBILE_RECAPTCHA = 'mobile_recaptcha',
TICKETS_LIST = 'tickets_list',
NOT_FOUND = 'not_found',
QUERY_LIST = 'query_list',
STUDENT_LIST = 'student_list',
Expand All @@ -28,6 +29,7 @@ export const RoutePath: Record<AppRoutes, string> = {
[AppRoutes.EMPLOYEE_CREATE]: '/employee/create',
[AppRoutes.MAIN]: '/',
[AppRoutes.MOBILE_RECAPTCHA]: '/mobile-recaptcha',
[AppRoutes.TICKETS_LIST]: '/ticket',
[AppRoutes.NOT_FOUND]: '/404',
[AppRoutes.QUERY_LIST]: '/query',
[AppRoutes.STUDENT_LIST]: '/student',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withLoadingMessage } from '@domains/common/utils/loading'
import { LoadingMsg } from '@domains/user/components/auth/constants/message'
import { message } from 'antd'
import { QueriesTypes } from '@domains/common/redux/interfaces'
import { QueryStatuses } from '@domains/common/constants/Enums'
import { StatusesEnum } from '@domains/common/constants/Enums'

export async function handleChangeStatusInvitation(mutation: any, id: string | undefined, status: QueriesTypes) {
if (id === undefined) {
Expand All @@ -16,7 +16,7 @@ export async function handleChangeStatusInvitation(mutation: any, id: string | u
})

if ('data' in response)
status === QueryStatuses.ACCEPTED
status === StatusesEnum.ACCEPTED
? message.success(`Вы успешно приняли заявку`)
: message.success(`Вы успешно отклонили заявку`)
}
16 changes: 16 additions & 0 deletions apps/schools/domains/common/redux/serializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ export interface GetAnalytics {
CANCELED: number
}

export interface GetTicketAnalytics {
'ticket-analytics': {
IN_PROGRESS: number
SENT: number
ACCEPTED: number
DECLINED: number
CANCELED: number
}
}

export interface GetQueryStatus {
id?: string
status: QueriesTypes
Expand Down Expand Up @@ -189,6 +199,12 @@ export interface GetFamily {
name: string
}

export interface GetAnalyticsData {
date_from?: string
date_to?: string
organization_id: string
}

export interface GetFamilyRecipient {
id?: string
name: string
Expand Down
6 changes: 0 additions & 6 deletions apps/schools/domains/organization/redux/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ export interface AllStudentJoinCircleQueriesData extends BasePaginationData {
student__student_profile__phone?: string
}

export interface GetOrganizationAnalyticsData {
date_from?: string
date_to?: string
organization_id: string
}

export interface GetOrganizationCircleList {
id: string
name: string
Expand Down
21 changes: 19 additions & 2 deletions apps/schools/domains/organization/redux/organizationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import {
GetOrganizationCircleListData,
GetCurrentCircleData,
AllStudentJoinCircleQueriesData,
GetOrganizationAnalyticsData,
} from './interfaces'
import { GetEmployee } from '../../employee/redux/interfaces'
import {
CreateOrganizationInviteEmployee,
GetAnalytics,
GetAnalyticsData,
GetCircleInviteStudent,
GetOrganizationInviteEmployee,
GetOrganizationSender,
Expand All @@ -32,6 +32,7 @@ import {
GetTeacher,
UpdateOrganizationInviteEmployee,
} from '@domains/common/redux/serializers'
import { GetTicket, GetTicketsData } from '@domains/ticket/redux/serializers'

const organizationApi = commonApi.injectEndpoints({
endpoints: (build) => ({
Expand Down Expand Up @@ -166,14 +167,28 @@ const organizationApi = commonApi.injectEndpoints({
}),
providesTags: (result) => providesList(result?.results, 'StudentJoinCircleQuery'),
}),
getOrganizationAnalytics: build.query<{ analytics: GetAnalytics }, GetOrganizationAnalyticsData>({
getOrganizationAnalytics: build.query<{ analytics: GetAnalytics }, GetAnalyticsData>({
query: (params) => ({
url: `/organization-management/organizations/${params.organization_id}/analytics`,
method: 'GET',
params: params,
}),
providesTags: ['StudentJoinCircleQuery'],
}),
getTicketsAnalytics: build.query<{ 'ticket-analytics': GetAnalytics }, GetAnalyticsData>({
query: (params) => ({
url: `/organization-management/organizations/${params.organization_id}/ticket-analytics`,
method: 'GET',
params: params,
}),
}),
getAllTickets: build.query<ReturnedData<GetTicket[]>, GetTicketsData>({
query: (params) => ({
url: `/organization-management/organizations/${params.organization_id}/family-tickets`,
method: 'GET',
params: params,
}),
}),
}),
})

Expand All @@ -197,4 +212,6 @@ export const {
useGetAllCirclesQuery,
useGetAllJoinCircleQueriesQuery,
useGetOrganizationAnalyticsQuery,
useGetTicketsAnalyticsQuery,
useGetAllTicketsQuery,
} = organizationApi
12 changes: 6 additions & 6 deletions apps/schools/domains/query/components/queryList/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueryStatuses } from '@domains/common/constants/Enums'
import { StatusesEnum } from '@domains/common/constants/Enums'
import {
ACCEPTED_FILTER_COLOR,
CANCELED_FILTER_COLOR,
Expand All @@ -23,9 +23,9 @@ interface TagType {
}

export const StatusDictionary: { [key: string]: TagType } = {
[QueryStatuses.SENT]: { text: 'Отправлено', color: SENT_FILTER_COLOR, antdColor: 'gold' },
[QueryStatuses.IN_PROGRESS]: { text: 'На рассмотрении', color: IN_PROGRESS_FILTER_COLOR, antdColor: 'blue' },
[QueryStatuses.ACCEPTED]: { text: 'Принято', color: ACCEPTED_FILTER_COLOR, antdColor: 'green' },
[QueryStatuses.CANCELED]: { text: 'Отменено', color: CANCELED_FILTER_COLOR, antdColor: 'volcano' },
[QueryStatuses.DECLINED]: { text: 'Отклонено', color: DECLINED_FILTER_COLOR, antdColor: 'red' },
[StatusesEnum.SENT]: { text: 'Отправлено', color: SENT_FILTER_COLOR, antdColor: 'gold' },
[StatusesEnum.IN_PROGRESS]: { text: 'На рассмотрении', color: IN_PROGRESS_FILTER_COLOR, antdColor: 'blue' },
[StatusesEnum.ACCEPTED]: { text: 'Принято', color: ACCEPTED_FILTER_COLOR, antdColor: 'green' },
[StatusesEnum.CANCELED]: { text: 'Отменено', color: CANCELED_FILTER_COLOR, antdColor: 'volcano' },
[StatusesEnum.DECLINED]: { text: 'Отклонено', color: DECLINED_FILTER_COLOR, antdColor: 'red' },
}
4 changes: 2 additions & 2 deletions apps/schools/domains/student/components/studentList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createSearchTextForRequest } from '@domains/common/utils/searchText'
import { RowType, TableType } from './interfaces'
import { searchInvitesColumns, searchStudentsColumns } from './constants'
import { useGetAllStudentInvitationsQuery, useGetAllStudentsQuery } from '@domains/organization/redux/organizationApi'
import { QueryStatuses } from '@domains/common/constants/Enums'
import { StatusesEnum } from '@domains/common/constants/Enums'
import EmptyWrapper from '@domains/common/components/containers/EmptyWrapper'
import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums'

Expand All @@ -19,7 +19,7 @@ export function StudentList() {

const { data: invites, isLoading: isLoadingInvites } = useGetAllStudentInvitationsQuery({
circle__organization__id: organizationId,
status: QueryStatuses.SENT,
status: StatusesEnum.SENT,
or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns),
})

Expand Down
18 changes: 18 additions & 0 deletions apps/schools/domains/ticket/components/ticketList/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { StatusesEnum } from '@domains/common/constants/Enums'
import type { LiteralUnion } from 'antd/lib/_util/type'
import type { PresetColorType, PresetStatusColorType } from 'antd/lib/_util/colors'
import { CANCELED_FILTER_COLOR, IN_PROGRESS_FILTER_COLOR, SENT_FILTER_COLOR } from './styles/styles'

export const searchTicketsColumns = ['family__name', 'ticket_comment__value']

interface TagType {
text: string
color: string
antdColor: LiteralUnion<PresetColorType | PresetStatusColorType, string>
}

export const StatusDictionary: { [key: string]: TagType } = {
[StatusesEnum.SENT]: { text: 'Новое', color: SENT_FILTER_COLOR, antdColor: 'red' },
[StatusesEnum.IN_PROGRESS]: { text: 'Открыто', color: IN_PROGRESS_FILTER_COLOR, antdColor: 'blue' },
[StatusesEnum.CANCELED]: { text: 'Закрыто', color: CANCELED_FILTER_COLOR, antdColor: 'green' },
}
Loading

0 comments on commit 4d7f4b8

Please sign in to comment.