ad
This commit is contained in:
@@ -75,7 +75,7 @@ const CreateCharacter = () => {
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
'https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/character/create',
|
||||
'http://localhost:5000/games/character/create',
|
||||
formDataToSend,
|
||||
{
|
||||
headers: {
|
||||
|
||||
@@ -60,7 +60,7 @@ const CreateItem = () => {
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
'https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/item/create',
|
||||
'http://localhost:5000/games/item/create',
|
||||
formDataToSend,
|
||||
{
|
||||
headers: {
|
||||
|
||||
@@ -73,7 +73,7 @@ const CreateNpc = () => {
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
'https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/npc/create',
|
||||
'http://localhost:5000/games/npc/create',
|
||||
formDataToSend,
|
||||
{
|
||||
headers: {
|
||||
|
||||
@@ -25,15 +25,15 @@ const GameMasterPage = () => {
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const pcsResponse = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/playerchars`);
|
||||
const pcsResponse = await axios.get(`http://localhost:5000/games/${gameId}/playerchars`);
|
||||
const processedPCs = Array.isArray(pcsResponse.data) ? pcsResponse.data : [pcsResponse.data];
|
||||
setPlayerCharacters(processedPCs.filter(pc => pc !== null));
|
||||
|
||||
const npcsResponse = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/npcs`);
|
||||
const npcsResponse = await axios.get(`http://localhost:5000/games/${gameId}/npcs`);
|
||||
const processedNPCs = Array.isArray(npcsResponse.data) ? npcsResponse.data : [npcsResponse.data];
|
||||
setNpcs(processedNPCs.filter(npc => npc !== null));
|
||||
|
||||
const itemsResponse = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/items`);
|
||||
const itemsResponse = await axios.get(`http://localhost:5000/games/${gameId}/items`);
|
||||
const processedItems = Array.isArray(itemsResponse.data) ? itemsResponse.data : [itemsResponse.data];
|
||||
setItems(processedItems.filter(item => item !== null));
|
||||
} catch (error) {
|
||||
@@ -61,7 +61,7 @@ const GameMasterPage = () => {
|
||||
const fetchOwners = async () => {
|
||||
try {
|
||||
// Only fetch player characters
|
||||
const pcsResponse = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/playerchars`);
|
||||
const pcsResponse = await axios.get(`http://localhost:5000/games/${gameId}/playerchars`);
|
||||
|
||||
const pcs = pcsResponse.data.map(pc => ({
|
||||
id: pc.CharID,
|
||||
@@ -122,7 +122,7 @@ const handleUpdate = async () => {
|
||||
OwnerID: formData.OwnerID,
|
||||
AP: formData.AP
|
||||
};
|
||||
response = await axios.put(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/item/${selectedItem.ItemID}`, itemData);
|
||||
response = await axios.put(`http://localhost:5000/games/item/${selectedItem.ItemID}`, itemData);
|
||||
} else if (editType === 'npc') {
|
||||
// Update NPC data
|
||||
const npcData = {
|
||||
@@ -143,7 +143,7 @@ const handleUpdate = async () => {
|
||||
Level: formData.Level,
|
||||
Allied: formData.Allied
|
||||
};
|
||||
response = await axios.put(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/npc/${selectedItem.NpcID}`, npcData);
|
||||
response = await axios.put(`http://localhost:5000/games/npc/${selectedItem.NpcID}`, npcData);
|
||||
} else if (editType === 'character') {
|
||||
// Update Player Character data
|
||||
const charData = {
|
||||
@@ -164,7 +164,7 @@ const handleUpdate = async () => {
|
||||
level: formData.Level,
|
||||
gold: formData.Gold
|
||||
};
|
||||
response = await axios.put(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/character/${selectedItem.CharID}`, charData);
|
||||
response = await axios.put(`http://localhost:5000/games/character/${selectedItem.CharID}`, charData);
|
||||
}
|
||||
|
||||
if (response.status === 200) {
|
||||
@@ -172,19 +172,19 @@ const handleUpdate = async () => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
// Fetch player characters
|
||||
const pcsResponse = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/playerchars`);
|
||||
const pcsResponse = await axios.get(`http://localhost:5000/games/${gameId}/playerchars`);
|
||||
setPlayerCharacters(
|
||||
Array.isArray(pcsResponse.data) ? pcsResponse.data : [pcsResponse.data]
|
||||
);
|
||||
|
||||
// Fetch NPCs
|
||||
const npcsResponse = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/npcs`);
|
||||
const npcsResponse = await axios.get(`http://localhost:5000/games/${gameId}/npcs`);
|
||||
setNpcs(
|
||||
Array.isArray(npcsResponse.data) ? npcsResponse.data : [npcsResponse.data]
|
||||
);
|
||||
|
||||
// Fetch items
|
||||
const itemsResponse = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/items`);
|
||||
const itemsResponse = await axios.get(`http://localhost:5000/games/${gameId}/items`);
|
||||
setItems(
|
||||
Array.isArray(itemsResponse.data) ? itemsResponse.data : [itemsResponse.data]
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ const GamesPage = () => {
|
||||
const fetchCharacter = async () => {
|
||||
try {
|
||||
console.log(`Fetching character for gameId: ${gameId}, userId: ${userId}`); // Debug output
|
||||
const response = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/${userId}/character`);
|
||||
const response = await axios.get(`http://localhost:5000/games/${gameId}/${userId}/character`);
|
||||
console.log('Character data:', response.data); // Debug output
|
||||
setCharacter(response.data);
|
||||
} catch (error) {
|
||||
@@ -40,7 +40,7 @@ const GamesPage = () => {
|
||||
|
||||
const fetchInventory = async (charId) => {
|
||||
try {
|
||||
const response = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/${charId}/items`);
|
||||
const response = await axios.get(`http://localhost:5000/games/${gameId}/${charId}/items`);
|
||||
setInventory(response.data ? [response.data].flat() : []);
|
||||
} catch (error) {
|
||||
console.error('Error fetching inventory:', error);
|
||||
@@ -75,7 +75,7 @@ const GamesPage = () => {
|
||||
|
||||
try {
|
||||
console.log('Checking if user is game master...');
|
||||
const response = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/master`);
|
||||
const response = await axios.get(`http://localhost:5000/games/${gameId}/master`);
|
||||
console.log('Game data:', response.data);
|
||||
console.log('User ID:', userId);
|
||||
console.log('Game master ID:', response.data.game_master_id);
|
||||
@@ -103,7 +103,7 @@ const GamesPage = () => {
|
||||
|
||||
const handleSaveDescription = async () => {
|
||||
try {
|
||||
const response = await axios.put(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${gameId}/${userId}/character`, { description: newDescription });
|
||||
const response = await axios.put(`http://localhost:5000/games/${gameId}/${userId}/character`, { description: newDescription });
|
||||
setCharacter({ ...character, description: newDescription });
|
||||
setIsEditOpen(false);
|
||||
} catch (error) {
|
||||
|
||||
@@ -19,7 +19,7 @@ const JoinGamePage = () => {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await axios.post(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/joinGame/${gameCode}`, { userId });
|
||||
const response = await axios.post(`http://localhost:5000/joinGame/${gameCode}`, { userId });
|
||||
if (response.status === 201) {
|
||||
setError('');
|
||||
navigate(`/games/${gameCode}`); // Redirect to the games page
|
||||
|
||||
@@ -13,7 +13,7 @@ function Login({ setIsLoggedIn }) {
|
||||
const handleLogin = async (e) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const res = await axios.post('https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/login', { username, password });
|
||||
const res = await axios.post('http://localhost:5000/login', { username, password });
|
||||
setMessage(res.data.message);
|
||||
if (res.data.success) {
|
||||
setIsLoggedIn(true);
|
||||
|
||||
@@ -12,7 +12,7 @@ const Profile = () => {
|
||||
useEffect(() => {
|
||||
const fetchCharacters = async () => {
|
||||
try {
|
||||
const response = await axios.get(`https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/games/${userId}/characters`);
|
||||
const response = await axios.get(`http://localhost:5000/games/${userId}/characters`);
|
||||
const charactersArray = Object.values(response.data);
|
||||
setCharacters(charactersArray);
|
||||
} catch (error) {
|
||||
|
||||
@@ -12,7 +12,7 @@ function Register({ setIsLoggedIn }) {
|
||||
const handleRegister = async (e) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const res = await axios.post('https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/register', { username, email, password });
|
||||
const res = await axios.post('http://localhost:5000/register', { username, email, password });
|
||||
setMessage(res.data.message);
|
||||
setIsLoggedIn(true);
|
||||
navigate('/');
|
||||
|
||||
@@ -30,7 +30,7 @@ const StartGame = () => {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('https://congenial-waddle-9w9749vg9q9cr49-5000.app.github.dev/createGame', {
|
||||
const response = await fetch('http://localhost:5000/createGame', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user