diff --git a/src/api/CommentResource.ts b/src/api/CommentResource.ts new file mode 100644 index 000000000..807be3375 --- /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( validationResult.data.message ); + } + return validationResult.data.message; + } ); + } +} diff --git a/src/components/pages/donation_confirmation/DonationCommentPopUp.vue b/src/components/pages/donation_confirmation/DonationCommentPopUp.vue index 512e8e30e..bd6205456 100644 --- a/src/components/pages/donation_confirmation/DonationCommentPopUp.vue +++ b/src/components/pages/donation_confirmation/DonationCommentPopUp.vue @@ -3,9 +3,10 @@
-

+

@@ -15,6 +16,7 @@

{{ $t( 'donation_comment_popup_explanation' ) }}

+ @@ -44,6 +46,18 @@ {{ $t( 'donation_comment_popup_is_public' ) }} + +