Skip to content

Commit 6341f69

Browse files
committed
fix assets folder
1 parent daeb275 commit 6341f69

File tree

5 files changed

+501
-10
lines changed

5 files changed

+501
-10
lines changed

.gitignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ c3.php
1616
.codeception.yml
1717
composer.lock
1818
.wp-env.override.json
19-
assets/js/*
20-
!assets/js/README.md
21-
!assets/js/indexeddb.worker.js
22-
assets/css/*
23-
!assets/css/README.md
24-
assets/asset-manifest.json
25-
assets/static
26-
assets/report.html
2719
yarn.lock
2820
.yarn/install-state.gz
2921
.yarn/cache

assets/css/payment.css

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
* SumUp Terminal Payment Interface Styles
3+
*/
4+
5+
#sumup-terminal-payment-interface {
6+
margin: 20px 0;
7+
}
8+
9+
#sumup-terminal-payment-interface h4 {
10+
margin-bottom: 15px;
11+
color: #333;
12+
}
13+
14+
.sumup-reader-card {
15+
border: 1px solid #ddd !important;
16+
padding: 15px !important;
17+
margin: 10px 0 !important;
18+
border-radius: 4px !important;
19+
background: #f9f9f9 !important;
20+
transition: box-shadow 0.3s ease;
21+
}
22+
23+
.sumup-reader-card:hover {
24+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
25+
}
26+
27+
.sumup-reader-card .reader-info {
28+
margin-bottom: 10px;
29+
}
30+
31+
.sumup-reader-card .reader-info strong {
32+
font-size: 14px;
33+
color: #333;
34+
}
35+
36+
.sumup-reader-card .reader-info small {
37+
color: #666;
38+
font-size: 12px;
39+
}
40+
41+
.reader-controls {
42+
margin-top: 10px !important;
43+
}
44+
45+
.sumup-checkout-btn,
46+
.sumup-cancel-btn {
47+
margin-right: 10px;
48+
min-width: 120px;
49+
}
50+
51+
.sumup-checkout-btn:disabled,
52+
.sumup-cancel-btn:disabled {
53+
opacity: 0.6;
54+
cursor: not-allowed;
55+
}
56+
57+
.payment-status {
58+
margin-top: 10px !important;
59+
min-height: 20px;
60+
}
61+
62+
.sumup-status-message,
63+
.sumup-status-success,
64+
.sumup-status-cancelled,
65+
.sumup-status-info,
66+
.sumup-status-error {
67+
padding: 8px 12px;
68+
border-radius: 4px;
69+
margin: 5px 0;
70+
font-size: 14px;
71+
}
72+
73+
.sumup-status-message {
74+
background: #e7f3ff;
75+
border: 1px solid #0073aa;
76+
color: #0073aa;
77+
}
78+
79+
.sumup-status-success {
80+
background: #edfaef;
81+
border: 1px solid #00a32a;
82+
color: #00a32a;
83+
}
84+
85+
.sumup-status-cancelled {
86+
background: #fff3cd;
87+
border: 1px solid #ffeaa7;
88+
color: #856404;
89+
}
90+
91+
.sumup-status-info {
92+
background: #f0f0f1;
93+
border: 1px solid #c3c4c7;
94+
color: #50575e;
95+
}
96+
97+
.sumup-status-error {
98+
background: #fcf0f1;
99+
border: 1px solid #d63638;
100+
color: #d63638;
101+
}
102+
103+
/* Responsive design */
104+
@media (max-width: 600px) {
105+
.sumup-reader-card {
106+
padding: 10px !important;
107+
}
108+
109+
.sumup-checkout-btn,
110+
.sumup-cancel-btn {
111+
width: 100%;
112+
margin: 5px 0;
113+
min-width: auto;
114+
}
115+
}

