Labels
Frontend
Description
ByteChain Academy's frontend has several accumulated infrastructure problems that collectively degrade the developer experience and user experience. There is a duplicate <Toaster> component rendering in layout.tsx causing double toast notifications, the frontend has no .env.example file leaving contributors confused about required environment variables, the admin data-fetching hooks use raw useState/useEffect instead of TanStack Query (which is specified in the project architecture), and all lesson video URLs in the codebase still point to a Rick Roll placeholder. This issue cleans all of this up and modernises the data-fetching layer.
Background & Context
frontend/app/layout.tsx renders <Toaster> twice — once inside the provider tree and once after it — causing every notification to appear twice
- There is no
frontend/.env.example file — NEXT_PUBLIC_API_URL is referenced in lib/api.ts but undocumented
frontend/hooks/use-admin-lessons.ts uses raw useState + useEffect + manual setLoading/setError — the project spec requires TanStack Query
frontend/hooks/use-lesson-quiz.ts has the same pattern
- The project architecture document specifies TanStack Query for all client-side data fetching
@tanstack/react-query may not be installed — check package.json and install if missing
Requirements
- Remove the duplicate
<Toaster> from frontend/app/layout.tsx — keep only one instance
- Create
frontend/.env.example with NEXT_PUBLIC_API_URL=http://localhost:3001 and a comment explaining its purpose
- Install
@tanstack/react-query and @tanstack/react-query-devtools if not already present
- Set up a
QueryClientProvider in layout.tsx wrapping the app
- Rewrite
use-admin-lessons.ts using useQuery for fetching and useMutation for create/update/delete operations
- Rewrite
use-lesson-quiz.ts using useQuery for fetching quiz data and useMutation for create/update quiz operations
- Update
frontend/app/admin/courses/[courseId]/lessons/page.tsx to use the new hook signatures if they change
- Replace all hardcoded Rick Roll video URLs (
https://www.youtube.com/embed/dQw4w9WgXcQ) with an empty string or a proper placeholder constant
Suggested Execution
Branch: git checkout -b feat/frontend-infrastructure-cleanup
Files to touch:
frontend/app/layout.tsx
frontend/.env.example ← create this
frontend/package.json
frontend/hooks/use-admin-lessons.ts
frontend/hooks/use-lesson-quiz.ts
frontend/contexts/learning-context.tsx (video URL placeholder)
frontend/app/admin/courses/[courseId]/lessons/page.tsx
Implement:
- Remove duplicate
<Toaster> — keep only the one inside the provider tree
- Create
.env.example with documented env vars
npm install @tanstack/react-query @tanstack/react-query-devtools
- Add
<QueryClientProvider client={queryClient}> in layout.tsx
- Rewrite
useAdminLessons with useQuery({ queryKey: ['lessons', courseId], queryFn: ... })
- Add
useMutation for delete lesson with onSuccess: () => queryClient.invalidateQueries(['lessons', courseId])
- Rewrite
useLessonQuiz with useQuery and useMutation for create/update
- Define
const PLACEHOLDER_VIDEO_URL = '' in a constants file and replace all Rick Roll references
Test & Validate:
- Trigger any action that fires a toast — verify it appears exactly once
- Check
frontend/.env.example documents NEXT_PUBLIC_API_URL
- Admin lessons page loads correctly using the refactored TanStack Query hooks
- Creating, editing, or deleting a lesson correctly invalidates and refetches the lesson list
- No Rick Roll URLs remain anywhere in the codebase (
grep -r "dQw4w9WgXcQ" frontend/ returns empty)
Acceptance Criteria
Example Commit Message
feat: fix duplicate toaster, add env.example, migrate admin hooks to TanStack Query, remove placeholder video URLs
Guidelines
- Assignment required before starting
- PR description must include
Closes #[issue_id]
- Join our Telegram: https://t.me/ByteChainAcademy
- Complexity: High (200 pts)
Labels
FrontendDescription
ByteChain Academy's frontend has several accumulated infrastructure problems that collectively degrade the developer experience and user experience. There is a duplicate
<Toaster>component rendering inlayout.tsxcausing double toast notifications, the frontend has no.env.examplefile leaving contributors confused about required environment variables, the admin data-fetching hooks use rawuseState/useEffectinstead of TanStack Query (which is specified in the project architecture), and all lesson video URLs in the codebase still point to a Rick Roll placeholder. This issue cleans all of this up and modernises the data-fetching layer.Background & Context
frontend/app/layout.tsxrenders<Toaster>twice — once inside the provider tree and once after it — causing every notification to appear twicefrontend/.env.examplefile —NEXT_PUBLIC_API_URLis referenced inlib/api.tsbut undocumentedfrontend/hooks/use-admin-lessons.tsuses rawuseState+useEffect+ manualsetLoading/setError— the project spec requires TanStack Queryfrontend/hooks/use-lesson-quiz.tshas the same pattern@tanstack/react-querymay not be installed — checkpackage.jsonand install if missingRequirements
<Toaster>fromfrontend/app/layout.tsx— keep only one instancefrontend/.env.examplewithNEXT_PUBLIC_API_URL=http://localhost:3001and a comment explaining its purpose@tanstack/react-queryand@tanstack/react-query-devtoolsif not already presentQueryClientProviderinlayout.tsxwrapping the appuse-admin-lessons.tsusinguseQueryfor fetching anduseMutationfor create/update/delete operationsuse-lesson-quiz.tsusinguseQueryfor fetching quiz data anduseMutationfor create/update quiz operationsfrontend/app/admin/courses/[courseId]/lessons/page.tsxto use the new hook signatures if they changehttps://www.youtube.com/embed/dQw4w9WgXcQ) with an empty string or a proper placeholder constantSuggested Execution
Branch:
git checkout -b feat/frontend-infrastructure-cleanupFiles to touch:
frontend/app/layout.tsxfrontend/.env.example← create thisfrontend/package.jsonfrontend/hooks/use-admin-lessons.tsfrontend/hooks/use-lesson-quiz.tsfrontend/contexts/learning-context.tsx(video URL placeholder)frontend/app/admin/courses/[courseId]/lessons/page.tsxImplement:
<Toaster>— keep only the one inside the provider tree.env.examplewith documented env varsnpm install @tanstack/react-query @tanstack/react-query-devtools<QueryClientProvider client={queryClient}>inlayout.tsxuseAdminLessonswithuseQuery({ queryKey: ['lessons', courseId], queryFn: ... })useMutationfor delete lesson withonSuccess: () => queryClient.invalidateQueries(['lessons', courseId])useLessonQuizwithuseQueryanduseMutationfor create/updateconst PLACEHOLDER_VIDEO_URL = ''in a constants file and replace all Rick Roll referencesTest & Validate:
frontend/.env.exampledocumentsNEXT_PUBLIC_API_URLgrep -r "dQw4w9WgXcQ" frontend/returns empty)Acceptance Criteria
<Toaster>exists inlayout.tsxfrontend/.env.exampleexists withNEXT_PUBLIC_API_URLdocumented@tanstack/react-queryis installed andQueryClientProviderwraps the appuse-admin-lessons.tsusesuseQueryanduseMutationuse-lesson-quiz.tsusesuseQueryanduseMutationExample Commit Message
feat: fix duplicate toaster, add env.example, migrate admin hooks to TanStack Query, remove placeholder video URLsGuidelines
Closes #[issue_id]