Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rewrite Ticket component #277

Merged
merged 6 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions api/customerService/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const AV = require('leancloud-storage')
const { Router } = require('express')

const { requireAuth, catchError, customerServiceOnly } = require('../middleware')

const router = Router().use(requireAuth, customerServiceOnly)

router.get(
'/',
catchError(async (req, res) => {
const role = await new AV.Query(AV.Role).equalTo('name', 'customerService').first()
if (!role) {
res.throw(500, 'Missing customer services role')
}
const customerServices = await role.getUsers().query().find({ useMasterKey: true })
res.json(
customerServices.map((user) => {
return {
id: user.id,
nid: user.get('nid'),
email: user.get('email') || '',
username: user.get('username'),
name: user.get('name') || '',
category_ids: user.get('categories')?.map((c) => c.objectId) || [],
}
})
)
})
)

module.exports = router
1 change: 1 addition & 0 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ apiRouter.use('/ticket-fields', require('./TicketField'))
apiRouter.use('/tickets', require('./ticket/api'))
apiRouter.use('/users', require('./user/api'))
apiRouter.use('/categories', require('./category/api'))
apiRouter.use('/customer-services', require('./customerService/api'))
apiRouter.get('/debug/search', parseSearchingQ, (req, res) => {
res.json({ q: req.q, query: req.query })
})
Expand Down
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import React from 'react'
import { render } from 'react-dom'
import { BrowserRouter } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from 'react-query'

import App from './modules/App'
import './config.webapp'

const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
},
},
})

render(
<BrowserRouter>
<App />
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
</BrowserRouter>,
document.getElementById('app')
)
5 changes: 3 additions & 2 deletions modules/About.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import { useTitle } from 'react-use'

import { useTitle } from './utils/hooks'

export default function About() {
const { t } = useTranslation()
useTitle(`${t('about')} - LeanTicket`)
useTitle(t('about'))

return (
<div>
Expand Down
1 change: 1 addition & 0 deletions modules/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class App extends Component {
{!this.state.loading && (
<AppContext.Provider
value={{
currentUser: this.state.currentUser,
isCustomerService: props.isCustomerService,
tagMetadatas: props.tagMetadatas,
addNotification: this.getChildContext().addNotification,
Expand Down
2 changes: 1 addition & 1 deletion modules/CustomerService/Tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ TicketPager.propTypes = {

export default function CustomerServiceTickets() {
const { t } = useTranslation()
useTitle(`${t('customerServiceTickets')} - LeanTicket`)
useTitle(t('customerServiceTickets'))
const { addNotification } = useContext(AppContext)
const [checkedTickets, setCheckedTickets] = useState(new Set())
const customerServices = useCustomerServices()
Expand Down
125 changes: 0 additions & 125 deletions modules/Evaluation.js

This file was deleted.

5 changes: 3 additions & 2 deletions modules/NotFound.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*global SUPPORT_EMAIL*/
import React from 'react'
import { useTranslation } from 'react-i18next'
import { useTitle } from 'react-use'

import { useTitle } from './utils/hooks'

export default function NotFound() {
const { t } = useTranslation()
useTitle('404 - LeanTicket')
useTitle('404')

return (
<div className="jumbotron">
Expand Down
73 changes: 0 additions & 73 deletions modules/Tag.js

This file was deleted.

Loading