assets/js/admin.js

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/**
2+
* SumUp Terminal Admin JavaScript
3+
*/
4+
5+
// Make sure the functions are available globally
6+
window.sumupAdmin = {
7+
8+
init: function() {
9+
console.log('SumUp Admin JS initialized');
10+
11+
// Make sure ajaxurl is available
12+
if (typeof ajaxurl === 'undefined') {
13+
window.ajaxurl = sumupAdminData.ajaxUrl;
14+
}
15+
16+
// Test that everything is working
17+
console.log('AJAX URL:', window.ajaxurl);
18+
console.log('Nonce:', sumupAdminData.nonce);
19+
},
20+
21+
testJS: function() {
22+
alert('JavaScript is working! AJAX URL: ' + window.ajaxurl);
23+
console.log('Test JS function called successfully');
24+
},
25+
26+
pairReader: function() {
27+
console.log('sumupPairReader called');
28+
const pairingCode = document.getElementById('sumup-pairing-code');
29+
const resultDiv = document.getElementById('sumup-pair-result');
30+
31+
if (!pairingCode || !resultDiv) {
32+
console.error('Required elements not found');
33+
return;
34+
}
35+
36+
const code = pairingCode.value.trim().toUpperCase();
37+
38+
if (!code) {
39+
resultDiv.innerHTML = '<div style="color: #d63638; margin-top: 10px;">Please enter a pairing code.</div>';
40+
return;
41+
}
42+
43+
resultDiv.innerHTML = '<div style="color: #0073aa; margin-top: 10px;">Pairing reader...</div>';
44+
console.log('Making AJAX request to:', window.ajaxurl);
45+
46+
fetch(window.ajaxurl, {
47+
method: 'POST',
48+
headers: {
49+
'Content-Type': 'application/x-www-form-urlencoded',
50+
},
51+
body: new URLSearchParams({
52+
action: 'sumup_pair_reader',
53+
pairing_code: code,
54+
nonce: sumupAdminData.nonce
55+
})
56+
})
57+
.then(response => {
58+
console.log('Response status:', response.status);
59+
if (!response.ok) {
60+
throw new Error('HTTP ' + response.status);
61+
}
62+
return response.json();
63+
})
64+
.then(data => {
65+
console.log('Response data:', data);
66+
if (data.success) {
67+
resultDiv.innerHTML = '<div style="color: #00a32a; margin-top: 10px;">✓ Reader paired successfully! Refreshing page...</div>';
68+
setTimeout(() => location.reload(), 2000);
69+
} else {
70+
resultDiv.innerHTML = '<div style="color: #d63638; margin-top: 10px;">✗ ' + (data.data || 'Pairing failed') + '</div>';
71+
}
72+
})
73+
.catch(error => {
74+
console.error('AJAX Error:', error);
75+
resultDiv.innerHTML = '<div style="color: #d63638; margin-top: 10px;">✗ Network error: ' + error.message + '</div>';
76+
});
77+
},
78+
79+
unpairReader: function(readerId) {
80+
console.log('sumupUnpairReader called with ID:', readerId);
81+
82+
if (!confirm(sumupAdminData.strings.confirmUnpair)) {
83+
return;
84+
}
85+
86+
fetch(window.ajaxurl, {
87+
method: 'POST',
88+
headers: {
89+
'Content-Type': 'application/x-www-form-urlencoded',
90+
},
91+
body: new URLSearchParams({
92+
action: 'sumup_unpair_reader',
93+
reader_id: readerId,
94+
nonce: sumupAdminData.nonce
95+
})
96+
})
97+
.then(response => response.json())
98+
.then(data => {
99+
if (data.success) {
100+
alert(sumupAdminData.strings.unpairSuccess);
101+
location.reload();
102+
} else {
103+
alert(sumupAdminData.strings.unpairFailed + ' ' + (data.data || sumupAdminData.strings.unknownError));
104+
}
105+
})
106+
.catch(error => {
107+
console.error('AJAX Error:', error);
108+
alert(sumupAdminData.strings.networkError);
109+
});
110+
},
111+
112+
113+
};
114+
115+
// Event delegation for button clicks
116+
function setupEventListeners() {
117+
// Use event delegation to handle dynamically added buttons
118+
document.addEventListener('click', function(event) {
119+
// Check if the clicked element has the sumup-btn class
120+
if (event.target.classList.contains('sumup-btn')) {
121+
event.preventDefault();
122+
123+
const action = event.target.getAttribute('data-action');
124+
console.log('Button clicked with action:', action);
125+
126+
switch (action) {
127+
case 'test-js':
128+
window.sumupAdmin.testJS();
129+
break;
130+
case 'pair-reader':
131+
window.sumupAdmin.pairReader();
132+
break;
133+
case 'unpair-reader':
134+
const readerId = event.target.getAttribute('data-reader-id');
135+
if (readerId) {
136+
window.sumupAdmin.unpairReader(readerId);
137+
}
138+
break;
139+
default:
140+
console.warn('Unknown action:', action);
141+
}
142+
}
143+
});
144+
}
145+
146+
// Initialize when DOM is ready
147+
function initSumupAdmin() {
148+
window.sumupAdmin.init();
149+
setupEventListeners();
150+
}
151+
152+
// Initialize based on DOM state
153+
if (document.readyState === 'loading') {
154+
document.addEventListener('DOMContentLoaded', initSumupAdmin);
155+
} else {
156+
initSumupAdmin();
157+
}
158+
159+
// Legacy global functions for backward compatibility (if needed)
160+
window.sumupTestJS = function() {
161+
window.sumupAdmin.testJS();
162+
};
163+
164+
window.sumupPairReader = function() {
165+
window.sumupAdmin.pairReader();
166+
};
167+
168+
window.sumupUnpairReader = function(readerId) {
169+
window.sumupAdmin.unpairReader(readerId);
170+
};
171+
172+

0 commit comments

Comments
 (0)