-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Newspaper-Advertisement-Analyzer/develop
Deploy Frontend
- Loading branch information
Showing
53 changed files
with
2,014 additions
and
791 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import axios from "axios"; | ||
import baseURL from "config"; | ||
|
||
// Function to delete a user | ||
export async function deleteUser(userId) { | ||
try { | ||
const response = await axios.post(`${baseURL}/delete-user`, { user_ID: userId }); | ||
if (response.status === 200) { | ||
console.log(response.data.message); // Assuming the response has a message field | ||
} else { | ||
console.error("Failed to delete user:", response.statusText); | ||
} | ||
} catch (error) { | ||
console.error("Error deleting user:", error); | ||
throw error; | ||
} | ||
} | ||
|
||
// Function to edit user details | ||
export async function editUser(userId, updatedData) { | ||
try { | ||
const response = await axios.post(`${baseURL}/updateUser`, { | ||
userId: userId, | ||
fullName: updatedData.fullName, | ||
mobile: updatedData.contactNumber, | ||
profession: updatedData.profession, | ||
}); | ||
if (response.status === 200) { | ||
console.log(response.data.message); // Assuming the response has a message field | ||
} else { | ||
console.error("Failed to edit user:", response.statusText); | ||
} | ||
} catch (error) { | ||
console.error("Error editing user:", error); | ||
throw error; | ||
} | ||
} | ||
|
||
// Function to get the list of users | ||
export async function getUserList() { | ||
try { | ||
const response = await axios.get(`${baseURL}/getAllUsers`); | ||
if (response.status === 200) { | ||
return response.data; | ||
} else { | ||
console.error("Failed to fetch user list:", response.statusText); | ||
} | ||
} catch (error) { | ||
console.error("Error fetching user list:", error); | ||
throw error; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import axios from "axios"; | ||
import baseURL from "config"; | ||
|
||
// Function to fetch data from the backend | ||
export async function getPriceFluct() { | ||
try { | ||
const response = await axios.get(`${baseURL}/priceFluctuationData`); // Adjust the endpoint URL | ||
return response.data; | ||
} catch (error) { | ||
console.error("Error fetching data from the backend:", error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import axios from "axios"; | ||
import baseURL from "config"; | ||
|
||
export async function fetchPendingAdvertisements() { | ||
try { | ||
const response = await axios.get(`${baseURL}/pendingAdvertisements`); // Adjust the endpoint URL | ||
return response.data; | ||
} catch (error) { | ||
console.error("Error fetching pending advertisements:", error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,47 @@ | ||
import axios from "axios"; | ||
import baseURL from "config"; | ||
|
||
// Function to fetch a saved PDF report from the backend | ||
export async function getReportPdf(reportId) { | ||
// Function to delete a user | ||
export async function deleteUser(userId) { | ||
try { | ||
const response = await axios.get(`${baseURL}/view-pdf?ReportID=${reportId}`, { | ||
responseType: "blob", // Specify the response type as a blob | ||
}); | ||
const response = await axios.delete(`${baseURL}/users/${userId}`); | ||
if (response.status === 200) { | ||
console.log(`User with ID ${userId} has been deleted`); | ||
} else { | ||
console.error("Failed to delete user:", response.statusText); | ||
} | ||
} catch (error) { | ||
console.error("Error deleting user:", error); | ||
throw error; | ||
} | ||
} | ||
|
||
// Function to edit user details | ||
export async function editUser(userId, updatedData) { | ||
try { | ||
const response = await axios.put(`${baseURL}/users/${userId}`, updatedData); | ||
if (response.status === 200) { | ||
// Create a blob URL for the PDF data | ||
const blob = new Blob([response.data], { type: "application/pdf" }); | ||
const url = window.URL.createObjectURL(blob); | ||
console.log(`User with ID ${userId} has been updated`); | ||
} else { | ||
console.error("Failed to edit user:", response.statusText); | ||
} | ||
} catch (error) { | ||
console.error("Error editing user:", error); | ||
throw error; | ||
} | ||
} | ||
|
||
// Open the PDF in a new tab | ||
window.open(url, "_blank"); | ||
// Function to get the list of users | ||
export async function getUserList() { | ||
try { | ||
const response = await axios.get(`${baseURL}/users`); | ||
if (response.status === 200) { | ||
return response.data; | ||
} else { | ||
console.error("Failed to fetch PDF report:", response.statusText); | ||
console.error("Failed to fetch user list:", response.statusText); | ||
} | ||
} catch (error) { | ||
console.error("Error fetching PDF report:", error); | ||
console.error("Error fetching user list:", error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import axios from "axios"; | ||
import baseURL from "config"; | ||
|
||
export async function submitAdvertisement(formData) { | ||
console.log("submitAdvertisement formData:", formData); | ||
try { | ||
const response = await axios.post(`${baseURL}/submitAdvertisement`, formData); // Adjust the endpoint URL | ||
return response.data; | ||
} catch (error) { | ||
console.error("Error submitting advertisement:", error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.