Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabito1451 committed Jan 24, 2025
1 parent b7e67b1 commit 5bf23e9
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 45 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/report-button/ReportBugButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
font-family: Open Sans;
font-size: 16px;
font-weight: 400;
padding-top: 13px;
margin-top: 13px;



Expand Down
38 changes: 31 additions & 7 deletions frontend/src/components/report-modal/ReportBugModal.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@
z-index: 10100;
background-repeat: no-repeat;
background-size: contain;
padding: 100px 100px;

}

.report-bug-form {
width: 500px;
width: 100%;
max-width: 642px;
background-color: #120721;
border-radius: 2px;
}


.modal-content h2 {

.modal-content h3 {

font-family: Open Sans;
font-size: 16px;
Expand All @@ -29,7 +33,9 @@
text-align: center;
text-underline-position: from-font;
text-decoration-skip-ink: none;
color: #798795
color: #798795;
padding-bottom: 5px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.line {
Expand All @@ -55,6 +61,7 @@
text-align: center;
text-underline-position: from-font;
text-decoration-skip-ink: none;
padding: 5px 0px;
color: #f0f0f0
}

Expand All @@ -67,17 +74,26 @@
.bug-textarea {
width: 100%;
min-height: 135px;
background-color: #22153a;
border: 1px solid rgba(255, 255, 255, 0.1);
background-color: #120721;
border: 1px solid #22153a;
border-radius: 8px;
padding: 12px;
color: white;
margin-bottom: 24px;
resize: vertical;
resize: none;
outline: none;
}

.bug-textarea::placeholder {
color: rgba(255, 255, 255, 0.4);
color: #f0f0f0;
font-family: Open Sans;
font-size: 14px;
font-weight: 400;
line-height: 24px;
text-align: left;
text-underline-position: from-font;
text-decoration-skip-ink: none;

}

.dev-group-link {
Expand All @@ -86,6 +102,13 @@
gap: 8px;
color: rgba(255, 255, 255, 0.6);
cursor: pointer;
font-family: Open Sans;
font-size: 14px;
font-weight: 400;




margin-bottom: 24px;
}

Expand All @@ -103,4 +126,5 @@
margin-top: 20px;
display: flex;
gap: 16px;
justify-content: center;
}
123 changes: 91 additions & 32 deletions frontend/src/components/report-modal/ReportBugModal.jsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,108 @@
import React from "react"
import "./ReportBugModal.css"
import telegramIcon from "../../assets/icons/telegram.svg"
import bg from "../../assets/images/background-form.png"
import { Button } from "components/ui/custom-button/Button"

import React, { useState } from "react";
import "./ReportBugModal.css";
import telegramIcon from "../../assets/icons/telegram.svg";
import bg from "../../assets/images/background-form.png";
import { Button } from "components/ui/custom-button/Button";
import { useWalletStore } from "../../stores/useWalletStore";
import { useMutation } from "@tanstack/react-query";
import { generateTelegramLink } from "services/telegram";
import { axiosInstance } from "utils/axios";
import { notify } from "components/layout/notifier/Notifier";

export function ReportBugModal({ onClose }) {
const { walletId } = useWalletStore();
const [bugDescription, setBugDescription] = useState("");

const mutation = useMutation({
mutationFn: async () => {
if (!window?.Telegram?.WebApp?.initData?.user?.id) {
const { subscription_link } = await generateTelegramLink(walletId);
window.open(subscription_link, "_blank");
return;
}
// Send bug report
return await axiosInstance.post(`/api/save-bug-report`, {
telegram_id: window?.Telegram?.WebApp?.initData?.user?.id,
wallet_id: walletId,
bug_description: bugDescription,
});
},
onSuccess: () => {
notify("Report sent successfully!");
},
onError: (error) => {
notify(error.response?.data?.message || "Report failed!", "error");
},
});

const handleSubmit = (e) => {
e.preventDefault()
onClose()
}
e.preventDefault();
if (!bugDescription.trim()) {
notify("Bug description cannot be empty!", "error");
return;
}
mutation.mutate();
onClose();
};

return (
<div onClick={onClose} style={{ backgroundImage: `url(${bg})`, backgroundSize: 'contain' }} className="modal-overlay">
<form className="report-bug-form" onClick={(e) => {
e.stopPropagation();
}} onSubmit={handleSubmit} >
<div
onClick={onClose}
style={{ backgroundImage: `url(${bg})`, backgroundSize: "contain" }}
className="modal-overlay"
>
<form
className="report-bug-form"
onClick={(e) => e.stopPropagation()}
onSubmit={handleSubmit}
>
<div className="modal-content">
<h2 >Report Bug</h2>


<p>Please describe the bug you've encountered</p>
<textarea placeholder="The bug I'm experiencing..." className="bug-textarea" />

<a className="dev-group-link" href="https://t.me/spotnet_dev">

<img src={telegramIcon} alt="telegram-icon" className="telegram-icon" />
<h3>Report Bug</h3>
<p className="modal-paragraph-text">
Please describe the bug you've encountered
</p>
<textarea
value={bugDescription}
onChange={(e) => setBugDescription(e.target.value)}
placeholder="The bug I'm experiencing..."
className="bug-textarea"
required
/>
<a
className="dev-group-link"
href="https://t.me/spotnet_dev"
target="_blank"
rel="noopener noreferrer"
>
<img
src={telegramIcon}
alt="telegram-icon"
className="telegram-icon"
/>
Ask in our Dev group
</a>
</div>
<div className="button-group">
<Button variant="secondary" type="button" className="cancel-button" onClick={(e) => {
e.stopPropagation();
onClose();
}}>
<Button
variant="secondary"
type="button"
className="cancel-button"
onClick={(e) => {
e.stopPropagation();
onClose();
}}
>
Cancel
</Button>
<Button variant="primary" type="submit" className="submit-button">
Send Report
<Button
variant="primary"
type="submit"
className="submit-button"
>
{mutation.isLoading ? "Sending..." : "Send Report"}
</Button>
</div>


</form>
</div>

)
);
}
2 changes: 1 addition & 1 deletion frontend/src/hooks/useAddDeposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useAddDeposit = () => {
const { data: contractAddress } = await axiosInstance.get(`/api/get-user-contract?wallet_id=${walletId}`);

// Prepare extra deposit data
const {data: prepare_data} = await axiosInstance.get(`/api/get-add-deposit-data/${positionId}`, {
const { data: prepare_data } = await axiosInstance.get(`/api/get-add-deposit-data/${positionId}`, {
params: {
amount: amount,
token_symbol: tokenSymbol
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const queryClient = new QueryClient();
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(
<ModalProvider>
<QueryClientProvider client={queryClient}>
<QueryClientProvider client={queryClient}>
<ModalProvider>
<Router>
<App />
</Router>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
</ModalProvider>
</ModalProvider>
</QueryClientProvider>
);

0 comments on commit 5bf23e9

Please sign in to comment.