Fix compilation errors in @rondo/comments-client
This commit is contained in:
parent
93584575d9
commit
ae670c8ea3
@ -1,104 +0,0 @@
|
|||||||
import {IHTTPClient} from '../http'
|
|
||||||
import {IComment, ICommentsAPIDef} from '@rondo/comments-common'
|
|
||||||
|
|
||||||
export enum ICommentActionTypes {
|
|
||||||
VOTE_UP = 'VOTE_UP',
|
|
||||||
VOTE_DOWN = 'VOTE_DOWN',
|
|
||||||
COMMENTS_RETRIEVE = 'COMMENTS_RETRIEVE',
|
|
||||||
COMMENT_ADD = 'COMMENT_ADD',
|
|
||||||
COMMENT_EDIT = 'COMMENT_EDIT',
|
|
||||||
COMMENT_REMOVE = 'COMMENT_DELETE',
|
|
||||||
|
|
||||||
SPAM_MARK = 'SPAM_MARK',
|
|
||||||
SPAM_UNMARK = 'SPAM_UNMARK',
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CommentActions {
|
|
||||||
constructor(protected readonly http: IHTTPClient<ICommentsAPIDef>) {}
|
|
||||||
|
|
||||||
voteUp(comment: IComment) {
|
|
||||||
return {
|
|
||||||
payload: this.http.post('/comments/:commentId/vote', null, {
|
|
||||||
commentId: comment.id,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.VOTE_UP,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
voteDown(comment: IComment) {
|
|
||||||
return {
|
|
||||||
payload: this.http.delete('/comments/:commentId/vote', null, {
|
|
||||||
commentId: comment.id,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.VOTE_DOWN,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getComments(storyId: number) {
|
|
||||||
return {
|
|
||||||
payload: this.http.get('/stories/:storyId/comments', null, {
|
|
||||||
storyId,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.COMMENTS_RETRIEVE,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addComment(comment: IComment) {
|
|
||||||
if (!comment.parentId) {
|
|
||||||
// root comment
|
|
||||||
return {
|
|
||||||
payload: this.http.post('/stories/:storyId/comments', comment, {
|
|
||||||
storyId: comment.storyId,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.COMMENT_ADD,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// nested comment
|
|
||||||
return {
|
|
||||||
payload: this.http
|
|
||||||
.post('/stories/:storyId/comments/:parentId', comment, {
|
|
||||||
storyId: comment.storyId,
|
|
||||||
parentId: comment.parentId,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.COMMENT_ADD,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
editComment(comment: IComment) {
|
|
||||||
return {
|
|
||||||
payload: this.http.put('/comments/:commentId', comment, {
|
|
||||||
commentId: comment.id,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.COMMENT_EDIT,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
removeComment(comment: IComment) {
|
|
||||||
return {
|
|
||||||
payload: this.http.delete('/comments/:commentId', null, {
|
|
||||||
commentId: comment.id,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.COMMENT_REMOVE,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
markAsSpam(comment: IComment) {
|
|
||||||
return {
|
|
||||||
payload: this.http.post('/comments/:commentId/spam', comment, {
|
|
||||||
commentId: comment.id,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.SPAM_MARK,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unmarkAsSpam(comment: IComment) {
|
|
||||||
return {
|
|
||||||
payload: this.http.delete('/comments/:commentId/spam', null, {
|
|
||||||
commentId: comment.id,
|
|
||||||
}),
|
|
||||||
type: ICommentActionTypes.SPAM_UNMARK,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import {IComment} from '@rondo/comments-common'
|
|
||||||
|
|
||||||
export interface ICommentProps {
|
|
||||||
comment: IComment
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CommentVote extends React.PureComponent {
|
|
||||||
render() {
|
|
||||||
return 'vote'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CommentButtons extends React.PureComponent {
|
|
||||||
render() {
|
|
||||||
return 'buttons'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Comment extends React.PureComponent<ICommentProps> {
|
|
||||||
render() {
|
|
||||||
const {comment} = this.props
|
|
||||||
return (
|
|
||||||
<div className='comment'>
|
|
||||||
<span className='score'>{comment.votes}</span>
|
|
||||||
<p>{comment.message}</p>
|
|
||||||
|
|
||||||
// TODO add comment children here
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ICommentsProps {
|
|
||||||
comments: IComment[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Comments extends React.PureComponent<ICommentsProps> {
|
|
||||||
render() {
|
|
||||||
const {comments} = this.props
|
|
||||||
return (
|
|
||||||
<div className='comments'>
|
|
||||||
{comments.map(comment => <Comment comment={comment} />)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +1,7 @@
|
|||||||
export * from './actions'
|
export * from './actions'
|
||||||
export * from './components'
|
export * from './components'
|
||||||
export * from './http'
|
export * from './http'
|
||||||
|
export * from './login'
|
||||||
export * from './middleware'
|
export * from './middleware'
|
||||||
export * from './redux'
|
export * from './redux'
|
||||||
export * from './renderer'
|
export * from './renderer'
|
||||||
|
|||||||
@ -3,5 +3,8 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"rootDir": "src"
|
"rootDir": "src"
|
||||||
}
|
},
|
||||||
|
"references": [
|
||||||
|
{"path": "../common"}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,9 @@
|
|||||||
"references": [
|
"references": [
|
||||||
{"path": "client"},
|
{"path": "client"},
|
||||||
{"path": "common"},
|
{"path": "common"},
|
||||||
{"path": "server"}
|
{"path": "server"},
|
||||||
|
{"path": "comments-client"},
|
||||||
|
{"path": "comments-common"},
|
||||||
|
{"path": "comments-server"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user