Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/controllers/questController.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ const showUserQuests = async (req, res) => {
});

if (!filteredQuests.length) {
return res.status(404).json({
success: false,
return res.status(200).json({
success: true,
response: [],
message: "No quests",
message: "No quests yet",
});
}
return res
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { Link, useNavigate } from 'react-router-dom'
import { useEffect, useState } from 'react'
import { apiUrl } from '../../api'
import { useUserStore } from '../stores/useUserStore'
import { useQuestStore } from '../stores/useQuestStore'

export const LoginForm = () => {
const fetchQuests = useQuestStore((state) => state.fetchQuests)
// State variables to store form input values
// const [name, setName] = useState('')
const [email, setEmail] = useState('')
Expand Down Expand Up @@ -62,7 +64,7 @@ export const LoginForm = () => {

login({
accessToken: data.accessToken,
userId: data.id,
userId: data.userID,
email: email,
name: data.name // check what the API actually returns here
})
Expand All @@ -77,6 +79,8 @@ export const LoginForm = () => {
// Clear the form inputs
setEmail('')
setPassword('')

await fetchQuests(data.accessToken)

// When signed up successfully -> redirect to profile page
navigate('/')
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/useQuestStore.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const useQuestStore = create((set) => ({

if (!response.ok) return { success: false, error: data.message };

set((state) => ({ quests: [...state.quests, data] }));
set((state) => ({ quests: [...state.quests, data.response || data] }))
return { success: true };
} catch (error) {
return { success: false, error: "Something went wrong" };
Expand Down