diff --git a/backend/controllers/routineController.js b/backend/controllers/routineController.js index dcc47005..ba437d56 100644 --- a/backend/controllers/routineController.js +++ b/backend/controllers/routineController.js @@ -286,12 +286,13 @@ export const updateRoutine = async (req, res) => { } // fetch updated routine details - const { name, description, items } = req.body; + const { name, description, items, isPublic } = req.body; const updates = { ...(name && { name }), ...(description && { description }), ...(items && { items }), + ...(isPublic !== undefined && { isPublic }), }; const routineId = req.params.id; @@ -430,10 +431,10 @@ export const getPublicRoutine = async (req, res) => { try { const routineId = req.params.id; const routine = await Routine.findById(routineId).populate("items.taskId"); - if (!routine) { - return res.status(404).json({ + if (!routine || !routine.isPublic) { + return res.status(403).json({ success: false, - message: "Routine not found", + message: "Routine not found or not public", }); } return res.status(200).json({ success: true, routine }); diff --git a/backend/src/models/Routine.js b/backend/src/models/Routine.js index 3ba7c2a5..6fd5417f 100644 --- a/backend/src/models/Routine.js +++ b/backend/src/models/Routine.js @@ -12,6 +12,10 @@ const routineSchema = mongoose.Schema( required: true, trim: true }, + isPublic: { + type: Boolean, + default: false, + }, description: { type: String, required: false, diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index d8e2a94c..b7753928 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -21,6 +21,7 @@ import ErrorBoundary from "./components/ErrorBoundary.jsx"; import PageTransition from "./components/PageTransition.jsx"; import ShareRoutine from "./pages/ShareRoutine.jsx"; import DailyJournal from "./pages/DailyJournal.jsx"; +import ForgeMode from "./pages/ForgeMode.jsx"; const AuthLayout = ({ children }) => (
@@ -38,9 +39,9 @@ const AnimatedRoutes = () => { path="/" element={ - - - + + + } /> @@ -48,9 +49,11 @@ const AnimatedRoutes = () => { path="/login" element={ - - - + + + + + } /> @@ -58,18 +61,22 @@ const AnimatedRoutes = () => { path="/signup" element={ - - - + + + + + } /> - - + + + + + } /> { } /> + + + + + + } + /> { element={ - + + + } @@ -142,7 +161,9 @@ const AnimatedRoutes = () => { path="/forge" element={ - + + + } /> @@ -150,11 +171,28 @@ const AnimatedRoutes = () => { path="/focus" element={ - + + + } /> - } /> + + + + } + /> + + + + } + /> @@ -166,104 +204,7 @@ const App = () => {
- - - - - - - } - /> - - - - - - } - /> - - - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - - - - } - /> - } /> - } /> - +