program finalizat
This commit is contained in:
+48
-46
@@ -1,3 +1,14 @@
|
||||
let codeOk = '';
|
||||
let codeGetDepartments = '';
|
||||
let codeSignUp = '';
|
||||
let userData = {
|
||||
email: null,
|
||||
name: null,
|
||||
password: null,
|
||||
app_type: null,
|
||||
departmentId: null
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async function () {
|
||||
const nextToStep2Button = document.getElementById('nextToStep2');
|
||||
const backToStep1Button = document.getElementById('backToStep1');
|
||||
@@ -7,15 +18,6 @@ document.addEventListener('DOMContentLoaded', async function () {
|
||||
const step1 = document.getElementById('step1');
|
||||
const step2 = document.getElementById('step2');
|
||||
|
||||
// This object will hold the user data
|
||||
let userData = {
|
||||
email: null,
|
||||
name: null,
|
||||
password: null,
|
||||
app_type: null,
|
||||
departmentId: null
|
||||
};
|
||||
|
||||
if (!await window.electronAPI.openUcSocket()) {
|
||||
alert('Internal error of the application.');
|
||||
return;
|
||||
@@ -27,16 +29,15 @@ document.addEventListener('DOMContentLoaded', async function () {
|
||||
return;
|
||||
}
|
||||
|
||||
const codeGetDepartments = operationCodes.GET_DEPARTMENTS;
|
||||
const codeSignUp = operationCodes.SIGN_UP;
|
||||
const codeOk = operationCodes.OK;
|
||||
codeGetDepartments = operationCodes.GET_DEPARTMENTS;
|
||||
codeSignUp = operationCodes.SIGN_UP;
|
||||
codeOk = operationCodes.OK;
|
||||
|
||||
let departments = await getDepartments();
|
||||
if (departments === null) {
|
||||
await window.electronAPI.showAlert('Failed to fetch departments.');
|
||||
return;
|
||||
}
|
||||
console.log(departments);
|
||||
|
||||
// Handle form submission for Step 1 (Profile Information)
|
||||
nextToStep2Button.addEventListener('click', async function (e) {
|
||||
@@ -98,37 +99,38 @@ document.addEventListener('DOMContentLoaded', async function () {
|
||||
await window.electronAPI.closeUcSocket();
|
||||
await window.electronAPI.changeContent('login');
|
||||
});
|
||||
|
||||
async function getDepartments() {
|
||||
if (!await window.electronAPI.sendUcMessage(codeGetDepartments)) return null;
|
||||
|
||||
const response = await waitForResponse();
|
||||
if (response && response.operationCode === codeOk) {
|
||||
return response.metaInfo.departments;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function attemptSignUp() {
|
||||
if (!await window.electronAPI.sendUcMessage(codeSignUp, userData)) return false;
|
||||
|
||||
const response = await waitForResponse();
|
||||
if (response && response.operationCode === codeOk) {
|
||||
return true;
|
||||
}
|
||||
await window.electronAPI.showAlert(`Signup failed: ${response?.metaInfo?.message || 'Unknown error'}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Function to switch between steps
|
||||
function switchStep(fromStep, toStep) {
|
||||
fromStep.classList.remove('active'); // Fade out the current step
|
||||
setTimeout(() => {
|
||||
fromStep.style.display = 'none'; // Hide the current step after transition
|
||||
toStep.style.display = 'flex'; // Ensure display is flex for the next step
|
||||
setTimeout(() => {
|
||||
toStep.classList.add('active'); // Fade in the next step
|
||||
}, 20); // Small delay to allow display change before applying opacity
|
||||
}, 500); // Transition duration (0.5s)
|
||||
}
|
||||
});
|
||||
|
||||
async function getDepartments() {
|
||||
if (!await window.electronAPI.sendUcMessage('GET_DEPARTMENTS')) return null;
|
||||
|
||||
const response = await waitForResponse();
|
||||
console.log(response);
|
||||
if (response && response.operationCode === codeOk) {
|
||||
return response.metaInfo.departments;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function attemptSignUp() {
|
||||
if (!await window.electronAPI.sendUcMessage(codeSignUp, userData)) return false;
|
||||
|
||||
const response = await waitForResponse();
|
||||
if (response && response.operationCode === codeOk) {
|
||||
return true;
|
||||
}
|
||||
await window.electronAPI.showAlert(`Signup failed: ${response?.metaInfo?.message || 'Unknown error'}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Function to switch between steps
|
||||
function switchStep(fromStep, toStep) {
|
||||
fromStep.classList.remove('active'); // Fade out the current step
|
||||
setTimeout(() => {
|
||||
fromStep.style.display = 'none'; // Hide the current step after transition
|
||||
toStep.style.display = 'flex'; // Ensure display is flex for the next step
|
||||
setTimeout(() => {
|
||||
toStep.classList.add('active'); // Fade in the next step
|
||||
}, 20); // Small delay to allow display change before applying opacity
|
||||
}, 500); // Transition duration (0.5s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user