diff --git a/frontend/src/components/BottomBar.js b/frontend/src/components/BottomBar.js
index 608eedb6..64f4bdb5 100644
--- a/frontend/src/components/BottomBar.js
+++ b/frontend/src/components/BottomBar.js
@@ -29,6 +29,8 @@ import EmojiEventsIcon from '@mui/icons-material/EmojiEvents';
import AmbossIcon from "./icons/AmbossIcon";
import FavoriteIcon from '@mui/icons-material/Favorite';
+import { getCookie } from "../utils/cookies";
+
// pretty numbers
function pn(x) {
if(x == null){
@@ -40,22 +42,6 @@ function pn(x) {
}
}
-function getCookie(name) {
- let cookieValue = null;
- if (document.cookie && document.cookie !== '') {
- const cookies = document.cookie.split(';');
- for (let i = 0; i < cookies.length; i++) {
- const cookie = cookies[i].trim();
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) === (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
- }
-
class BottomBar extends Component {
constructor(props) {
super(props);
@@ -124,11 +110,11 @@ class BottomBar extends Component {
- {this.state.network == 'testnet'?
+ {this.state.network == 'testnet'?
- {this.state.node_id.slice(0, 12)+"... (1ML)"}
@@ -137,7 +123,7 @@ class BottomBar extends Component {
- {this.state.node_id.slice(0, 12)+"... (AMBOSS)"}
@@ -157,7 +143,7 @@ class BottomBar extends Component {
- {this.state.robosats_running_commit_hash.slice(0, 12)+"..."}
@@ -216,7 +202,7 @@ class BottomBar extends Component {
{t("Support is only offered via public channels. Join our Telegram community if you have questions or want to hang out with other cool robots. Please, use our Github Issues if you find a bug or want to see new features!")}
this.state.max_amount || this.state.takeAmount == "" || this.state.takeAmount == null) ? 'none':''}}>
-
@@ -232,7 +217,7 @@ class OrderPage extends Component {
return(
<>
-
@@ -256,7 +241,7 @@ class OrderPage extends Component {
LinearDeterminate =()=> {
const [progress, setProgress] = React.useState(0);
-
+
React.useEffect(() => {
const timer = setInterval(() => {
setProgress((oldProgress) => {
@@ -264,12 +249,12 @@ class OrderPage extends Component {
return (left / this.state.total_secs_exp) * 100;
});
}, 1000);
-
+
return () => {
clearInterval(timer);
};
}, []);
-
+
return (
@@ -291,14 +276,14 @@ class OrderPage extends Component {
.then((response) => response.json())
.then((data) => this.completeSetState(data));
}
-
+
// set delay to the one matching the order status. If null order status, delay goes to 9999999.
setDelay = (status)=>{
return status >= 0 ? this.statusToDelay[status.toString()] : 99999999;
}
getCurrencyCode(val){
- let code = val ? currencyDict[val.toString()] : ""
+ let code = val ? currencyDict[val.toString()] : ""
return code
}
@@ -441,7 +426,7 @@ class OrderPage extends Component {
CancelButton = () => {
const { t } = this.props;
// If maker and Waiting for Bond. Or if taker and Waiting for bond.
- // Simply allow to cancel without showing the cancel dialog.
+ // Simply allow to cancel without showing the cancel dialog.
if ((this.state.is_maker & [0,1].includes(this.state.status)) || this.state.is_taker & this.state.status == 3){
return(
@@ -459,9 +444,9 @@ class OrderPage extends Component {
)}
-
+
// If the escrow is Locked, show the collaborative cancel button.
-
+
if ([8,9].includes(this.state.status)){
return(
@@ -498,8 +483,8 @@ class OrderPage extends Component {
@@ -514,18 +499,18 @@ class OrderPage extends Component {
-
+
-
- >:
+
+ >:
""
}
@@ -539,7 +524,7 @@ class OrderPage extends Component {
>
:
}
-
+
@@ -570,15 +555,15 @@ class OrderPage extends Component {
- {this.state.price_now?
+ {this.state.price_now?
:
- (this.state.is_explicit ?
+ (this.state.is_explicit ?
:
)
- }
+ }
@@ -599,53 +584,53 @@ class OrderPage extends Component {
-
+
{/* If the user has a penalty/limit */}
- {this.state.penalty ?
+ {this.state.penalty ?
<>
-
+
>
- : null}
-
+ : null}
+
{/* If the counterparty asked for collaborative cancel */}
- {this.state.pending_cancel ?
+ {this.state.pending_cancel ?
<>
{t("{{nickname}} is asking for a collaborative cancel", {nickname: this.state.is_maker ? this.state.taker_nick : this.state.maker_nick})}
-
+
>
- : null}
+ : null}
{/* If the user has asked for a collaborative cancel */}
- {this.state.asked_for_cancel ?
+ {this.state.asked_for_cancel ?
<>
{t("You asked for a collaborative cancellation")}
-
+
>
- : null}
+ : null}
-
+
{/* Participants can see the "Cancel" Button, but cannot see the "Back" or "Take Order" buttons */}
{this.state.is_participant ?
<>
- >
+ >
:
@@ -660,7 +645,7 @@ class OrderPage extends Component {
)
}
-
+
doubleOrderPageDesktop=()=>{
return(
@@ -673,7 +658,7 @@ class OrderPage extends Component {
)
}
-
+
a11yProps(index) {
return {
id: `simple-tab-${index}`,
@@ -724,7 +709,7 @@ class OrderPage extends Component {
:
- (this.state.is_participant ?
+ (this.state.is_participant ?
<>
{/* Desktop View */}
@@ -744,11 +729,11 @@ class OrderPage extends Component {
}
render (){
- return (
+ return (
// Only so nothing shows while requesting the first batch of data
this.state.loading ? : this.orderDetailsPage()
);
}
}
-export default withTranslation()(OrderPage);
\ No newline at end of file
+export default withTranslation()(OrderPage);
diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js
index 770188d5..5607799a 100644
--- a/frontend/src/components/TradeBox.js
+++ b/frontend/src/components/TradeBox.js
@@ -17,22 +17,7 @@ import LockOpenIcon from '@mui/icons-material/LockOpen';
import BalanceIcon from '@mui/icons-material/Balance';
import ContentCopy from "@mui/icons-material/ContentCopy";
-function getCookie(name) {
- let cookieValue = null;
- if (document.cookie && document.cookie !== '') {
- const cookies = document.cookie.split(';');
- for (let i = 0; i < cookies.length; i++) {
- const cookie = cookies[i].trim();
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) === (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
-}
-const csrftoken = getCookie('csrftoken');
+import { getCookie } from "../utils/cookies";
// pretty numbers
function pn(x) {
@@ -54,7 +39,7 @@ class TradeBox extends Component {
}
}
-
+
Sound = ({soundFileName}) => (
// Four filenames: "locked-invoice", "taker-found", "open-chat", "successful"
@@ -209,7 +194,7 @@ class TradeBox extends Component {
{t("Lock {{amountSats}} Sats to PUBLISH order", {amountSats: pn(this.props.data.bond_satoshis)})}
{" " + this.stepXofY()}
- :
+ :
{t("Lock {{amountSats}} Sats to TAKE order", {amountSats: pn(this.props.data.bond_satoshis)})}
@@ -224,13 +209,13 @@ class TradeBox extends Component {
-
+
-
-
+
-
{t("Be patient while robots check the book. It might take some time. This box will ring 🔊 once a robot takes your order.")}
-
{t("Please note that if your premium is excessive or your currency or payment methods are not popular, your order might expire untaken. Your bond will return to you (no action needed).")}
+
{t("Please note that if your premium is excessive or your currency or payment methods are not popular, your order might expire untaken. Your bond will return to you (no action needed).")}
@@ -416,13 +401,13 @@ class TradeBox extends Component {
-
+
-
@@ -437,7 +422,7 @@ class TradeBox extends Component {
handleInputInvoiceChanged=(e)=>{
this.setState({
invoice: e.target.value,
- badInvoice: false,
+ badInvoice: false,
});
}
@@ -461,7 +446,7 @@ class TradeBox extends Component {
handleInputDisputeChanged=(e)=>{
this.setState({
statement: e.target.value,
- badStatement: false,
+ badStatement: false,
});
}
@@ -512,17 +497,17 @@ class TradeBox extends Component {
- {t("The taker is committed! Before letting you send {{amountFiat}} {{currencyCode}}, we want to make sure you are able to receive the BTC. Please provide a valid invoice for {{amountSats}} Satoshis.",
- {amountFiat: parseFloat(parseFloat(this.props.data.amount).toFixed(4)),
- currencyCode: this.props.data.currencyCode,
- amountSats: pn(this.props.data.invoice_amount)}
+ {t("The taker is committed! Before letting you send {{amountFiat}} {{currencyCode}}, we want to make sure you are able to receive the BTC. Please provide a valid invoice for {{amountSats}} Satoshis.",
+ {amountFiat: parseFloat(parseFloat(this.props.data.amount).toFixed(4)),
+ currencyCode: this.props.data.currencyCode,
+ amountSats: pn(this.props.data.invoice_amount)}
)
}
-
@@ -594,9 +579,9 @@ class TradeBox extends Component {
{t("Please, submit your statement. Be clear and specific about what happened and provide the necessary evidence. You MUST provide a contact method: burner email, XMPP or telegram username to follow up with the staff. Disputes are solved at the discretion of real robots (aka humans), so be as helpful as possible to ensure a fair outcome. Max 5000 chars.")}
-
+
- {
var showReveiceButton=false;
var showDisputeButton=true;
}
-
+
//In Chatroom - Fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
if(this.props.data.is_buyer & this.props.data.status == 10){
var showSendButton=false;
@@ -829,8 +814,8 @@ handleRatingRobosatsChange=(e)=>{
var showSendButton=false;
var showReveiceButton=true;
var showDisputeButton=true;
- }
-
+ }
+
return(
{/* Make confirmation sound for Chat Open. */}
@@ -841,7 +826,7 @@ handleRatingRobosatsChange=(e)=>{
- {this.props.data.is_seller ?
+ {this.props.data.is_seller ?
{this.props.data.status == 9?
t("Say hi! Be helpful and concise. Let them know how to send you {{currencyCode}}.",{currencyCode: this.props.data.currencyCode})
@@ -909,13 +894,13 @@ handleRatingRobosatsChange=(e)=>{
{this.state.rating_platform!=5 & this.state.rating_platform!=null ?
-
{t("Thank you for using Robosats!")}
+
{t("Thank you for using Robosats!")}
Let us know how the platform could improve (Telegram / Github)
: null}
-
+
{this.showBondIsReturned()}
@@ -944,13 +929,13 @@ handleRatingRobosatsChange=(e)=>{
)
}
- // Countdown Renderer callback with condition
+ // Countdown Renderer callback with condition
countdownRenderer = ({ minutes, seconds, completed }) => {
const { t } = this.props;
if (completed) {
// Render a completed state
return (
{t("Retrying!")}
);
-
+
} else {
return (
{zeroPad(minutes)}m {zeroPad(seconds)}s
@@ -970,7 +955,7 @@ handleRatingRobosatsChange=(e)=>{
- {t("Your invoice has expired or more than 3 payment attempts have been made. Muun wallet is not recommended. ")}
+ {t("Your invoice has expired or more than 3 payment attempts have been made. Muun wallet is not recommended. ")}
{t("Check the list of compatible wallets")}
@@ -980,7 +965,7 @@ handleRatingRobosatsChange=(e)=>{
- {
}
}
-export default withTranslation()(TradeBox);
\ No newline at end of file
+export default withTranslation()(TradeBox);
diff --git a/frontend/src/components/UserGenPage.js b/frontend/src/components/UserGenPage.js
index 9b4acfda..3e5954f3 100644
--- a/frontend/src/components/UserGenPage.js
+++ b/frontend/src/components/UserGenPage.js
@@ -11,22 +11,7 @@ import ContentCopy from "@mui/icons-material/ContentCopy";
import RoboSatsNoTextIcon from "./icons/RoboSatsNoTextIcon"
import BoltIcon from '@mui/icons-material/Bolt';
-function getCookie(name) {
- let cookieValue = null;
- if (document.cookie && document.cookie !== '') {
- const cookies = document.cookie.split(';');
- for (let i = 0; i < cookies.length; i++) {
- const cookie = cookies[i].trim();
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) === (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
-}
-const csrftoken = getCookie('csrftoken');
+import { getCookie } from "../utils/cookies";
class UserGenPage extends Component {
constructor(props) {
@@ -59,7 +44,7 @@ class UserGenPage extends Component {
// sort of cryptographically strong function to generate Base62 token client-side
genBase62Token(length)
- {
+ {
return window.btoa(Array.from(
window.crypto.getRandomValues(
new Uint8Array(length * 2)))
@@ -161,7 +146,7 @@ class UserGenPage extends Component {