-
Notifications
You must be signed in to change notification settings - Fork 4
Add cultivations #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6694029
e1764c6
b67815f
3628a25
41cb1d1
5516df3
3f02cb5
49aa60c
869b2fd
973e097
35c55e1
e1aa0ee
bfa7927
b1dea77
709f431
d39b097
b8e33be
ad11dec
986a121
225767f
c8c6b8e
2f70bcc
d8cf2b3
4d4d807
d2bcc04
0a6b66e
23c38a7
4165904
3f6c7ca
3bd6879
114a9c8
da272eb
1dd8d6a
7188eed
e449ae1
8aabffe
29e990e
06cf156
3bbf38b
0b5d2e6
362a168
460889e
63d3ea8
2352e62
60dba71
b6b04d2
4379d6d
07e6838
80db2e7
d1a5b68
4637fee
007545d
d6b8294
1b9722d
050e682
8f86ed4
3a6d90f
f28882e
3d90cfd
988fa5c
c316d5c
44dab14
3bd450f
efc0761
1ab985e
f338f73
77c31bf
cbc9cfe
090c411
6a97469
d4c7fbe
94ba874
069e5da
5eae0b4
a4abff2
a3a2fc8
ab2f5b9
a6c19de
975d959
e9bb078
273e151
e4a4f38
f587a6f
84ba48a
52e6966
9cdb4d5
d22471c
32e8b40
bd1f10b
3b359f6
a860f6c
dddc435
f98175a
b5d3e23
f8500b7
e1aadf5
6e9e94d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # NodeJS Configuration | ||
| # Sets the environment for the application (development, production). | ||
| # Example: development, production | ||
| NODE_ENV= | ||
|
|
||
| # Secret key used to sign session cookies. | ||
| # Must be a strong, randomly generated string. Do not hardcode or commit this value to version control. Use a secure secret management system. | ||
| # Rotate this key periodically. Compromising this secret can allow attackers to hijack user sessions. | ||
| FDM_SESSION_SECRET= | ||
|
|
||
| # DB configuration | ||
| # The hostname or IP address of the PostgreSQL database server. | ||
| POSTGRES_HOST= | ||
|
|
||
| # The port number on which the PostgreSQL database server is listening. Defaults to 5432 if not specified. | ||
| POSTGRES_PORT= | ||
|
|
||
| # The name of the PostgreSQL database to connect to. | ||
| POSTGRES_DB= | ||
|
|
||
| # The username used to authenticate with the PostgreSQL database server. | ||
| POSTGRES_USER= | ||
|
|
||
| # The password used to authenticate with the PostgreSQL database server. Ensure this is stored securely and not exposed in version control. | ||
| POSTGRES_PASSWORD= | ||
|
|
||
| # Mapbox configuration | ||
| # API token for Mapbox services. Required to use Mapbox features. | ||
| # Obtain your token from the Mapbox website. Keep this token secure and do not expose it in version control. | ||
| MAPBOX_TOKEN= | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,25 @@ | ||
| # Changelog fdm-app | ||
|
|
||
| ## v.0.1.0 | ||
| ## 0.2.0 | ||
|
|
||
| A first prototype of an application for fdm with minimal functions | ||
| ### Minor Changes | ||
|
|
||
| - e1aa0ee: Rename an app to `Nutriëntenbalans` | ||
|
|
||
| ### Patch Changes | ||
|
|
||
| - bfa7927: Increase width of sidebar on desktop to `18rem` | ||
| - 35c55e1: Add example configuration file as `.env.example` | ||
| - Updated dependencies [d39b097] | ||
| - Updated dependencies [35c55e1] | ||
| - Updated dependencies [6694029] | ||
| - Updated dependencies [c316d5c] | ||
| - Updated dependencies [b1dea77] | ||
| - Updated dependencies [d39b097] | ||
| - Updated dependencies [49aa60c] | ||
| - @svenvw/fdm-data@1.0.0 | ||
| - @svenvw/fdm-core@0.6.0 | ||
|
|
||
| ## 0.1.0 | ||
|
|
||
| A first prototype of an application for fdm with minimal functions |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,107 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useState } from "react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Form, useLocation, useNavigation } from "@remix-run/react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { cn } from "@/lib/utils" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Label } from "@/components/ui/label"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Input } from "@/components/ui/input"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { buttonVariants } from "@/components/ui/button" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Calendar } from "@/components/ui/calendar" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // import { nl } from "react-day-picker/locale" // Could not be found somehow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface SidebarNavProps extends React.HTMLAttributes<HTMLElement> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| items: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| href: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }[] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function SidebarNav({ className, items, ...props }: SidebarNavProps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { pathname } = useLocation(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <nav | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={cn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1 truncate", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {...props} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {items.map((item) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key={item.href} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| href={item.href} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={cn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| buttonVariants({ variant: "ghost" }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pathname === item.href | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? "bg-muted hover:bg-muted" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : "hover:bg-transparent hover:underline", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "justify-start" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {item.title} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </a> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use Remix's Link component instead of anchor tags Replace the anchor tags with Remix's -import { Form, useLocation, useNavigation } from "@remix-run/react";
+import { Form, useLocation, useNavigation, Link } from "@remix-run/react";
// ... in the map function ...
-<a
+<Link
key={item.href}
- href={item.href}
+ to={item.href}
className={cn(
buttonVariants({ variant: "ghost" }),
pathname === item.href
? "bg-muted hover:bg-muted"
: "hover:bg-transparent hover:underline",
"justify-start"
)}
>
{item.title}
-</a>
+</Link>📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </nav> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default function Cultivation(props: { action: string | undefined; }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add comprehensive props interface for the Cultivation component The component needs a proper TypeScript interface for its props to improve type safety and documentation. interface CultivationProps {
action?: string;
initialSowingDate?: Date;
initialHarvestingDate?: Date;
onSubmit?: (data: {
yield: number;
nitrogenContent: number;
sowingDate?: Date;
harvestingDate?: Date;
}) => void;
}
export default function Cultivation({
action,
initialSowingDate,
initialHarvestingDate,
onSubmit,
}: CultivationProps) {
// ... rest of the component
} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const navigation = useNavigation(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Get sowing and harvesting dates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [dateSowing, setDateSowing] = useState<Date | undefined>(new Date('2024-03-01')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [dateHarvesting, setDateHarvesting] = useState<Date | undefined>(new Date('2024-10-01')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+52
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid hardcoded dates in state initialization The component initializes dates with hardcoded values, which might not be appropriate for all use cases. -const [dateSowing, setDateSowing] = useState<Date | undefined>(new Date('2024-03-01'))
-const [dateHarvesting, setDateHarvesting] = useState<Date | undefined>(new Date('2024-10-01'))
+const [dateSowing, setDateSowing] = useState<Date | undefined>(props.defaultSowingDate || undefined)
+const [dateHarvesting, setDateHarvesting] = useState<Date | undefined>(props.defaultHarvestingDate || undefined)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="space-y-6"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p className="text-sm text-muted-foreground"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Werk de opbrengst, stikstofgehalte en zaai- en oogstdatum bij voor dit gewas. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form method="post" action={props.action}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <fieldset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled={navigation.state === "submitting"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </fieldset> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+63
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix fieldset structure and enhance form validation The fieldset is not properly enclosing the form fields, and the form lacks proper validation. <Form method="post" action={props.action}>
<fieldset
disabled={navigation.state === "submitting"}
+ className="grid w-full items-center gap-4"
>
- </fieldset>
- <div className="grid w-full items-center gap-4">
{/* Move all form fields here */}
- </div>
+ </fieldset>
</Form>Also, consider adding form validation: const [errors, setErrors] = useState<Record<string, string>>({});
const validateForm = () => {
const newErrors: Record<string, string> = {};
if (!yield) newErrors.yield = "Yield is required";
if (!nitrogenContent) newErrors.nitrogenContent = "Nitrogen content is required";
setErrors(newErrors);
return Object.keys(newErrors).length === 0;
};Also applies to: 85-136 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="grid w-full items-center gap-4"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex flex-col space-y-1.5"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Label htmlFor="b_name_farm">Opbrengst (ton ds/ ha) <span className="text-red-500">*</span></Label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Input id="b_name_farm" type="number" name="b_name_farm" placeholder="37 ton ds / ha" aria-required="true" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex flex-col space-y-1.5"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Label htmlFor="b_name_farm">Stikstofgehalte gewas (kg N / ton DS) <span className="text-red-500">*</span></Label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Input id="b_name_farm" type="number" name="b_name_farm" placeholder="4 kg N / ton DS" aria-required="true" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
+75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix duplicate form field IDs The input fields are using the same ID -<Input id="b_name_farm" type="number" name="b_name_farm" placeholder="37 ton ds / ha" aria-required="true" />
+<Input id="yield" type="number" name="yield" placeholder="37 ton ds / ha" aria-required="true" />
-<Input id="b_name_farm" type="number" name="b_name_farm" placeholder="4 kg N / ton DS" aria-required="true" />
+<Input id="nitrogen_content" type="number" name="nitrogen_content" placeholder="4 kg N / ton DS" aria-required="true" />📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="grid grid-cols-1 md:grid-cols-2 gap-4"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex flex-col space-y-1.5"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Label htmlFor="b_name_farm">Zaaidatum</Label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Calendar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // locale={nl} TODO: library has installation issues somehow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode="single" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selected={dateSowing} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSelect={setDateSowing} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="rounded-md border" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weekStartsOn={1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| month={dateSowing} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex flex-col space-y-1.5"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Label htmlFor="b_name_farm">Oogstdatum</Label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Calendar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // locale={nl} TODO: library has installation issues somehow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode="single" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selected={dateHarvesting} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSelect={setDateHarvesting} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="rounded-md border" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| weekStartsOn={1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| month={dateHarvesting} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Form> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve the locale import issue
The commented import for the Dutch locale suggests there's an unresolved installation or configuration issue that needs attention. This could affect the calendar's localization.
Consider these solutions:
npm install date-fns/locale/nlimport { nl } from 'date-fns/locale'