Skip to content

Commit 20b2dc6

Browse files
authored
Merge pull request #639 from ksraj123/feature-tickets
Feature tickets
2 parents 01e9575 + 0080c8a commit 20b2dc6

34 files changed

+3450
-14
lines changed

package-lock.json

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"react-chartjs-2": "^2.9.0",
3030
"react-content-loader": "^5.0.4",
3131
"react-cookies": "^0.1.1",
32+
"react-data-table-component": "^6.11.0",
3233
"react-datepicker": "^3.1.3",
3334
"react-dom": "^16.12.0",
3435
"react-dropzone": "^11.0.1",
@@ -38,6 +39,7 @@
3839
"react-loading-overlay": "^1.0.1",
3940
"react-lottie": "^1.2.3",
4041
"react-markdown": "^4.3.1",
42+
"react-markdown-editor-lite": "^1.1.4",
4143
"react-mde": "^10.2.1",
4244
"react-moment": "^0.9.7",
4345
"react-redux": "^7.2.0",

src/actions/authAction.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,20 @@ export const loginUser = (userInfo, history) => async (dispatch) => {
4747

4848
// update state with user
4949
const decodedData = await jwt_decode(token);
50-
localStorage.setItem('userId', decodedData._id)
50+
console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PRINTING RES.DATA.USER !!!!!!!!!!!!!!1");
51+
console.log(res.data.user);
52+
localStorage.setItem('userId', res.data.user._id)
5153
dispatch(setCurrentUser(decodedData));
5254

55+
// Update user name in localStorage
56+
localStorage.setItem('username', `${res.data.user.name.firstName} ${res.data.user.name.lastName}`)
57+
5358
// update user role in localStorage
5459
localStorage.setItem('admin', res.data.user.isAdmin)
5560

61+
// update user role in localStorage
62+
localStorage.setItem('ticketModerator', res.data.user.isTicketsModerator)
63+
5664
// store orgId in localStorage
5765
localStorage.setItem('orgId', res.data.user.orgId);
5866

src/actions/ticketAction.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import axios from "axios";
2+
import { GET_TICKETs } from "./types";
3+
import { BASE_URL } from "./baseApi";
4+
import { errorHandler } from "../utils/errorHandler";
5+
6+
export const getTickets = () => async (dispatch) => {
7+
try {
8+
const res = await axios.get(`${BASE_URL}/ticket`);
9+
dispatch({
10+
type: GET_TICKETs,
11+
payload: res.data.tickets,
12+
});
13+
} catch (error) {
14+
dispatch(errorHandler(error));
15+
}
16+
};

src/actions/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ export const ACTIVATE_DEACTIVATE_ACCOUNT_TOGGLER = "ACTIVATE_DEACTIVATE_ACCOUNT_
5656
export const GET_WIKIS = "GET_WIKIS";
5757
export const CLEAR_INVITE_LINK = "CLEAR_INVITE_LINK";
5858
export const GET_LOGIN_OPTIONS = "GET_LOGIN_OPTIONS";
59+
export const GET_TICKETs = "GET_TICKETs";

src/reducers/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import proposalReducer from "./proposalReducer";
1414
import adminReducers from "./adminReducers";
1515
import commentReducer from "./commentReducer";
1616
import analyticsReducer from './analyticsReducer';
17+
import ticketReducer from './ticketReducer';
1718
import wikisReducer from './wikisReducer';
1819

1920
const rootReducer = combineReducers({
@@ -32,7 +33,8 @@ const rootReducer = combineReducers({
3233
proposal: proposalReducer,
3334
admin: adminReducers,
3435
comment: commentReducer,
35-
analytics: analyticsReducer
36+
analytics: analyticsReducer,
37+
tickets: ticketReducer
3638
});
3739

3840
export default rootReducer;

src/reducers/ticketReducer.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { GET_TICKETs } from "../actions/types";
2+
const initialState = {
3+
tickets: "",
4+
};
5+
6+
export default (state = initialState, action) => {
7+
switch (action.type) {
8+
case GET_TICKETs: {
9+
console.log(`Action Recieved in reducer! ${action.type}`);
10+
return {
11+
...state,
12+
tickets: action.payload.reverse(),
13+
};
14+
}
15+
default: {
16+
return state;
17+
}
18+
}
19+
};

src/router.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import AdminRoute from "./common/AdminRoute";
2424
import Activity from "./user/Activity/Activity";
2525
import IntegrationsPage from "./user/integrations/IntegrationsPage/IntegrationsPage";
2626
import UserIntegrations from "./user/integrations/UserIntegrations/UserIntegrations";
27+
import TicketDashboard from "../src/user/Admin/Tickets/TicketDashboard";
2728

2829
const Router = () => (
2930
<BrowserRouter>
@@ -58,6 +59,7 @@ const Router = () => (
5859
path="/userintegrations"
5960
component={UserIntegrations}
6061
/>
62+
<PrivateRoute exact path="/tickets" component={TicketDashboard} />
6163
<Route component={NotFound} />
6264
</Switch>
6365
</BrowserRouter>

0 commit comments

Comments
 (0)