generated from 8iq/nodejs-hackathon-boilerplate-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from LamArt/feature/SCHOOL-726/circle-page
circle page
- Loading branch information
Showing
15 changed files
with
263 additions
and
8 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
apps/schools/domains/circle/components/studentList/constants.ts
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 @@ | ||
export const searchStudentsColumns = ['name', 'address'] |
86 changes: 86 additions & 0 deletions
86
apps/schools/domains/circle/components/studentList/index.tsx
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,86 @@ | ||
import React, { useState } from 'react' | ||
import { Typography } from 'antd' | ||
import router from 'next/router' | ||
import styles from './styles/styles.module.scss' | ||
import { useOrganization } from '@domains/organization/providers/organizationProvider' | ||
import { Button } from '@domains/common/components/button' | ||
import { Table } from '@domains/common/components/table' | ||
import { createSearchTextForRequest } from '@domains/common/utils/searchText' | ||
import { RowType, TableType } from './interfaces' | ||
import { searchStudentsColumns } from './constants' | ||
import { useGetAllCirclesQuery } from '@domains/organization/redux/organizationApi' | ||
import EmptyWrapper from '@domains/common/components/containers/EmptyWrapper' | ||
import { mapReturnedData } from '@domains/common/redux/utils' | ||
import { HighlightText } from '@domains/common/components/table/forming' | ||
import { getVarsForAddressColumn } from '@domains/student/components/studentList/utils' | ||
|
||
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 reformattedData = mapReturnedData(circles, (circle) => { | ||
const transformedCircle = structuredClone(circle) as TableType | ||
transformedCircle.accepted_count = circle.student_profile_queries.ACCEPTED | ||
return transformedCircle | ||
}) | ||
|
||
return ( | ||
<EmptyWrapper | ||
titleText={'Список кружков пока пуст'} | ||
descriptionText={'Вы можете добавить их, нажав на кнопку'} | ||
buttonText={'Добавить кружок'} | ||
pageTitle={'Кружки'} | ||
data={circles} | ||
isLoading={isLoading} | ||
handleRunTask={() => router.push('/circle/create')} | ||
searchTrigger={searchRequestText} | ||
> | ||
<div className={styles.header}> | ||
<Typography.Title level={1}>Кружки</Typography.Title> | ||
<Button | ||
type='schoolDefault' | ||
block | ||
className={styles.button} | ||
onClick={() => router.push('/circle/create')} | ||
> | ||
Добавить кружок | ||
</Button> | ||
</div> | ||
<Table<RowType, TableType> | ||
columnsTitlesAndKeys={[ | ||
['Название', 'name'], | ||
['Адрес', 'address'], | ||
['Кол-во принятых заявок', 'accepted_count'], | ||
]} | ||
data={reformattedData} | ||
isLoading={isLoading} | ||
mainRoute={'/student'} | ||
searchFields={['name', 'address']} | ||
customFields={{ | ||
address: ({ text, searchText }) => { | ||
const [address, additional_text] = getVarsForAddressColumn(text ?? '') | ||
|
||
return ( | ||
<div> | ||
<div className={styles.additionalTextAddress}> | ||
<HighlightText text={additional_text ?? ''} searchText={searchText} /> | ||
</div> | ||
|
||
<div className={styles.textAddress}> | ||
<HighlightText text={address ?? ''} searchText={searchText} /> | ||
</div> | ||
</div> | ||
) | ||
}, | ||
}} | ||
searchRequestText={searchRequestText} | ||
setSearchRequestText={setSearchRequestText} | ||
/> | ||
</EmptyWrapper> | ||
) | ||
} |
13 changes: 13 additions & 0 deletions
13
apps/schools/domains/circle/components/studentList/interfaces.ts
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,13 @@ | ||
export interface RowType { | ||
id?: string | ||
name: string | ||
address: string | ||
accepted_count: number | ||
} | ||
|
||
export interface TableType { | ||
id?: string | ||
name: string | ||
address: string | ||
accepted_count: number | ||
} |
62 changes: 62 additions & 0 deletions
62
apps/schools/domains/circle/components/studentList/styles/styles.module.scss
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,62 @@ | ||
@import '../../../../common/components/styles/abstracts/common'; | ||
|
||
.tableContainer { | ||
@extend %table; | ||
} | ||
|
||
.header { | ||
margin-bottom: 31px; | ||
align-items: center; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
|
||
.button { | ||
min-width: 200px; | ||
text-align: center; | ||
font-family: 'Roboto', sans-serif; | ||
font-size: 16px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 24px; | ||
width: 14%; | ||
} | ||
} | ||
|
||
.search { | ||
font-size: 150%; | ||
position: absolute; | ||
right: 30px; | ||
} | ||
|
||
.cross { | ||
font-size: 100%; | ||
position: absolute; | ||
right: 60px; | ||
|
||
:hover { | ||
opacity: .6; | ||
} | ||
|
||
:active, :focus { | ||
opacity: .8; | ||
} | ||
} | ||
|
||
.additionalTextAddress { | ||
color: $color-background; | ||
font-family: 'Roboto', sans-serif; | ||
font-size: 16px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 22px; | ||
} | ||
|
||
.textAddress { | ||
color: $color-foreground; | ||
font-family: 'Roboto', sans-serif; | ||
font-size: 14px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 22px; | ||
} |
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
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,12 @@ | ||
import { ReturnedData } from '@domains/common/redux/interfaces' | ||
|
||
export function mapReturnedData<T>(response: ReturnedData<T[]> | undefined, delegate: (x: T) => any) { | ||
return response !== undefined | ||
? ({ | ||
count: response.count, | ||
next: response.next, | ||
previous: response.previous, | ||
results: response.results.map(delegate), | ||
} as ReturnedData<any>) | ||
: undefined | ||
} |
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
2 changes: 2 additions & 0 deletions
2
apps/schools/domains/student/components/studentList/constants.ts
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export const searchInvitesColumns = ['student__name', 'student_profile__phone', 'family__parent_phone', 'circle__name'] | ||
export const searchStudentsColumns = ['name', 'student_profile__phone', 'parent_phone', 'circle__name'] | ||
|
||
export const ADDRESS_SEPARATOR = '&;' |
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,5 @@ | ||
import { ADDRESS_SEPARATOR } from '@domains/student/components/studentList/constants' | ||
|
||
export function getVarsForAddressColumn(text: string) { | ||
return text.split(ADDRESS_SEPARATOR) | ||
} |
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 React from 'react' | ||
import Head from 'next/head' | ||
import { PageContent } from '@domains/common/components/containers/PageContent' | ||
|
||
import { | ||
OrganizationRequired, | ||
} from '@domains/common/components/containers/OrganizationRequired' | ||
import {CircleList} from "@domains/circle/components/studentList"; | ||
|
||
const CirclesPageContent = () => { | ||
return ( | ||
<> | ||
<Head> | ||
<title>Кружки</title> | ||
</Head> | ||
<PageContent> | ||
<OrganizationRequired> | ||
<CircleList/> | ||
</OrganizationRequired> | ||
</PageContent> | ||
</> | ||
) | ||
} | ||
|
||
export default CirclesPageContent |