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