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

feat: add guest loan comment functionality to new ty page #5784

Merged
merged 1 commit into from
Feb 7, 2025
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
29 changes: 27 additions & 2 deletions src/components/Thanks/SingleVersion/LoanComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
variant="primary"
:state="buttonState"
aria-label="Comment"
@click="submitCommentAsUser"
@click="submitComment"
v-kv-track-event="['post-checkout', 'submit', 'comments-ask', 'comment']"
>
Leave Comment
Expand Down Expand Up @@ -105,12 +105,20 @@ import {
} from '@kiva/kv-components';
import loanAddComment from '#src/graphql/mutation/loanAddComment.graphql';
import useTipMessage from '#src/composables/useTipMessage';
import { GUEST_COMMENT_COMMENT, GUEST_COMMENT_LOANID } from '#src/plugins/guest-comment-mixin';

const emit = defineEmits(['guest-continue']);

const apollo = inject('apollo');
const cookieStore = inject('cookieStore');

const { $showTipMsg } = useTipMessage(apollo);

const props = defineProps({
isGuest: {
type: Boolean,
default: true,
},
loan: {
type: Object,
default: () => ({}),
Expand All @@ -136,6 +144,15 @@ const buttonState = computed(() => {
return '';
});

const submitCommentAsGuest = () => {
// Save comment to cookie
cookieStore.set(GUEST_COMMENT_COMMENT, userComment.value, { path: '/' });
cookieStore.set(GUEST_COMMENT_LOANID, loanId.value, { path: '/' });

// Show create account form
emit('guest-continue');
};

const submitCommentAsUser = () => {
loading.value = true;
apollo.mutate({
Expand All @@ -145,7 +162,7 @@ const submitCommentAsUser = () => {
body: userComment.value
}
}).then(({ data }) => {
// comment was added successfully
// Comment was added successfully
if (data.loan.addComment) {
$showTipMsg(`Thank you for helping ${loanName.value}!`);
showComment.value = false;
Expand All @@ -159,4 +176,12 @@ const submitCommentAsUser = () => {
loading.value = false;
});
};

const submitComment = () => {
if (props.isGuest) {
submitCommentAsGuest();
} else {
submitCommentAsUser();
}
};
</script>
5 changes: 3 additions & 2 deletions src/components/Thanks/ThanksPageSingleVersion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
class="print:tw-hidden tw-mb-2.5"
/>
<LoanComment
v-if="!isGuest && loanForComment"
:key="loanForComment.id"
v-if="loanForComment"
:is-guest="isGuest"
:loan="loanForComment"
class="tw-mb-2.5"
@guest-continue="handleContinue"
/>
<AccountReceiptShare
ref="receiptSection"
Expand Down
Loading