Skip to content

Commit

Permalink
Merge pull request #109 from LamArt/dev
Browse files Browse the repository at this point in the history
Release 0.6.0 + 1.0.0
  • Loading branch information
zavarin-michael authored Mar 18, 2024
2 parents e60b7cf + 05b9f0e commit 12cd3a7
Show file tree
Hide file tree
Showing 148 changed files with 1,735 additions and 5,868 deletions.
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Getting started

> **Node should be > 16.** You can check node version using `node -v` command in your terminal.
> **Node should be > 16.14.0** You can check node version using `node -v` command in your terminal.
> **You need a raised [backend](https://github.com/LamArt/open-schools-platform/tree/dev) server nearby**
Expand Down
14 changes: 8 additions & 6 deletions apps/schools/domains/circle/components/circleList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export function CircleList() {
const [searchRequestText, setSearchRequestText] = useState('')
const { organizationId } = useOrganization()

const { data: circles, isLoading: isLoading } = useGetAllCirclesQuery({
organization_id: organizationId,
or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns),
})
const { data: circles, isFetching: isFetching } = useGetAllCirclesQuery(
{
organization_id: organizationId,
or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns),
},
)

const reformattedData = mapReturnedData(circles, (circle) => {
const transformedCircle = structuredClone(circle) as unknown as TableType
Expand All @@ -36,7 +38,7 @@ export function CircleList() {
buttonText={'Добавить кружок'}
pageTitle={'Кружки'}
data={circles}
isLoading={isLoading}
isLoading={isFetching}
handleRunTask={() => router.push('/circle/create')}
searchTrigger={searchRequestText}
>
Expand All @@ -58,7 +60,7 @@ export function CircleList() {
['Кол-во принятых заявок', 'accepted_count'],
]}
data={reformattedData}
isLoading={isLoading}
isLoading={isFetching}
mainRoute={'/circle'}
searchFields={['name', 'address']}
customFields={{
Expand Down
33 changes: 27 additions & 6 deletions apps/schools/domains/circle/components/currentCircle/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import router from 'next/router'
import { Col, Row, Typography } from 'antd'
import Image from 'next/image'
Expand All @@ -23,15 +23,18 @@ 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 { ErrorType } from '@store/commonApi'

const CurrentCircle = () => {
const [isModalVisible, setIsModalVisible] = useState(false)
const [searchRequestText, setSearchRequestText] = useState('')
const [mutation] = useDeleteCircleMutation()
const [mutation, isDeleteFinished] = useDeleteCircleMutation()
const uuid = getUuidFromUrl()

const { organizationId } = useOrganization()

const { data: circle } = useGetCircleQuery({ circle_id: uuid[0] })
const { data: circle, error: circleError } = useGetCircleQuery({ circle_id: uuid[0] })
const { data: students, isLoading } = useGetCircleStudentsQuery({
circle_id: uuid[0],
or_search: createSearchTextForRequest(searchRequestText, searchColumns),
Expand Down Expand Up @@ -59,6 +62,15 @@ const CurrentCircle = () => {
const countAllQueries = sumObjectValues(queriesCount)
const addressVars = getVarsForAddressColumn(circle?.circle.address ?? '')

useEffect(() => {
if (circleError && (circleError as ErrorType).status == 404) {
router.push('/circle')
}
}, [circleError])

if (isDeleteFinished.isSuccess) return null
if (uuid.length === 0) router.push('/404')

return (
<>
<Typography.Title className={styles.name} level={1}>
Expand All @@ -71,21 +83,30 @@ const CurrentCircle = () => {
<Row className={styles.Row}>
<div>Всего</div>
<span></span>
<Link href={'/profile'} className={styles.colorCountAllQueries}>
<Link
href={`/query?circles=${circle?.circle.name ?? ''}`}
className={styles.colorCountAllQueries}
>
{countAllQueries}
</Link>
</Row>
<Row className={styles.Row}>
<div>Принято</div>
<span></span>
<Link href={'/profile'} className={styles.colorCountAcceptedQueries}>
<Link
href={`/query?statuses=${QueryStatuses.ACCEPTED}&circles=${circle?.circle.name}`}
className={styles.colorCountAcceptedQueries}
>
{queriesCount.ACCEPTED}
</Link>
</Row>
<Row className={styles.Row}>
<div>На рассмотрении</div>
<span></span>
<Link href={'/profile'} className={styles.colorCountInProgressQueries}>
<Link
href={`/query?statuses=${QueryStatuses.IN_PROGRESS}&circles=${circle?.circle.name}`}
className={styles.colorCountInProgressQueries}
>
{queriesCount.IN_PROGRESS}
</Link>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
}

.colorCountAllQueries {
color: #4CD174

}

.colorCountInProgressQueries {
color: #2698FF
}

.colorCountAcceptedQueries {
color: #4CD174
}
}

.Row span {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useOrganization } from '@domains/organization/providers/organizationPro
import { getUuidFromUrl } from '@domains/common/utils/getUuidFromUrl'
import { mapSteps } from '@domains/circle/interfaces/mapStepsType'
import { FormMapSteps } from '@domains/circle/constants/Enums'
import router from 'next/router'

interface MapComponentProps {
mode: 'Change' | 'Create'
Expand Down Expand Up @@ -174,11 +175,11 @@ const ConfirmMap = (props: MapComponentProps) => {
onClick={() => {
if (mode === 'Create') {
handleSubmitCreateForm(organizationId, mainForm, mutation).then((isSucceed) => {
if (isSucceed) window.location.href = '/circle'
if (isSucceed) router.push('/circle')
})
} else if (mode === 'Change') {
handleSubmitUpdateForm(circleId, mainForm, mutation).then((isSucceed) => {
if (isSucceed) window.location.href = `/circle/${circleId}`
if (isSucceed) router.push(`/circle/${circleId}`)
})
}
}}
Expand Down
10 changes: 8 additions & 2 deletions apps/schools/domains/circle/redux/circleApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { commonApi } from '@store/commonApi'
import { commonApi, providesList } from '@store/commonApi'
import { ReturnedData } from '../../common/redux/interfaces'
import {
AllCirclesData,
Expand All @@ -18,52 +18,58 @@ const circleApi = commonApi.injectEndpoints({
method: 'GET',
params: params,
}),
providesTags: (result) => providesList(result?.results, 'Circle' ),
}),
createCircle: build.mutation<{ circle: GetCircle }, CreateCircleData>({
query: (data) => ({
url: '/organization-management/circles',
method: 'POST',
body: data,
}),
invalidatesTags: [{ type: 'Circle', id: 'LIST' }],
}),
changeCircle: build.mutation<{ circle: GetCircle }, ChangeCircleData>({
query: (data) => ({
url: `/organization-management/circles/${data.circle_id}`,
method: 'PATCH',
body: data,
}),
invalidatesTags: (result, error, arg) => [{ type: 'Circle', id: arg.circle_id }],
}),
getCircle: build.query<{ circle: GetCircle }, CircleData>({
query: (params) => ({
url: `/organization-management/circles/${params.circle_id}`,
method: 'GET',
}),
providesTags: (result, error, arg) => [{ type: 'Circle', id: arg.circle_id }],
}),
getCircleStudents: build.query<ReturnedData<GetStudent[]>, CircleStudentsData>({
query: (params) => ({
url: `/organization-management/circles/${params.circle_id}/students`,
method: 'GET',
params: params,
}),
providesTags: (result, error, arg) => [{ type: 'Circle', id: arg.circle_id }],
}),
deleteCircle: build.mutation<{ circle: GetCircle }, CircleData>({
query: (params) => ({
url: `/organization-management/circles/${params.circle_id}`,
method: 'DELETE',
}),
invalidatesTags: [{ type: 'Circle', id: 'LIST' }],
}),
inviteStudent: build.mutation<{ query: GetQueryStatus }, CreateCircleInviteStudentData>({
query: (body) => ({
url: `/organization-management/circles/${body.circle_id}/invite-student`,
method: 'POST',
body: body,
}),
invalidatesTags: (result, error, arg) => [{ type: 'Circle', id: arg.circle_id }, { type: 'Student', id: 'LIST' }],
}),
}),
})

export const {
useGetAllCirclesQuery,
useGetCircleStudentsQuery,
useCreateCircleMutation,
useGetCircleQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import styles from './styles/styles.module.scss'
import React from 'react'
import { useRouter } from 'next/router'
import { MenuItemObj } from '../classes'
import { UserOutlined } from '@ant-design/icons'
import { LogoutOutlined, UserOutlined } from '@ant-design/icons'
import { Menu } from 'antd'

const menuList: MenuItemObj[] = [new MenuItemObj('user', 'Профиль', <UserOutlined style={{ fontSize: '150%' }} />, [])]
const menuList: MenuItemObj[] = [
new MenuItemObj('user', 'Профиль', <UserOutlined style={{ fontSize: '150%' }} />, []),
new MenuItemObj('logout', 'Выход', <LogoutOutlined style={{ fontSize: '150%' }} />, []),
]

const UserProfile = () => {
const router = useRouter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
.menu {
padding-top: 10px;
border: 0;
display: flex;
margin-top: auto;

:global {
.ant-menu-item-selected {

color: $color-black;
background-color: white !important;
font-family: "Roboto";
font-family: "Roboto", sans-serif;
font-size: 16px;
font-style: normal;
font-weight: 600;
Expand All @@ -24,7 +23,7 @@
.ant-menu-item:hover {

color: $color-black;
font-family: "Roboto";
font-family: "Roboto", sans-serif;
font-size: 16px;
font-style: normal;
font-weight: 600;
Expand All @@ -41,7 +40,7 @@

.menuItem {
color: $color-unselected-item;
font-family: "Roboto";
font-family: "Roboto", sans-serif;
display: flex;
width: 160px;
height: 40px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
font-style: normal;
font-weight: 600;
line-height: 28px;
max-width: 700px;
letter-spacing: -1.5px;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
}

.deleteButton {
width: 160px;
width: auto;
padding: 7px;
}
}
33 changes: 33 additions & 0 deletions apps/schools/domains/common/components/field/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import styles from './styles/styles.module.scss'
import { Col, Row } from 'antd'
import React from 'react'
import { FieldProps } from './interface'

export const Field = (props: FieldProps) => {
const { fieldName, fieldValue = undefined, defaultValue, type = 'right' } = props

let lgxs

if (type === 'left') {
lgxs = 14
} else if (type === 'center') {
lgxs = 12
} else {
lgxs = 10
}

if (!fieldValue && !defaultValue) {
return null
}

return (
<Row gutter={[0, 24]} className={styles.itemContainer}>
<Col className={styles.fieldName} lg={lgxs} xs={lgxs}>
{fieldName}
</Col>
<Col className={styles.fieldValue} lg={24 - lgxs} xs={24 - lgxs}>
{fieldValue || defaultValue}
</Col>
</Row>
)
}
6 changes: 6 additions & 0 deletions apps/schools/domains/common/components/field/interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface FieldProps {
fieldName: string
fieldValue?: string
defaultValue?: string
type?: 'left' | 'center' | 'right'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@import '@domains/common/components/styles/abstracts/_colors.scss';


.itemContainer {
margin-bottom: 30px;

.fieldName {
color: $color-field-name;

font-family: "Open Sans", sans-serif;
font-size: 20px;
font-style: normal;
font-weight: 600;
line-height: 130%;
}

.fieldValue {
color: $color-field-value;

font-family: "Open Sans", sans-serif;
font-size: 20px;
font-style: normal;
font-weight: 600;
line-height: 130%;
}
}
10 changes: 9 additions & 1 deletion apps/schools/domains/common/components/input/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Input as BaseInput } from 'antd'
import React from 'react'
import React, { useEffect, useState } from 'react'
import defaultStyles from './styles/default.module.scss'
import PhoneInput from 'react-phone-input-2'
import 'react-phone-input-2/lib/style.css'
Expand Down Expand Up @@ -30,9 +30,16 @@ export const Input: React.FC<CustomInputProps> = (props) => {
className,
children,
inputContainerClass,
valueName,
...restProps
} = props

const [phoneValue, setPhoneValue] = useState('')

useEffect(() => {
setPhoneValue(localStorage.getItem(typeof valueName === 'string' ? valueName : '') ?? '+7')
}, [valueName])

if (!typeInput.includes(customType)) {
return (
<div className={classNames(defaultStyles.inputContainer, inputContainerClass)}>
Expand Down Expand Up @@ -63,6 +70,7 @@ export const Input: React.FC<CustomInputProps> = (props) => {
buttonStyle={BUTTON_INPUT_PHONE_STYLE}
inputStyle={INPUT_PHONE_STYLE}
containerStyle={{ marginTop: '8px' }}
value={phoneValue}
/>
{children}
</div>
Expand Down
Loading

0 comments on commit 12cd3a7

Please sign in to comment.