Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-the-qa committed Oct 23, 2024
1 parent d011690 commit af2d419
Show file tree
Hide file tree
Showing 2,555 changed files with 693,638 additions and 97 deletions.
94 changes: 0 additions & 94 deletions .gitignore

This file was deleted.

59 changes: 59 additions & 0 deletions dist/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ADPList Review Service</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
#response {
white-space: pre-wrap;
background-color: #f0f0f0;
padding: 10px;
border-radius: 5px;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 300px;
}
</style>
</head>
<body>
<h1>ADPList Review Service</h1>
<div id="userIdForm">
<label for="userId">User ID:</label>
<input type="text" id="userId" required>
<button onclick="submitUserId()">Submit</button>
</div>
<div id="response"></div>
<button onclick="clearResponse()" style="display: none;" id="clearButton">Clear Response</button>

<div id="apiKeyModal" class="modal">
<div class="modal-content">
<h2>Enter Senja API Key</h2>
<input type="password" id="apiKey" required>
<button onclick="submitApiKey()">Submit</button>
</div>
</div>

<script src="script.js"></script>
</body>
</html>
148 changes: 148 additions & 0 deletions dist/public/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
let userId = '';
let adpListResponse = [];
function submitUserId() {
const userIdInput = document.getElementById('userId');
userId = userIdInput.value;
if (userId) {
const apiKeyModal = document.getElementById('apiKeyModal');
apiKeyModal.style.display = 'block';
}
else {
alert('Please enter a User ID');
}
}
function submitApiKey() {
const apiKeyInput = document.getElementById('apiKey');
const apiKey = apiKeyInput.value;
if (apiKey) {
const submitButton = document.querySelector('.modal-content button');
submitButton.disabled = true;
submitButton.textContent = 'Loading...';
fetch('/api/review', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ userId, apiKey }),
})
.then(response => response.json())
.then(data => {
const responseElement = document.getElementById('response');
responseElement.textContent = JSON.stringify(data, null, 2);
const clearButton = document.getElementById('clearButton');
clearButton.style.display = 'block';
const apiKeyModal = document.getElementById('apiKeyModal');
apiKeyModal.style.display = 'none';
})
.catch(error => {
alert('Error: ' + error.message);
})
.finally(() => {
submitButton.disabled = false;
submitButton.textContent = 'Submit';
});
}
else {
alert('Please enter an API Key');
}
}
function clearResponse() {
const responseElement = document.getElementById('response');
responseElement.textContent = '';
const clearButton = document.getElementById('clearButton');
clearButton.style.display = 'none';
const userIdInput = document.getElementById('userId');
userIdInput.value = '';
const apiKeyInput = document.getElementById('apiKey');
apiKeyInput.value = '';
}
document.addEventListener('DOMContentLoaded', () => {
const userIdForm = document.getElementById('userIdForm');
const senjaForm = document.getElementById('senjaForm');
const userIdInput = document.getElementById('userId');
const submitUserIdButton = document.getElementById('submitUserId');
const senjaApiKeyInput = document.getElementById('senjaApiKey');
const submitSenjaApiKeyButton = document.getElementById('submitSenjaApiKey');
const successBanner = document.getElementById('successBanner');
const errorBanner = document.getElementById('errorBanner');
submitUserIdButton.addEventListener('click', () => __awaiter(void 0, void 0, void 0, function* () {
const userId = userIdInput.value.trim();
if (!userId) {
alert('Please enter a User ID');
return;
}
submitUserIdButton.disabled = true;
successBanner.style.display = 'none';
errorBanner.style.display = 'none';
try {
const response = yield fetch('/api/adplist-review', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ userId }),
});
if (!response.ok) {
throw new Error('Failed to fetch ADPList reviews');
}
adpListResponse = yield response.json();
successBanner.textContent = `Successfully fetched ${adpListResponse.length} reviews`;
successBanner.style.display = 'block';
userIdForm.style.display = 'none';
senjaForm.style.display = 'block';
}
catch (error) {
console.error('Error:', error);
errorBanner.style.display = 'block';
}
finally {
submitUserIdButton.disabled = false;
}
}));
submitSenjaApiKeyButton.addEventListener('click', () => __awaiter(void 0, void 0, void 0, function* () {
const senjaApiKey = senjaApiKeyInput.value.trim();
if (!senjaApiKey) {
alert('Please enter a Senja API Key');
return;
}
submitSenjaApiKeyButton.disabled = true;
successBanner.style.display = 'none';
errorBanner.style.display = 'none';
try {
const response = yield fetch('/api/senja-testimonial', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
senjaApiKey,
adpListReviews: adpListResponse
}),
});
if (!response.ok) {
throw new Error('Failed to create Senja testimonials');
}
const results = yield response.json();
successBanner.textContent = `Successfully created ${results.length} testimonials`;
successBanner.style.display = 'block';
}
catch (error) {
console.error('Error:', error);
errorBanner.textContent = 'Failed to create testimonials. Please try again.';
errorBanner.style.display = 'block';
}
finally {
submitSenjaApiKeyButton.disabled = false;
}
}));
});
Loading

0 comments on commit af2d419

Please sign in to comment.