@@ -42,7 +54,13 @@ export default function PaybuttonForm ({ onSubmit, paybuttons, wallets, error }:
Create Button
diff --git a/components/Paybutton/paybutton.module.css b/components/Paybutton/paybutton.module.css
index 5422864d2..ac88af751 100644
--- a/components/Paybutton/paybutton.module.css
+++ b/components/Paybutton/paybutton.module.css
@@ -463,6 +463,32 @@ body[data-theme='dark'] .form_ctn_outer {
font-weight: 600;
}
+.loading_spinner_ctn {
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 10px;
+ z-index: 5;
+}
+
+.loading_spinner {
+ display: inline-block;
+ width: 24px;
+ height: 24px;
+ border: 3px solid rgba(255,255,255,.3);
+ border-radius: 50%;
+ border-top-color: var(--primary-text-color);
+ animation: spin 1s ease-in-out infinite;
+}
+
+@keyframes spin {
+ to { transform: rotate(360deg); }
+}
@media (max-width: 960px) {
.arrow {
diff --git a/pages/button/[id].tsx b/pages/button/[id].tsx
index 39cac9269..5cec04600 100644
--- a/pages/button/[id].tsx
+++ b/pages/button/[id].tsx
@@ -17,6 +17,7 @@ import { UserProfile } from '@prisma/client'
import { fetchUserProfileFromId } from 'services/userService'
import { removeUnserializableFields } from 'utils'
import moment from 'moment-timezone'
+import LoadingSpinner from 'components/Paybutton/LoadingSpinner'
export const getServerSideProps: GetServerSideProps = async (context) => {
supertokensNode.init(SuperTokensConfig.backendConfig())
@@ -59,6 +60,7 @@ export default function Button (props: PaybuttonProps): React.ReactElement {
const userProfile = props.userProfile
const timezone = userProfile?.preferredTimezone === '' ? moment.tz.guess() : userProfile.preferredTimezone
const router = useRouter()
+ const [loading, setLoading] = useState(false)
const updateIsSyncing = (addressStringList: string[]): void => {
const newIsSyncing = { ...isSyncing }
@@ -118,6 +120,7 @@ export default function Button (props: PaybuttonProps): React.ReactElement {
const downloadCSV = async (paybutton: { id: string, name: string }, currency: string): Promise
=> {
try {
+ setLoading(true)
const preferredCurrencyId = userProfile?.preferredCurrencyId ?? ''
let url = `/api/paybutton/download/transactions/${paybutton.id}?currency=${preferredCurrencyId}`
const isCurrencyEmptyOrUndefined = (value: string): boolean => (value === '' || value === undefined)
@@ -148,6 +151,7 @@ export default function Button (props: PaybuttonProps): React.ReactElement {
} catch (error) {
console.error('An error occurred while downloading the CSV:', error)
} finally {
+ setLoading(false)
setSelectedCurrency('')
}
}
@@ -173,30 +177,32 @@ export default function Button (props: PaybuttonProps): React.ReactElement {
id='export-btn'
value={selectedCurrency}
onChange={handleExport}
+ disabled={loading}
className="button_outline button_small"
style={{ marginBottom: '0', cursor: 'pointer' }}
>
-
+
{Object.entries(NETWORK_TICKERS_FROM_ID)
.filter(([id]) => paybuttonNetworks.includes(Number(id)))
.map(([id, ticker]) => (
))}
)
: (
-
- Export as CSV
-
+ Export as CSV{loading && }
+
)}