Skip to content

Commit

Permalink
Merge pull request #326 from commerceblock/fix/multiple-slot-with-token
Browse files Browse the repository at this point in the history
fix: multiple slot with a single token
  • Loading branch information
tomt1664 authored Sep 25, 2023
2 parents 0baf635 + a808efb commit 2d502be
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions assets/stylesheets/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3267,6 +3267,13 @@ div#root {
font-size: 30px;
}

.qr-code {
display: flex;
margin-inline: auto;
margin-bottom: 30px;
height: 160px !important;
width: 160px !important;
}

@media (max-width: 575px) {
.carousel-image__overlay {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"nodemailer": "^6.3.0",
"path-to-regexp": "^3.0.0",
"prop-types": "^15.7.2",
"qrcode.react": "^3.1.0",
"query-string": "^6.2.0",
"react": "^16.8.6",
"react-dom": "^16.9.0",
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/api_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ module.exports = {

if (tokenDetails.amount >= FEE_RATE_PER_MONTH_IN_MSAT) {
const months = tokenDetails.amount / FEE_RATE_PER_MONTH_IN_MSAT;
if (slot_id === 0) {
if (!isNaN(slot_id) && Number(slot_id) === 0) {
const clientDetailsData = await create_slot_with_token(months);
reply_msg(res, {
auth_token: clientDetailsData.auth_token,
Expand All @@ -1304,6 +1304,8 @@ module.exports = {
expiry_date: clientDetailsData.expiry_date
}, startTime);
}
tokenDetails.amount = 0;
await tokenDetails.save();
} else {
reply_err(res, 'Token contains insufficient balance', startTime);
}
Expand Down
4 changes: 3 additions & 1 deletion src/view/modals/CreateSlotModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import swal from 'sweetalert';
import {Button, Form, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader, InputGroup, InputGroupAddon} from 'reactstrap';

import apiService from '../../helpers/api-service';
import QRCode from "qrcode.react";

function milliSatsToSats(milliSats) {
return milliSats / 1000;
Expand Down Expand Up @@ -180,7 +181,8 @@ class CreateSlotModal extends React.PureComponent {
) : null}
{this.state.invoice !== '' ? (
<FormGroup>
<Label className="f-bold fs14">Invoice</Label>
<Label className="f-bold fs14">Invoice: </Label>
<QRCode className="qr-code" value={this.state.invoice} />
<InputGroup>
<Input
type="textarea"
Expand Down

0 comments on commit 2d502be

Please sign in to comment.