summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/Influencers.js28
1 files changed, 11 insertions, 17 deletions
diff --git a/client/src/Influencers.js b/client/src/Influencers.js
index cfa28d9..a72d654 100644
--- a/client/src/Influencers.js
+++ b/client/src/Influencers.js
@@ -1,18 +1,16 @@
import React, { useState, useEffect, useCallback } from 'react';
import axios from 'axios';
-require('dotenv').config();
-function Influencers() {
+function Influencers({ adminPassword }) {
const [profiles, setProfiles] = useState([]);
const [newProfile, setNewProfile] = useState('');
- const adminPassword = process.env.ADMIN_PASSWROD;
-
const fetchProfiles = useCallback(async () => {
try {
- const response = await axios.get('http://localhost:5001/influencers', {
- headers: { 'x-admin-password': adminPassword }
+ const response = await axios.get('http://localhost:5001/profiles', {
+ headers: { Authorization: `Bearer ${adminPassword}` }
});
+ console.log('Fetched profiles:', response.data);
setProfiles(response.data);
} catch (error) {
console.error('Error fetching profiles:', error);
@@ -25,13 +23,11 @@ function Influencers() {
const addProfile = async () => {
try {
- const updatedProfiles = [...profiles, newProfile];
await axios.post(
- 'http://localhost:5001/influencers',
- { profiles: updatedProfiles },
- { headers: { 'x-admin-password': adminPassword } }
+ 'http://localhost:5001/profiles',
+ { username: newProfile },
+ { headers: { Authorization: `Bearer ${adminPassword}` } }
);
- setProfiles(updatedProfiles);
setNewProfile('');
fetchProfiles();
} catch (error) {
@@ -46,10 +42,10 @@ function Influencers() {
formData.append('file', file);
try {
- await axios.post('http://localhost:5001/import-influencers', formData, {
+ await axios.post('http://localhost:5001/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
- 'x-admin-password': adminPassword
+ Authorization: `Bearer ${adminPassword}`
}
});
fetchProfiles();
@@ -61,8 +57,8 @@ function Influencers() {
const exportJson = async () => {
try {
- const response = await axios.get('http://localhost:5001/export-influencers', {
- headers: { 'x-admin-password': adminPassword },
+ const response = await axios.get('http://localhost:5001/export', {
+ headers: { Authorization: `Bearer ${adminPassword}` },
responseType: 'blob'
});
const url = window.URL.createObjectURL(new Blob([response.data]));
@@ -86,14 +82,12 @@ function Influencers() {
placeholder="Enter Instagram username"
/>
<button onClick={addProfile}>Add</button>
-
<h3>Current Influencers</h3>
<ul>
{profiles.map((profile, index) => (
<li key={index}>{profile}</li>
))}
</ul>
-
<h3>Import/Export Influencers</h3>
<input
type="file"