balibabu commited on
Commit
f372e89
·
1 Parent(s): 7ae407c

feat: Add Sider to SearchPage #2247 (#2262)

Browse files

### What problem does this PR solve?

feat: Add Sider to SearchPage #2247

### Type of change


- [x] New Feature (non-breaking change which adds functionality)

web/src/hooks/knowledge-hooks.ts CHANGED
@@ -69,7 +69,7 @@ export const useFetchKnowledgeBaseConfiguration = () => {
69
  export const useNextFetchKnowledgeList = (
70
  shouldFilterListWithoutDocument: boolean = false,
71
  ): {
72
- list: any[];
73
  loading: boolean;
74
  } => {
75
  const { data, isFetching: loading } = useQuery({
 
69
  export const useNextFetchKnowledgeList = (
70
  shouldFilterListWithoutDocument: boolean = false,
71
  ): {
72
+ list: IKnowledge[];
73
  loading: boolean;
74
  } => {
75
  const { data, isFetching: loading } = useQuery({
web/src/pages/search/index.less ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .searchSide {
2
+ overflow: auto;
3
+ height: 100vh;
4
+ position: fixed !important;
5
+ inset-inline-start: 0;
6
+ top: 0;
7
+ bottom: 0;
8
+ scrollbar-width: thin;
9
+ scrollbar-color: unset;
10
+
11
+ .checkGroup {
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+ .list {
16
+ width: 100%;
17
+ }
18
+ .checkbox {
19
+ width: 100%;
20
+ }
21
+ .knowledgeName {
22
+ width: 120px;
23
+ }
24
+ }
web/src/pages/search/index.tsx CHANGED
@@ -1,5 +1,69 @@
 
 
 
 
 
 
 
 
 
1
  const SearchPage = () => {
2
- return <div>SearchPage</div>;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  };
4
 
5
  export default SearchPage;
 
1
+ import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks';
2
+ import { Checkbox, Layout, List, Typography } from 'antd';
3
+ import React, { useCallback } from 'react';
4
+
5
+ import { CheckboxValueType } from 'antd/es/checkbox/Group';
6
+ import styles from './index.less';
7
+
8
+ const { Header, Content, Footer, Sider } = Layout;
9
+
10
  const SearchPage = () => {
11
+ const { list } = useNextFetchKnowledgeList();
12
+
13
+ const handleChange = useCallback((checkedValue: CheckboxValueType[]) => {
14
+ console.log('🚀 ~ handleChange ~ args:', checkedValue);
15
+ }, []);
16
+
17
+ return (
18
+ <Layout hasSider>
19
+ <Sider className={styles.searchSide} theme={'light'}>
20
+ <Checkbox.Group className={styles.checkGroup} onChange={handleChange}>
21
+ <List
22
+ bordered
23
+ dataSource={list}
24
+ className={styles.list}
25
+ renderItem={(item) => (
26
+ <List.Item>
27
+ <Checkbox value={item.id} className={styles.checkbox}>
28
+ <Typography.Text
29
+ ellipsis={{ tooltip: item.name }}
30
+ className={styles.knowledgeName}
31
+ >
32
+ {item.name}
33
+ </Typography.Text>
34
+ </Checkbox>
35
+ </List.Item>
36
+ )}
37
+ />
38
+ </Checkbox.Group>
39
+ </Sider>
40
+ <Layout style={{ marginInlineStart: 200 }}>
41
+ <Header style={{ padding: 0 }} />
42
+ <Content style={{ margin: '24px 16px 0', overflow: 'initial' }}>
43
+ <div
44
+ style={{
45
+ padding: 24,
46
+ textAlign: 'center',
47
+ }}
48
+ >
49
+ <p>long content</p>
50
+ {
51
+ // indicates very long content
52
+ Array.from({ length: 100 }, (_, index) => (
53
+ <React.Fragment key={index}>
54
+ {index % 20 === 0 && index ? 'more' : '...'}
55
+ <br />
56
+ </React.Fragment>
57
+ ))
58
+ }
59
+ </div>
60
+ </Content>
61
+ <Footer style={{ textAlign: 'center' }}>
62
+ Ant Design ©{new Date().getFullYear()} Created by Ant UED
63
+ </Footer>
64
+ </Layout>
65
+ </Layout>
66
+ );
67
  };
68
 
69
  export default SearchPage;