Skip to content

Commit d0e1a1f

Browse files
feat: added adaptivity in crm dashboard header and filters panel
1 parent be6139b commit d0e1a1f

File tree

29 files changed

+323
-31
lines changed

29 files changed

+323
-31
lines changed

public/crm_filter_icon.svg

Lines changed: 10 additions & 0 deletions
Loading

src/app/(crm)/crm/dashboard/layout.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
&Container {
1414
max-width: 800px;
1515
width: 90%;
16-
height: 98%;
16+
flex: 1;
1717
display: flex;
1818
flex-direction: column;
1919
align-items: center;

src/app/(website)/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export default function Home() {
22
return <></>;
33
}
4-
// export const runtime = 'nodejs';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
'use client';
2+
import Drawer from '@mui/material/Drawer';
3+
import React, { useState } from 'react';
4+
import { useSession } from 'next-auth/react';
5+
import { userState } from '@/shared/state/user/state';
6+
import { observer } from 'mobx-react-lite';
7+
import s from './style.module.scss';
8+
import { DrawerCloseButton } from './ui/CloseButton';
9+
import { crmDraweFilterState } from '../../shared/state/crmDrawerFilterComponent/CRMDrawerFilterComponentState';
10+
11+
type CRMDrawerFilterComponentProps = {
12+
children: React.ReactElement;
13+
};
14+
export const CRMDrawerFilterComponent: React.FC<CRMDrawerFilterComponentProps> =
15+
observer(({ children }) => {
16+
const session = useSession();
17+
18+
const handleCloseModal = () => {
19+
crmDraweFilterState.handleClose();
20+
};
21+
22+
if (!session.data?.user) {
23+
return <></>;
24+
}
25+
return (
26+
<Drawer
27+
slotProps={{
28+
paper: {
29+
style: {
30+
backgroundColor: 'black',
31+
},
32+
},
33+
}}
34+
anchor="top"
35+
open={crmDraweFilterState.open}
36+
>
37+
<div className={s.drawerContainer}>
38+
<div className={s.drawerControlsContainer}>
39+
<DrawerCloseButton handleCloseDrawer={handleCloseModal} />
40+
</div>
41+
<div className={s.drawerFiltersContainer}>{children}</div>
42+
</div>
43+
</Drawer>
44+
);
45+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
$WIDTH: 100%;
2+
3+
.drawer {
4+
&ControlsContainer {
5+
width: 100%;
6+
height: 20px;
7+
display: flex;
8+
flex-direction: row;
9+
align-items: center;
10+
justify-content: space-between;
11+
box-sizing: border-box;
12+
padding: 15px 20px;
13+
border: 1px solid rgba(white, 0.1);
14+
}
15+
&FiltersContainer {
16+
height: 100%;
17+
display: flex;
18+
justify-content: center;
19+
align-items: center;
20+
flex-direction: column;
21+
row-gap: 25px;
22+
box-sizing: border-box;
23+
padding: 15px;
24+
padding-top: 30px;
25+
color: white;
26+
border-bottom: 1px solid rgba(white, 0.1);
27+
border-right: 1px solid rgba(white, 0.1);
28+
border-left: 1px solid rgba(white, 0.1);
29+
30+
@media (max-width: 590px) {
31+
height: fit-content;
32+
}
33+
}
34+
&Container {
35+
background-color: black;
36+
width: $WIDTH;
37+
height: auto;
38+
}
39+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import s from './style.module.scss';
3+
type DrawerCloseButtonProps = {
4+
handleCloseDrawer: () => void;
5+
};
6+
export function DrawerCloseButton({
7+
handleCloseDrawer,
8+
}: DrawerCloseButtonProps) {
9+
return (
10+
<button className={s.btnContainer} onClick={handleCloseDrawer}>
11+
<div className={s.btnCross} />
12+
</button>
13+
);
14+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.btn {
2+
&Container {
3+
all: unset;
4+
height: auto;
5+
width: auto;
6+
border-radius: 8px;
7+
display: flex;
8+
flex-direction: row;
9+
align-items: center;
10+
justify-content: flex-start;
11+
box-sizing: border-box;
12+
padding: 3px;
13+
cursor: pointer;
14+
}
15+
&Cross {
16+
color: white;
17+
width: 15px;
18+
height: 15px;
19+
position: relative;
20+
&::after {
21+
content: '';
22+
position: absolute;
23+
width: 1px;
24+
height: 15px;
25+
top: 0px;
26+
left: 7px;
27+
background-color: white;
28+
transform: rotate(45deg);
29+
}
30+
&::before {
31+
content: '';
32+
position: absolute;
33+
width: 1px;
34+
height: 15px;
35+
top: 0px;
36+
left: 7px;
37+
background-color: white;
38+
transform: rotate(-45deg);
39+
}
40+
}
41+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.container {
2+
height: 68vh;
3+
width: 100%;
4+
overflow-y: scroll;
5+
@media (max-width: 590px) {
6+
height: 57vh;
7+
}
8+
@media (max-width: 400px) {
9+
flex: 1;
10+
}
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { action, makeObservable, observable } from 'mobx';
2+
3+
export class CRMDrawerFilterState {
4+
open = false;
5+
6+
constructor() {
7+
makeObservable(this, {
8+
open: observable,
9+
handleOpen: action,
10+
handleClose: action,
11+
});
12+
}
13+
handleOpen() {
14+
this.open = true;
15+
}
16+
handleClose() {
17+
this.open = false;
18+
}
19+
toggle() {
20+
this.open = !this.open;
21+
}
22+
}
23+
24+
export const crmDraweFilterState = new CRMDrawerFilterState();

src/widgets/CRMDashboard/Filters/index.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { getOrderDataSource } from '@/shared/db/orders';
1111
import { getConsultationDataSource } from '@/shared/db/consultations';
1212
import { PrintOrderEntity } from '@/entities/order';
1313
import { ConsultationEntity } from '@/entities/consultation';
14-
import { SubmitButton } from './ui/SubmitButton';
1514
import { ResetFiltersButton } from './ui/ResetFiltersButton';
15+
import { FilterLayout } from './ui/FilterLayout';
1616

1717
type OrderFilterTypes = {
1818
createdAt: Date[];
@@ -52,18 +52,24 @@ export async function Filters() {
5252
<div className={s.container}>
5353
<div className={s.border}>
5454
<div className={s.borderLabel}>Фильтры</div>
55-
<DateFilter
56-
orderData={result?.createdAt}
57-
consData={consData?.createdAt}
58-
/>
59-
<EmailFilter orderData={result?.email} consData={consData?.email} />
60-
<PhoneFilter orderData={result?.phone} consData={consData?.contact} />
61-
<MaterialFilter data={result?.plasticType} />
62-
<TypeFilter />
63-
<StatusFilter />
64-
<PaymentStatusFilter />
65-
<SubmitButton />
66-
<ResetFiltersButton />
55+
<FilterLayout>
56+
<>
57+
<DateFilter
58+
orderData={result?.createdAt}
59+
consData={consData?.createdAt}
60+
/>
61+
<EmailFilter orderData={result?.email} consData={consData?.email} />
62+
<PhoneFilter
63+
orderData={result?.phone}
64+
consData={consData?.contact}
65+
/>
66+
<MaterialFilter data={result?.plasticType} />
67+
<TypeFilter />
68+
<StatusFilter />
69+
<PaymentStatusFilter />
70+
<ResetFiltersButton />
71+
</>
72+
</FilterLayout>
6773
</div>
6874
</div>
6975
);

0 commit comments

Comments
 (0)