Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
bc4e75f
Rename `p_date_acquiring` to `p_acquiring_date` anc convert type from…
SvenVw Dec 5, 2024
320e55d
Improve and extend documentation for fertilizers
SvenVw Dec 5, 2024
4189f5d
Add `fertilizer_application` table
SvenVw Dec 5, 2024
f64d75f
Rename p_amount to p_app_amount
SvenVw Dec 5, 2024
b0c001e
Add functions `addFertilizerApplication`, `updateFertilizerApplicatio…
SvenVw Dec 5, 2024
e13e826
Fixes
SvenVw Dec 5, 2024
b846996
Export the new functions
SvenVw Dec 5, 2024
81caa2e
Fix enum
SvenVw Dec 5, 2024
9525388
Fix
SvenVw Dec 5, 2024
6e0b6be
Fix renaming
SvenVw Dec 5, 2024
31476c3
Expand tests for fertilizer applications
SvenVw Dec 5, 2024
7af3fda
Rename `p_amount` at `fertilizer_acquiring` to `p_acquiring_amount`
SvenVw Dec 5, 2024
a948c61
Fix by adding `b_name` to output type of `getCultivationPlan`
SvenVw Dec 5, 2024
4460722
Fix naming of p_app_amount
SvenVw Dec 5, 2024
61da12f
Add to output of `getCultivationPlan` the `fertilizer_applications`
SvenVw Dec 5, 2024
be8d2ea
Submit something when adding
SvenVw Dec 5, 2024
aab6c96
Upgrade date input to input picker
SvenVw Dec 5, 2024
9ed8c89
Merge remote-tracking branch 'origin/main' into add-fertilizer-applic…
SvenVw Dec 11, 2024
c10e25c
Fix migration issue
SvenVw Dec 12, 2024
e2a4bd8
Refactor cultivation plan page
SvenVw Dec 12, 2024
3c878ff
Start converting to form
SvenVw Dec 12, 2024
761a20d
Add date picker to form
SvenVw Dec 12, 2024
55313cf
Include the combobox to the form
SvenVw Dec 12, 2024
eb7bd66
Fixes
SvenVw Dec 12, 2024
92bae8b
Remove old code
SvenVw Dec 12, 2024
4112897
Remove selection of fertilizers for acquiring but select all fertilizers
SvenVw Dec 12, 2024
efa423d
Export `getFertilizer` and `getFertilizers`
SvenVw Dec 12, 2024
5be0abc
`getFertilizers` returns the details of the fertilizers similiar as `…
SvenVw Dec 12, 2024
6ef3d44
Alter `p_acquiring_date` and `p_picking_date` from date to timestamptz
SvenVw Dec 12, 2024
423b18b
Save the applications to the db
SvenVw Dec 12, 2024
c8c9ca6
Add feedback that fertilizer application is saved
SvenVw Dec 12, 2024
9484ca2
Show fertilizers applied
SvenVw Dec 13, 2024
071526e
Fix returning all fertilizer applications
SvenVw Dec 13, 2024
296e476
Fix aligning
SvenVw Dec 13, 2024
7db0478
Reset form after submission
SvenVw Dec 13, 2024
6ab9f5f
Improve alignment
SvenVw Dec 13, 2024
78a0074
Return the p_app_id's for a cultivation
SvenVw Dec 16, 2024
d2bb50c
Add deletion of fertilizer applications
SvenVw Dec 16, 2024
eb2c064
Update the blocks for crop and catch crop
SvenVw Dec 16, 2024
2f011d6
Rename the FertilizerApplicationsForm
SvenVw Dec 16, 2024
bee0e62
Add changeset
SvenVw Dec 16, 2024
7fa5bbf
Combine into single db migration
SvenVw Dec 16, 2024
b1981e2
Small fixes
SvenVw Dec 16, 2024
ac824d0
Bump version numbers and update changelog
SvenVw Dec 16, 2024
878ddb5
Update fdm-app/app/routes/app.addfarm.$b_id_farm.cultivations.$b_lu_c…
SvenVw Dec 16, 2024
69f47ec
Ensure p_app_method parameter is correctly handled in addFertilizerAp…
SvenVw Dec 16, 2024
9862df6
Use consistent b_lu_catalogue variable when adding cultivations
SvenVw Dec 16, 2024
4e6e8bb
Update fdm-app/app/root.tsx
SvenVw Dec 16, 2024
c846c0f
Add validation for b_id and p_id before inserting
SvenVw Dec 16, 2024
2623632
Update fdm-app/app/routes/app.addfarm.new.tsx
SvenVw Dec 16, 2024
a5883f3
Upgrade tsconfig to ES2022
SvenVw Dec 16, 2024
4db3182
Fix error message
SvenVw Dec 16, 2024
6e41e54
Update fdm-app/app/routes/app.addfarm.$b_id_farm.cultivations.$b_lu_c…
SvenVw Dec 16, 2024
6173e46
Add type checking for form data
SvenVw Dec 16, 2024
d6e5e22
merge
SvenVw Dec 16, 2024
6bff009
Review form initialization values.
SvenVw Dec 16, 2024
be29e5a
Fix comparison
SvenVw Dec 16, 2024
f7c94ce
Resolve component redeclaration
SvenVw Dec 16, 2024
74a768b
Add loading state and error handling to delete operation.
SvenVw Dec 16, 2024
fdbf240
Remove console.log
SvenVw Dec 16, 2024
3c410e2
Add proper TypeScript types for props.
SvenVw Dec 16, 2024
6c21a08
Improve toast with addFarm
SvenVw Dec 16, 2024
3dd4f44
Improve type
SvenVw Dec 16, 2024
098e8d0
Update fdm-app/app/routes/app.addfarm.new.tsx
SvenVw Dec 16, 2024
d1eb1b2
Upgrade to ES2022
SvenVw Dec 16, 2024
4602474
Improve error message
SvenVw Dec 16, 2024
59790f1
Solve merge conflict
SvenVw Dec 16, 2024
87e0c8a
Add transaction management for atomic operations
SvenVw Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions fdm-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog fdm-app

