Build a React-based admin dashboard to create, edit, and toggle flags. Create a rule builder UI for non-technical users. Show real-time flag evaluation statistics and audit history. By the end, anyone can manage flags without touching code.
← Back to Module 08 overviewnpm create vite@latest dashboard -- --template react-ts cd dashboard npm install
npm run dev starts dev server at http://localhost:5173.Create dashboard/src/components/FlagList.tsx:
import React, { useEffect, useState } from 'react';
import axios from 'axios';
interface Flag {
id: string;
name: string;
description: string;
status: 'off' | 'on' | 'percentage' | 'rules';
percentage_enabled: number;
updated_at: string;
}
export function FlagList() {
const [flags, setFlags] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchFlags = async () => {
try {
const response = await axios.get('/api/flags');
setFlags(response.data.flags);
} catch (err) {
console.error('Failed to fetch flags:', err);
} finally {
setLoading(false);
}
};
fetchFlags();
}, []);
if (loading) return Loading...;
return (
Feature Flags
Name
Status
Updated
Actions
{flags.map(flag => (
{flag.name}
{flag.status}
{new Date(flag.updated_at).toLocaleDateString()}
))}
);
}