Day 9 完了

実装内容:
1. backend/apps/fields/views.py - FieldViewSetをModelViewSetに変更(書き込み可能)
2. frontend/src/components/Navbar.tsx - 圃場管理リンク追加
3. frontend/src/app/fields/page.tsx - 圃場一覧画面
4. frontend/src/app/fields/new/page.tsx - 新規作成画面
5. frontend/src/app/fields/[id]/page.tsx - 編集画面
API CRUDテスト結果:
- POST /api/fields/ → 201 Created
- GET /api/fields/ → 200 OK
- PATCH /api/fields/{id}/ → 200 OK
- DELETE /api/fields/{id}/ → 204 No Content
ブラウザで http://localhost:3000/fields から圃場のCRUD操作が可能です。
次の工程に移りますか?
This commit is contained in:
Akira
2026-02-15 13:34:32 +09:00
parent afd434cd4c
commit 923dd5dece
5 changed files with 605 additions and 5 deletions

View File

@@ -1,23 +1,49 @@
'use client';
import { useRouter } from 'next/navigation';
import { LogOut } from 'lucide-react';
import { useRouter, usePathname } from 'next/navigation';
import { LogOut, Wheat, MapPin } from 'lucide-react';
import { logout } from '@/lib/api';
export default function Navbar() {
const router = useRouter();
const pathname = usePathname();
const handleLogout = () => {
logout();
};
const isActive = (path: string) => pathname === path;
return (
<nav className="bg-white shadow-sm border-b border-gray-200">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex justify-between h-16">
<div className="flex items-center">
<div className="flex items-center space-x-8">
<h1 className="text-xl font-bold text-green-700">KeinaSystem</h1>
<span className="ml-2 text-sm text-gray-500"></span>
<div className="flex items-center space-x-4">
<button
onClick={() => router.push('/allocation')}
className={`flex items-center px-3 py-2 text-sm rounded-md transition-colors ${
isActive('/allocation')
? 'text-green-700 bg-green-50'
: 'text-gray-700 hover:text-gray-900 hover:bg-gray-100'
}`}
>
<Wheat className="h-4 w-4 mr-2" />
</button>
<button
onClick={() => router.push('/fields')}
className={`flex items-center px-3 py-2 text-sm rounded-md transition-colors ${
isActive('/fields') || pathname?.startsWith('/fields/')
? 'text-green-700 bg-green-50'
: 'text-gray-700 hover:text-gray-900 hover:bg-gray-100'
}`}
>
<MapPin className="h-4 w-4 mr-2" />
</button>
</div>
</div>
<div className="flex items-center">
<button