← Back to Main Page

Module 4: Build Sprint 3

Understanding Your Third Ticket

Learn how to approach your third ticket in the Labs project and understand the development workflow.

Third Ticket Details

View your third ticket details and requirements on GitHub:

Third Ticket Documentation

Approaching Your Third Feature

Learn how to implement a React client application that integrates with your backend API.

Implementation Checklist

  • Review and select 3 pages from the provided wireframes
  • Set up React project structure and routing
  • Implement authentication flow with JWT
  • Create reusable components for common UI elements
  • Integrate with backend API endpoints
  • Implement responsive design
  • Add error handling and loading states

React Project Structure

// Example project structure
src/
├── components/
│   ├── common/
│   │   ├── Button.jsx
│   │   ├── Card.jsx
│   │   └── Navbar.jsx
│   ├── auth/
│   │   ├── LoginForm.jsx
│   │   └── ProtectedRoute.jsx
│   └── pages/
│       ├── Home.jsx
│       ├── Dashboard.jsx
│       └── AssignmentView.jsx
├── services/
│   ├── api.js
│   └── auth.js
├── context/
│   └── AuthContext.jsx
└── utils/
    └── helpers.js

Authentication Context Example

// Example of authentication context setup
import { createContext, useContext, useState } from 'react';

const AuthContext = createContext();

export function AuthProvider({ children }) {
    const [user, setUser] = useState(null);
    const [loading, setLoading] = useState(true);

    const login = async (credentials) => {
        try {
            const response = await api.post('/api/auth/login', credentials);
            const { token } = response.data;
            localStorage.setItem('token', token);
            setUser(response.data.user);
        } catch (error) {
            throw error;
        }
    };

    return (
        
            {children}
        
    );
}

API Service Example

// Example of API service setup
import axios from 'axios';

const api = axios.create({
    baseURL: process.env.REACT_APP_API_URL,
    headers: {
        'Content-Type': 'application/json'
    }
});

// Add request interceptor for auth token
api.interceptors.request.use(config => {
    const token = localStorage.getItem('token');
    if (token) {
        config.headers.Authorization = `Bearer ${token}`;
    }
    return config;
});

export const getAssignments = () => api.get('/api/assignments');
export const getAssignmentById = (id) => api.get(`/api/assignments/${id}`);
export const updateAssignment = (id, data) => api.put(`/api/assignments/${id}`, data);

React Overview

Review essential React concepts and frontend development practices for building the client application.

Login Setup

HTML, CSS, & JS Primer

Assignments Overview