diff --git a/src/api/CommentResource.ts b/src/api/CommentResource.ts new file mode 100644 index 000000000..7839ec735 --- /dev/null +++ b/src/api/CommentResource.ts @@ -0,0 +1,35 @@ +import axios, { AxiosResponse } from 'axios'; + +export interface CommentRequest { + donationId: number; + updateToken: string; + comment: string; + withName: boolean; + isPublic: boolean; +} + +interface CommentResponse { + status: string; + message: string; +} + +export interface CommentResource { + post: ( data: CommentRequest ) => Promise; +} + +export class ApiCommentResource implements CommentResource { + postEndpoint: string; + + constructor( postEndpoint: string ) { + this.postEndpoint = postEndpoint; + } + + post( data: CommentRequest ): Promise { + return axios.post( this.postEndpoint, data ).then( ( validationResult: AxiosResponse ) => { + if ( validationResult.data.status === 'OK' ) { + return Promise.reject(); + } + return validationResult.data.message; + } ); + } +} diff --git a/src/components/pages/donation_confirmation/DonationCommentPopUp.vue b/src/components/pages/donation_confirmation/DonationCommentPopUp.vue index 512e8e30e..97bcbf9a5 100644 --- a/src/components/pages/donation_confirmation/DonationCommentPopUp.vue +++ b/src/components/pages/donation_confirmation/DonationCommentPopUp.vue @@ -3,9 +3,10 @@
-

+

@@ -66,8 +67,7 @@