types#TaskComment TypeScript Examples
The following examples show how to use
types#TaskComment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommentSlice.tsx From knboard with MIT License | 6 votes |
fetchComments = createAsyncThunk<TaskComment[], number>(
"comment/fetchCommentsStatus",
async (taskId, { dispatch }) => {
try {
const response: AxiosResponse<TaskComment[]> = await api.get(
`${API_COMMENTS}?task=${taskId}`
);
return response.data;
} catch (err) {
dispatch(createErrorToast(err.message));
return [];
}
}
)
Example #2
Source File: CommentSlice.tsx From knboard with MIT License | 6 votes |
createComment = createAsyncThunk<
TaskComment | undefined,
NewTaskComment
>("comment/createCommentStatus", async (comment, { dispatch }) => {
try {
const response: AxiosResponse<TaskComment> = await api.post(
API_COMMENTS,
comment
);
dispatch(createSuccessToast("Comment posted"));
return response.data;
} catch (err) {
dispatch(createErrorToast(err.message));
}
})
Example #3
Source File: CommentSlice.tsx From knboard with MIT License | 6 votes |
slice = createSlice({
name: "comment",
initialState,
reducers: {},
extraReducers: (builder) => {
builder.addCase(fetchComments.pending, (state) => {
state.fetchCommentsStatus = "loading";
});
builder.addCase(fetchComments.fulfilled, (state, action) => {
commentAdapter.addMany(state, action.payload);
state.fetchCommentsStatus = "succeeded";
});
builder.addCase(createComment.pending, (state) => {
state.createCommentStatus = "loading";
});
builder.addCase(createComment.fulfilled, (state, action) => {
commentAdapter.addOne(state, action.payload as TaskComment);
state.createCommentStatus = "succeeded";
});
builder.addCase(deleteComment.fulfilled, (state, action) => {
commentAdapter.removeOne(state, action.payload as Id);
});
},
})
Example #4
Source File: CommentItem.test.tsx From knboard with MIT License | 5 votes |
comment: TaskComment = {
id: 1,
author: 1,
created: formatISO(new Date(2012, 8, 18, 19, 0, 52)),
modified: formatISO(new Date(2015, 9, 15, 20, 2, 53)),
task: 1,
text: "foobar",
}
Example #5
Source File: CommentSlice.tsx From knboard with MIT License | 5 votes |
commentAdapter = createEntityAdapter<TaskComment>({
sortComparer: (a, b) => b.created.localeCompare(a.created),
})