summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/package-lock.json21
-rw-r--r--client/package.json1
-rw-r--r--client/src/Influencers.js28
3 files changed, 15 insertions, 35 deletions
diff --git a/client/package-lock.json b/client/package-lock.json
index 8efb06a..a6fa0c1 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -12,7 +12,6 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.2",
- "dotenv": "^16.4.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.24.0",
@@ -7764,15 +7763,12 @@
}
},
"node_modules/dotenv": {
- "version": "16.4.5",
- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
- "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
+ "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
"license": "BSD-2-Clause",
"engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://dotenvx.com"
+ "node": ">=10"
}
},
"node_modules/dotenv-expand": {
@@ -16407,15 +16403,6 @@
}
}
},
- "node_modules/react-scripts/node_modules/dotenv": {
- "version": "10.0.0",
- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
- "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
- "license": "BSD-2-Clause",
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/read-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
diff --git a/client/package.json b/client/package.json
index 71228a9..70e70ca 100644
--- a/client/package.json
+++ b/client/package.json
@@ -7,7 +7,6 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.2",
- "dotenv": "^16.4.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.24.0",
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"