refac: move map to each dialoge

This commit is contained in:
Sosokker 2025-02-14 09:24:59 +07:00
parent 0c16743230
commit 8f5459acf9
5 changed files with 86 additions and 8 deletions

View File

@ -1,12 +1,14 @@
"use client";
import { useState } from "react";
import { Dialog, DialogContent } from "@/components/ui/dialog";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Check, MapPin } from "lucide-react";
import { cn } from "@/lib/utils";
import type { Crop } from "@/types";
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
import GoogleMapWithDrawing from "@/components/google-map-with-drawing";
interface Plant {
id: string;
@ -61,6 +63,9 @@ export function CropDialog({ open, onOpenChange, onSubmit }: CropDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<VisuallyHidden>
<DialogTitle></DialogTitle>
</VisuallyHidden>
<DialogContent className="sm:max-w-[900px] p-0">
<div className="grid md:grid-cols-2 h-[600px]">
{/* Left side - Plant Selection */}
@ -97,9 +102,9 @@ export function CropDialog({ open, onOpenChange, onSubmit }: CropDialogProps) {
{/* Right side - Map */}
<div className="relative">
<div className="absolute inset-0 bg-muted/10">
{/* Placeholder map - Replace with your map component */}
<div className="h-full w-full bg-muted/20 flex items-center justify-center">
<div className="text-center space-y-2">
<GoogleMapWithDrawing />
{/* <div className="text-center space-y-2">
<MapPin className="h-8 w-8 mx-auto text-muted-foreground" />
<p className="text-sm text-muted-foreground">
Map placeholder
@ -108,7 +113,7 @@ export function CropDialog({ open, onOpenChange, onSubmit }: CropDialogProps) {
<br />
Lng: {location.lng.toFixed(4)}
</p>
</div>
</div> */}
</div>
</div>
</div>

View File

@ -25,6 +25,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { ChatbotDialog } from "./chatbot-dialog";
import { AnalyticsDialog } from "./analytics-dialog";
import type { Crop, CropAnalytics } from "@/types";
import GoogleMapWithDrawing from "@/components/google-map-with-drawing";
const getCropById = (id: string): Crop => {
return {
@ -204,17 +205,18 @@ export default function CropDetailPage({ params }: { params: Promise<{ farmId: s
</div>
<div className="space-y-6">
<Card className="h-[400px]">
<Card className="h-[400px] mb-32">
<CardContent className="p-0 h-full">
<GoogleMapWithDrawing />
<div className="h-full w-full bg-muted/20 flex items-center justify-center">
<div className="text-center space-y-2">
{/* <div className="text-center space-y-2">
<MapPin className="h-8 w-8 mx-auto text-muted-foreground" />
<p className="text-sm text-muted-foreground">
Map placeholder
<br />
Click to view full map
</p>
</div>
</div> */}
</div>
</CardContent>
</Card>

View File

@ -1,7 +1,7 @@
import PlantingDetailsForm from "./planting-detail-form";
import HarvestDetailsForm from "./harvest-detail-form";
import { Separator } from "@/components/ui/separator";
import GoogleMapWithDrawing from "./google-map-with-drawing";
import GoogleMapWithDrawing from "@/components/google-map-with-drawing";
export default function SetupPage() {
return (

71
to_insert.sql Normal file
View File

@ -0,0 +1,71 @@
INSERT INTO light_profiles (name)
VALUES
('Full Sun'),
('Partial Shade'),
('Full Shade');
INSERT INTO soil_conditions (name)
VALUES
('Loamy'),
('Sandy'),
('Clay'),
('Silty');
INSERT INTO harvest_units (name)
VALUES
('Kilograms'),
('Pounds'),
('Bushels'),
('Tons');
INSERT INTO plants (
uuid, name, variety, row_spacing, optimal_temp, planting_depth, average_height,
light_profile_id, soil_condition_id, planting_detail, is_perennial, days_to_emerge,
days_to_flower, days_to_maturity, harvest_window, ph_value, estimate_loss_rate,
estimate_revenue_per_hu, harvest_unit_id, water_needs
)
VALUES
(
'450e8400-e29b-41d4-a716-446655440000', -- UUID
'Tomato', -- Name
'Cherry', -- Variety
0.5, -- Row Spacing (meters)
25.0, -- Optimal Temperature (°C)
0.02, -- Planting Depth (meters)
1.5, -- Average Height (meters)
1, -- Light Profile ID (Full Sun)
1, -- Soil Condition ID (Loamy)
'Plant in well-drained soil.', -- Planting Detail
FALSE, -- Is Perennial
7, -- Days to Emerge
60, -- Days to Flower
90, -- Days to Maturity
14, -- Harvest Window (days)
6.5, -- pH Value
0.1, -- Estimate Loss Rate
10.0, -- Estimate Revenue per Harvest Unit
1, -- Harvest Unit ID (Kilograms)
2.5 -- Water Needs (liters per day)
),
(
'550e8400-e29b-41d4-a716-446655440001', -- UUID
'Corn', -- Name
'Sweet', -- Variety
0.75, -- Row Spacing (meters)
30.0, -- Optimal Temperature (°C)
0.05, -- Planting Depth (meters)
2.0, -- Average Height (meters)
1, -- Light Profile ID (Full Sun)
2, -- Soil Condition ID (Sandy)
'Plant in rows with adequate spacing.', -- Planting Detail
FALSE, -- Is Perennial
10, -- Days to Emerge
70, -- Days to Flower
100, -- Days to Maturity
21, -- Harvest Window (days)
6.0, -- pH Value
0.15, -- Estimate Loss Rate
8.0, -- Estimate Revenue per Harvest Unit
2, -- Harvest Unit ID (Pounds)
3.0 -- Water Needs (liters per day)
);