Skip to content

Commit

Permalink
Merge pull request #522 from djeck1432/feat/frontend-connect-report-w…
Browse files Browse the repository at this point in the history
…ith-backend

Connect report bug modal window with backend
  • Loading branch information
djeck1432 authored Jan 27, 2025
2 parents 8f5f328 + 6f02823 commit c2ed6c9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions frontend/src/hooks/useBugReport.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { useMutation } from '@tanstack/react-query';
import { axiosInstance } from 'utils/axios';
import { generateTelegramLink } from 'services/telegram';
import { notify } from 'components/layout/notifier/Notifier';

export const useBugReport = (walletId, bugDescription, onClose) => {
const mutation = useMutation({
mutationFn: async () => {
if (!window?.Telegram?.WebApp?.initData?.user?.id) {
const { subscription_link } = await generateTelegramLink(walletId);
window.open(subscription_link, '_blank');
return;
}

return await axiosInstance.post(`/api/save-bug-report`, {
telegram_id: window?.Telegram?.WebApp?.initData?.user?.id,
const user_id = window?.Telegram?.WebApp?.initData?.user?.id;
const data = {
wallet_id: walletId,
bug_description: bugDescription,
});
}
if (user_id) data.telegram_id = user_id;
return await axiosInstance.post(`/api/save-bug-report`, data);
},
onSuccess: () => {
notify('Report sent successfully!');
Expand Down

0 comments on commit c2ed6c9

Please sign in to comment.