-
-
-
Profile Setup
-
-
-
-
-
-
-
-
-
-
-
- Abbreviation |
- Name |
-
-
-
-
-
-
-
Save Sections
-
+
-
- // Function to convert file to base64 string
- function convertToBase64(file) {
- return new Promise((resolve, reject) => {
- const reader = new FileReader();
- reader.readAsDataURL(file);
- reader.onload = () => resolve(reader.result.split(',')[1]);
- reader.onerror = error => reject(error);
- });
- }
- // Function to send profile picture to server
- async function sendProfilePicture(base64String) {
- const URL = `${pythonURI}/api/id/pfp`; // Adjust endpoint as needed
- const options = {
- ...fetchOptions,
- method: 'POST',
- body: JSON.stringify({ base64String }),
- };
- const response = await fetch(URL, options);
- if (!response.ok) {
- throw new Error(`Failed to upload profile picture: ${response.status}`);
- }
- // Handle success response as needed
- }
-
- // Function to save sections (example action)
- function saveSections() {
- const URL = `${pythonURI}/api/user/section`; // Adjusted endpoint
-
- const sectionsData = {
- sections: userSections
- };
-
- const options = {
- ...fetchOptions,
- method: 'POST',
- headers: {
- ...fetchOptions.headers,
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(sectionsData)
- };
-
- fetch(URL, options)
- .then(response => {
- if (!response.ok) {
- throw new Error(`Failed to save sections: ${response.status}`);
- }
- // Handle success response as needed
- console.log('Sections saved successfully!');
- })
- .catch(error => {
- console.error('Error saving sections:', error.message);
- // Handle error display or fallback mechanism
- });
- }
-