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

fix: multiple slot with a single token #326

Merged
merged 2 commits into from
Sep 25, 2023
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
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