## 0.4.0

### Minor Changes

- bee0e62: Add `FertilizerApplicationsForm` to list, add and delete fertilizer applications
- 4112897: Remove selection of fertilizers for acquiring but select all fertilizers

### Patch Changes

- Updated dependencies [7af3fda]
- Updated dependencies [bc4e75f]
- Updated dependencies [a948c61]
- Updated dependencies [efa423d]
- Updated dependencies [b0c001e]
- Updated dependencies [6ef3d44]
- Updated dependencies [61da12f]
- Updated dependencies [5be0abc]
- Updated dependencies [4189f5d]
- @svenvw/fdm-core@0.7.0
- @svenvw/fdm-data@1.0.0

## 0.3.1

### Patch Changes
Expand Down
40 changes: 0 additions & 40 deletions fdm-app/app/components/blocks/farm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useState } from "react";
import { Form } from "react-router";
import { zodResolver } from "@hookform/resolvers/zod"
import { useRemixForm, RemixFormProvider } from "remix-hook-form"
Expand All @@ -14,7 +13,6 @@ import {
CardTitle,
} from "@/components/ui/card"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import {
FormControl,
FormDescription,
Expand All @@ -23,22 +21,15 @@ import {
FormLabel,
FormMessage,
} from "@/components/ui/form"

import { MultiSelect } from "@/components/custom/multi-select"
import { LoadingSpinner } from "../custom/loadingspinner";


export interface fertilizersListType {
value: string
label: string
}

export interface farmType {
b_name_farm: string | null
b_fertilizers_organic: string[]
b_fertilizers_mineral: string[]
organicFertilizersList: fertilizersListType[]
mineralFertilizersList: fertilizersListType[]
action: "/app/addfarm/new"
FormSchema: z.Schema<any>
}
Expand All @@ -49,11 +40,7 @@ export interface farmType {
* @returns The JSX element representing the farm form.
*/
export function Farm(props: farmType) {
const organicFertilizersList = props.organicFertilizersList
const mineralFertilizersList = props.mineralFertilizersList
const FormSchema = props.FormSchema
const [selectedOrganicFertilizers, setOrganicFertilizers] = useState<string[]>(props.b_fertilizers_organic);
const [selectedMineralFertilizers, setMineralFertilizers] = useState<string[]>(props.b_fertilizers_mineral);

const form = useRemixForm<z.infer<typeof FormSchema>>({
mode: "onTouched",
Expand Down Expand Up @@ -90,36 +77,9 @@ export function Farm(props: farmType) {
<FormDescription />
<FormMessage />
</FormItem>

)}
/>
</div>
<div className="flex flex-col space-y-1.5">
<Label htmlFor="b_fertilizers_organic">Welke <i>organische</i> meststoffen gebruikt u?</Label>
<MultiSelect
options={organicFertilizersList}
onValueChange={setOrganicFertilizers}
defaultValue={selectedOrganicFertilizers}
placeholder="Selecteer meststoffen"
variant="inverted"
animation={0}
maxCount={10}
name="b_fertilizers_organic"
/>
</div>
<div className="flex flex-col space-y-1.5">
<Label htmlFor="b_fertilizers_mineral">Welke <i>minerale</i> meststoffen gebruikt u?</Label>
<MultiSelect
options={mineralFertilizersList}
onValueChange={setMineralFertilizers}
defaultValue={selectedMineralFertilizers}
placeholder="Selecteer meststoffen"
variant="inverted"
animation={0}
maxCount={10}
name="b_fertilizers_mineral"
/>
</div>
</div>
</CardContent>
<CardFooter className="flex justify-between">
Expand Down
86 changes: 0 additions & 86 deletions fdm-app/app/components/custom/combobox-fertilizers.tsx

This file was deleted.

129 changes: 71 additions & 58 deletions fdm-app/app/components/custom/combobox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react"
import { ReactNode, useState } from "react"

import { Button } from "@/components/ui/button"
import {
Expand All @@ -14,6 +14,14 @@ import {
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
import {
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form"
import { ChevronsUpDown, Check } from "lucide-react"
import { cn } from "@/lib/utils"

Expand All @@ -24,71 +32,76 @@ type optionType = {

interface ComboboxProps {
options: { value: string, label: string }[]
value?: string
defaultValue?: string
onChange?: (value: string) => void
onOpenChange?: (open: boolean) => void
form: any
name: string
label: ReactNode
}

export function Combobox({
options,
value: controlledValue,
defaultValue,
onChange,
onOpenChange
form,
name,
label
}: ComboboxProps) {
const [open, setOpen] = useState(false)
const [internalValue, setInternalValue] = useState(defaultValue ?? "")

const value = controlledValue ?? internalValue
const handleValueChange = (newValue: string) => {
setInternalValue(newValue)
onChange?.(newValue)
}
const name = "combobox"

return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Button
variant="outline"
role="combobox"
aria-expanded={open}
name={name}
className="w-full justify-between opacity-50"
>
{value || "Begin met typen..."}
<ChevronsUpDown className="opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-full p-0">
<Command>
<CommandInput placeholder="Begin met typen..." className="h-9" />
<CommandList>
<CommandEmpty>Niks gevonden</CommandEmpty>
<CommandGroup>
{options.map((option: optionType) => (
<CommandItem
key={option.value}
value={option.label}
onSelect={(currentValue) => {
setInternalValue(currentValue === value ? "" : currentValue)
setOpen(false)
}}
<FormField
control={form.control}
name={name}
render={({ field }) => (
<FormItem>
<FormLabel>{label}</FormLabel>
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<FormControl>
<Button
variant="outline"
role="combobox"
aria-expanded={open}
name={name}
className="w-full justify-between"
>
<p className="text-pretty w-[350px]">{option.label}</p>
<Check
className={cn(
"ml-auto",
value === option.label ? "opacity-100" : "opacity-0"
)}
/>
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
{options.find(option => option.value === field.value)?.label || "Begin met typen..."}
<ChevronsUpDown className="opacity-50" />
</Button>
</FormControl>
</PopoverTrigger>
<PopoverContent className="w-full p-0">
<Command>
<CommandInput placeholder="Begin met typen..." className="h-9" />
<CommandList>
<CommandEmpty>Niks gevonden</CommandEmpty>
<CommandGroup>
{options.map((option: optionType) => (
<CommandItem
value={option.value}
key={option.value}
onSelect={() => {
form.setValue(name, option.value)
setOpen(false)
}}
>
<p className="text-pretty w-[350px]">{option.label}</p>
<Check
className={cn(
"ml-auto",
option.value === field.value
? "opacity-100"
: "opacity-0"
)}
/>
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
<FormDescription />
<FormMessage />
</FormItem>
)}
/>
)
}
Loading