Skip to content

Commit

Permalink
manage conversations interface, archive/unarchive conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
raykyri committed May 21, 2023
1 parent fca26a5 commit 6a4736f
Show file tree
Hide file tree
Showing 17 changed files with 33,814 additions and 33,948 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"react": "~16.14.0",
"react-dom": "~16.14.0",
"react-easy-emoji": "~1.4.0",
"react-icons": "^4.8.0",
"react-redux": "7.2.2",
"react-router-dom": "~5.2.0",
"redux": "~4.0.5",
Expand Down
Binary file added client/public/polldoc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 46 additions & 3 deletions client/src/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export const REQUEST_CONVERSATIONS = "REQUEST_CONVERSATIONS"
export const RECEIVE_CONVERSATIONS = "RECEIVE_CONVERSATIONS"
export const CONVERSATIONS_FETCH_ERROR = "CONVERSATIONS_FETCH_ERROR"

export const CLOSE_CONVERSATION_SUCCESS = "CLOSE_CONVERSATION_SUCCESS"
export const CLOSE_CONVERSATION_ERROR = "CLOSE_CONVERSATION_ERROR"

export const REOPEN_CONVERSATION_SUCCESS = "REOPEN_CONVERSATION_SUCCESS"
export const REOPEN_CONVERSATION_ERROR = "REOPEN_CONVERSATION_ERROR"

/* zid for clarity - this is conversation config */
export const REQUEST_ZID_METADATA = "REQUEST_ZID_METADATA"
export const RECEIVE_ZID_METADATA = "RECEIVE_ZID_METADATA"
Expand Down Expand Up @@ -951,17 +957,18 @@ const createConversationPostError = (err) => {
}
}

const postCreateConversation = () => {
const postCreateConversation = (topic) => {
return api.post("/api/v3/conversations", {
topic,
is_draft: true,
is_active: true,
})
}

export const handleCreateConversationSubmit = () => {
export const handleCreateConversationSubmit = (topic) => {
return (dispatch) => {
dispatch(createConversationStart())
return postCreateConversation()
return postCreateConversation(topic)
.then(
(res) => {
dispatch(createConversationPostSuccess(res))
Expand All @@ -975,6 +982,42 @@ export const handleCreateConversationSubmit = () => {
}
}

const postCloseConversation = (conversation_id) => {
return api.post("/api/v3/conversation/close", {
conversation_id,
})
}

export const handleCloseConversation = (conversation_id) => {
return (dispatch) => {
return postCloseConversation(conversation_id).then(
(res) => {
dispatch({ type: CLOSE_CONVERSATION_SUCCESS, data: conversation_id })
return res
},
(err) => dispatch({ type: CLOSE_CONVERSATION_ERROR, data: err })
)
}
}

const postReopenConversation = (conversation_id) => {
return api.post("/api/v3/conversation/reopen", {
conversation_id,
})
}

export const handleReopenConversation = (conversation_id) => {
return (dispatch) => {
return postReopenConversation(conversation_id).then(
(res) => {
dispatch({ type: REOPEN_CONVERSATION_SUCCESS, data: conversation_id })
return res
},
(err) => dispatch({ type: REOPEN_CONVERSATION_ERROR, data: err })
)
}
}

/* request all comments */

const requestComments = () => {
Expand Down
36 changes: 17 additions & 19 deletions client/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,23 @@ class App extends React.Component<
return null
}
return (
<Flex>
<Box>
<PrivateRoute
isLoading={this.isLoading()}
authed={this.isAuthed()}
exact
path="/conversations"
component={AllConversations}
/>
<PrivateRoute
isLoading={this.isLoading()}
authed={this.isAuthed()}
exact
path="/account"
component={Account}
/>
<Route path="/c/:conversation_id" component={Survey} />
</Box>
</Flex>
<Box>
<PrivateRoute
isLoading={this.isLoading()}
authed={this.isAuthed()}
exact
path="/conversations"
component={AllConversations}
/>
<PrivateRoute
isLoading={this.isLoading()}
authed={this.isAuthed()}
exact
path="/account"
component={Account}
/>
<Route path="/c/:conversation_id" component={Survey} />
</Box>
)
}}
/>
Expand Down
13 changes: 8 additions & 5 deletions client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Provider } from "react-redux"
import { BrowserRouter as Router, Route } from "react-router-dom"
import { createStore, applyMiddleware, compose } from "redux"
import thunk from "redux-thunk"
import { IconContext } from "react-icons"

import { ThemeProvider } from "theme-ui"
import theme from "./theme"
Expand All @@ -21,11 +22,13 @@ class Root extends React.Component {
render() {
return (
<ThemeProvider theme={theme}>
<Provider store={store}>
<Router>
<Route render={(routeProps) => <App {...routeProps} />}></Route>
</Router>
</Provider>
<IconContext.Provider value={{ style: { position: "relative", top: "0.08em" } }}>
<Provider store={store}>
<Router>
<Route render={(routeProps) => <App {...routeProps} />}></Route>
</Router>
</Provider>
</IconContext.Provider>
</ThemeProvider>
)
}
Expand Down
7 changes: 1 addition & 6 deletions client/src/pages/admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ class ConversationAdminContainer extends React.Component<

return (
<Flex>
<Box sx={{ mr: [5], p: [4], flex: "0 0 275" }}>
<Box sx={{ mb: [3] }}>
<Link sx={{ variant: "links.nav" }} to={`/`}>
All
</Link>
</Box>
<Box sx={{ mr: [5], pt: [5], flex: "0 0 275", maxWidth: "50px" }}>
<Box sx={{ mb: [3] }}>
<Link sx={{ variant: url ? "links.nav" : "links.activeNav" }} to={`${match.url}`}>
Configure
Expand Down
Loading

0 comments on commit 6a4736f

Please sign in to comment.