From b85278998a61620853e0cfa0c5584506790d51a2 Mon Sep 17 00:00:00 2001 From: Anyer Date: Thu, 29 May 2025 17:52:53 +0200 Subject: [PATCH 1/3] token --- src/api.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api.js b/src/api.js index 0b7703e..0b75f23 100644 --- a/src/api.js +++ b/src/api.js @@ -9,8 +9,16 @@ const baseURL = isLocalhost ? 'http://127.0.0.1:8000/' : 'http://187.33.149.121:8000/'; +const token = isLocalhost + ? '5fc8db25bf14ab3c73c9ba1aee9c24041417eb1a' + : 'f9362bf38eff64c300ec094dc050ca76906e0ede'; + const api = axios.create({ baseURL, + headers: { + Authorization: `Token ${token}`, + Accept: 'application/json', + } }); export default api; \ No newline at end of file From 8f9f1515c2efd568215c9cd460374256a5063edf Mon Sep 17 00:00:00 2001 From: Anyer Date: Thu, 29 May 2025 19:37:58 +0200 Subject: [PATCH 2/3] . --- src/pages/ChatbotEditor.tsx | 12 ++++++++---- src/pages/MainPage.tsx | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/ChatbotEditor.tsx b/src/pages/ChatbotEditor.tsx index c065456..a904221 100644 --- a/src/pages/ChatbotEditor.tsx +++ b/src/pages/ChatbotEditor.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { useNavigate, useParams } from 'react-router-dom'; +import { useNavigate, useParams, useLocation } from 'react-router-dom'; import { ArrowLeft, Bot } from 'lucide-react'; import api from '../api'; @@ -9,8 +9,12 @@ const ChatbotEditor = () => { const [name, setName] = useState(''); const [description, setDescription] = useState(''); const [loading, setLoading] = useState(!!id); - - useEffect(() => { + const query = new URLSearchParams(useLocation().search); + const name2 = query.get("name"); // Ex: "BotXpert" + const description2 = query.get("description"); + setName(name2 || ''); + setDescription(description2 || ''); + /*useEffect(() => { if (id) { const fetchBot = async () => { try { @@ -26,7 +30,7 @@ const ChatbotEditor = () => { }; fetchBot(); } - }, [id]); + }, [id]);*/ const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); diff --git a/src/pages/MainPage.tsx b/src/pages/MainPage.tsx index ab3d596..73ea606 100644 --- a/src/pages/MainPage.tsx +++ b/src/pages/MainPage.tsx @@ -113,7 +113,7 @@ function Dashboard() { {/* Chatbot List */} {chatbots.map((bot) => ( -
navigate(`/chatbot/${bot.id}`)}> +
navigate(`/chatbot/${bot.id}?name=${encodeURIComponent(bot.name)}&description=${encodeURIComponent(bot.description)}`)}>
From 3b0396c2b6d03f324f6b70707e3201c16f272bed Mon Sep 17 00:00:00 2001 From: Anyer Date: Thu, 29 May 2025 19:41:18 +0200 Subject: [PATCH 3/3] . --- src/pages/ChatbotEditor.tsx | 12 ++++-------- src/pages/MainPage.tsx | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/pages/ChatbotEditor.tsx b/src/pages/ChatbotEditor.tsx index a904221..c065456 100644 --- a/src/pages/ChatbotEditor.tsx +++ b/src/pages/ChatbotEditor.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { useNavigate, useParams, useLocation } from 'react-router-dom'; +import { useNavigate, useParams } from 'react-router-dom'; import { ArrowLeft, Bot } from 'lucide-react'; import api from '../api'; @@ -9,12 +9,8 @@ const ChatbotEditor = () => { const [name, setName] = useState(''); const [description, setDescription] = useState(''); const [loading, setLoading] = useState(!!id); - const query = new URLSearchParams(useLocation().search); - const name2 = query.get("name"); // Ex: "BotXpert" - const description2 = query.get("description"); - setName(name2 || ''); - setDescription(description2 || ''); - /*useEffect(() => { + + useEffect(() => { if (id) { const fetchBot = async () => { try { @@ -30,7 +26,7 @@ const ChatbotEditor = () => { }; fetchBot(); } - }, [id]);*/ + }, [id]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); diff --git a/src/pages/MainPage.tsx b/src/pages/MainPage.tsx index 73ea606..ab3d596 100644 --- a/src/pages/MainPage.tsx +++ b/src/pages/MainPage.tsx @@ -113,7 +113,7 @@ function Dashboard() { {/* Chatbot List */} {chatbots.map((bot) => ( -
navigate(`/chatbot/${bot.id}?name=${encodeURIComponent(bot.name)}&description=${encodeURIComponent(bot.description)}`)}> +
navigate(`/chatbot/${bot.id}`)}>