Skip to content

Commit 6fb784f

Browse files
authored
Merge pull request #92 from AVC0706/AVC1
View User and mandal in Dashboard, Some changes and Next Meeting
2 parents f1ba9bf + 039d715 commit 6fb784f

File tree

11 files changed

+60
-30
lines changed

11 files changed

+60
-30
lines changed

client/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
# misc
1515
.DS_Store
16+
.env
1617
.env.local
1718
.env.development.local
1819
.env.test.local

client/src/components/dashboard/AdminTab.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import UserContext from "../../context/user/userContext";
66

77
const {TabPane} = Tabs;
88

9-
function AdminTab() {
9+
function AdminTab(props) {
1010
const [adminPanel, setadminPanel] = useState({
1111
tab: "City",
1212
});
@@ -117,14 +117,16 @@ function AdminTab() {
117117
});
118118
};
119119

120+
120121
return (
121122
<Tabs defaultActiveKey={[tab]}>
122123
{user.admin.toLowerCase() === "state" ? (
123124
<TabPane tab="District Admins" key="District">
124125
{loading ? (
125126
<Spin size="large"/>
126127
) : (
127-
<DataTable users={districtAdmin} deleteUser={deleteUser} adminType={'district'}/>
128+
<DataTable users={districtAdmin} redirect={props.redirect} deleteUser={deleteUser}
129+
adminType={'district'}/>
128130
)}
129131
</TabPane>
130132
) : null}
@@ -135,7 +137,8 @@ function AdminTab() {
135137
{loading ? (
136138
<Spin size="large"/>
137139
) : (
138-
<DataTable users={cityAdmin} deleteUser={deleteUser} adminType={'city'}/>
140+
<DataTable users={cityAdmin} redirect={props.redirect} deleteUser={deleteUser}
141+
adminType={'city'}/>
139142
)}
140143
</TabPane>
141144
) : null}
@@ -145,7 +148,8 @@ function AdminTab() {
145148
{loading ? (
146149
<Spin size="large"/>
147150
) : (
148-
<DataTable users={normalUsers} deleteUser={deleteUser} adminType={'null'}/>
151+
<DataTable users={normalUsers} redirect={props.redirect} deleteUser={deleteUser}
152+
adminType={'null'}/>
149153
)}
150154
</TabPane>
151155
</Tabs>

client/src/components/dashboard/Dashboard.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import MandalAdminTab from "./MandalAdminTab.js";
66

77
const {Sider, Content} = Layout;
88

9-
function Dashboard() {
9+
function Dashboard(props) {
1010
const [dashBoard, setdashBoard] = useState({
1111
tab: "Admins",
1212
});
@@ -15,6 +15,8 @@ function Dashboard() {
1515
setdashBoard({...dashBoard, tab: e.key});
1616
};
1717

18+
19+
1820
return (
1921
<Layout style={{minHeight: "92vh"}}>
2022
<Layout>
@@ -27,9 +29,9 @@ function Dashboard() {
2729
</Sider>
2830
<Layout style={{padding: "0 24px 24px"}}>
2931
<Content>
30-
{tab === "Mandals" && <MandalTab></MandalTab>}
31-
{tab === "Admins" && <AdminTab></AdminTab>}
32-
{tab === "Mandal Admins" && <MandalAdminTab></MandalAdminTab>}
32+
{tab === "Mandals" && <MandalTab redirect={props.redirectMandal}/>}
33+
{tab === "Admins" && <AdminTab redirect={props.redirectUser}/>}
34+
{tab === "Mandal Admins" && <MandalAdminTab redirect={props.redirectUser} />}
3335
</Content>
3436
</Layout>
3537
</Layout>

client/src/components/dashboard/DataTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const DataTable = (props) => {
114114

115115
const onViewButton = (e, record) => {
116116
e.preventDefault();
117-
// props.history.push('/userProfile')
117+
props.redirect(record._id)
118118
};
119119

120120
const onChange = (e) => {

client/src/components/dashboard/MandalAdminTab.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import axios from "axios";
99
const {TabPane} = Tabs;
1010

1111

12-
function MandalAdminTab() {
12+
function MandalAdminTab(props) {
1313
const userContext = useContext(UserContext);
1414
const {user} = userContext;
1515
const [loading, setLoading] = useState(true);
@@ -37,12 +37,12 @@ function MandalAdminTab() {
3737
const [normalUsers, setNormalUsers] = useState([]);
3838
return (
3939
<Tabs defaultActiveKey={tab}>
40-
<TabPane tab="Existing Admins" key="Existing"><MandalTable></MandalTable></TabPane>
40+
<TabPane tab="Existing Admins" key="Existing"><MandalTable redirect={props.redirect}/></TabPane>
4141
<TabPane tab="Add New Mandal Admin" key="New">
4242
<Row>
4343
<Col/>
4444
<Col>
45-
<Register></Register>
45+
<Register/>
4646
</Col>
4747
<Col/>
4848
</Row>

client/src/components/dashboard/MandalTab.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import UserContext from "../../context/user/userContext";
77

88
const {TabPane} = Tabs;
99

10-
function MandalTab() {
10+
function MandalTab(props) {
1111

1212
const userContext = useContext(UserContext);
1313
const {user} = userContext;
@@ -104,7 +104,7 @@ function MandalTab() {
104104
{loading ? (
105105
<Spin size="large"/>
106106
) : (
107-
<MandalApprovalTable mandals={falseMandal}></MandalApprovalTable>
107+
<MandalApprovalTable mandals={falseMandal} redirect={props.redirect}></MandalApprovalTable>
108108
)}
109109
</TabPane>
110110
) : null}
@@ -114,7 +114,7 @@ function MandalTab() {
114114
{loading ? (
115115
<Spin size="large"/>
116116
) : (
117-
<MandalTable mandals={approvedMandal}></MandalTable>
117+
<MandalTable mandals={approvedMandal} redirect={props.redirect}></MandalTable>
118118
)}
119119
</TabPane>
120120

client/src/components/dashboard/MandalTable.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ const MandalTable = (props) => {
4343
key: "actions",
4444
render: (text, record) => (
4545
<Space size="middle">
46-
<Button type="primary">View</Button>
47-
46+
<Button type="primary" onClick={(e) => onViewButton(e, record)}>
47+
View
48+
</Button>
4849
<Popconfirm
4950
title="Are you sure?"
5051
icon={<QuestionCircleOutlined style={{color: "red"}}/>}
@@ -87,6 +88,10 @@ const MandalTable = (props) => {
8788
console.log("params", pagination, filters, sorter, extra);
8889
}
8990
};
91+
const onViewButton = (e, record) => {
92+
e.preventDefault();
93+
props.redirect(record._id)
94+
};
9095
const onChange = (e) => {
9196
if (e.value === "") {
9297
setstate({...state, filterTable: null, baseData: props.mandals});
@@ -101,7 +106,7 @@ const MandalTable = (props) => {
101106
onChange={onChange}
102107
enterButton
103108
onSearch={search}
104-
></Input.Search>
109+
/>
105110
<Table
106111
columns={columns}
107112
dataSource={filterTable == null ? baseData : filterTable}

client/src/views/Dashboard/Dashboard.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ import {Col, Row} from "antd";
55

66
const Dashboard = (props) => {
77
const userContext = useContext(UserContext);
8+
const redirectUser = (id) => {
9+
props.history.push(`/userProfile/${id}`);
10+
}
11+
const redirectMandal = (id) => {
12+
props.history.push(`/mandalProfile/${id}`);
13+
}
814
return (
915
<><Row>
1016
<Col span={2}/>
1117
<Col span={20}>{userContext.user && userContext.user.admin.toLowerCase() !== "null" ? (
12-
<DashboardView/>
18+
<DashboardView redirectUser={redirectUser} redirectMandal={redirectMandal}/>
1319
) : (
1420
<p>You are not a admin.</p>
1521
)}</Col>

client/src/views/Profiles/UserProfile.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function UserProfile(props) {
4242
const getUser = () => {
4343
console.log(props)
4444
axios
45-
.get(process.env.REACT_APP_SERVER_URL + `/user/profile/${props.match.params.id}`)
45+
.get(`${process.env.REACT_APP_SERVER_URL}/user/profile/${props.match.params.id}`)
4646
.then((res) => {
4747
if (res.status === 200) {
4848
console.log(res.data.user)
@@ -66,7 +66,7 @@ function UserProfile(props) {
6666
style={{margin: "10px"}}
6767
extra=
6868
{
69-
userContext.user && userContext.user.admin != "null" ? <Button
69+
userContext.user && userContext.user.admin !== "null" ? <Button
7070
style={{marginTop: "0px", float: "right"}}
7171
type="primary"
7272
onClick={showEditMember}
@@ -93,13 +93,12 @@ function UserProfile(props) {
9393
</Descriptions.Item>
9494
<Descriptions.Item label="Qualification">{qualification}</Descriptions.Item>
9595

96-
<Descriptions.Item label="Joined At">
97-
{{
98-
if(created_at) {
99-
created_at.getDate();
100-
}
101-
}}
102-
</Descriptions.Item>
96+
{/*<Descriptions.Item label="Joined At">*/}
97+
{/* {*/}
98+
{/* created_at.getDate()*/}
99+
100+
{/* }*/}
101+
{/*</Descriptions.Item>*/}
103102

104103
<Descriptions.Item label="Area of Interest"><Tag>Area of
105104
Interest</Tag></Descriptions.Item>

routes/mandal.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ router.post("/createMandal", isAdmin, async (req, res) => {
2626
},
2727
);
2828

29-
3029
await mandal.save();
3130

32-
3331
res
3432
.status(200)
3533
.json({msg: "Mandal Registration Successful !!", mandal, user});

0 commit comments

Comments
 (0)