-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
811 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { | ||
dehydrate, | ||
HydrationBoundary, | ||
QueryClient, | ||
} from "@tanstack/react-query"; | ||
|
||
import { client } from "@/lib/query-client"; | ||
import { queryKeys } from "@/lib/query-keys"; | ||
|
||
import CreateCustomProject from "@/containers/projects/new"; | ||
|
||
export default async function CreateCustomProjectPage() { | ||
const queryClient = new QueryClient(); | ||
|
||
await queryClient.prefetchQuery({ | ||
queryKey: queryKeys.projects.countries.queryKey, | ||
queryFn: () => client.projects.getProjectCountries.query(), | ||
}); | ||
|
||
return ( | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
<CreateCustomProject /> | ||
</HydrationBoundary> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
|
||
import { DotFilledIcon } from "@radix-ui/react-icons"; | ||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
||
import { Label } from "@/components/ui/label"; | ||
|
||
const RadioGroup = React.forwardRef< | ||
React.ElementRef<typeof RadioGroupPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> | ||
>(({ className, ...props }, ref) => { | ||
return ( | ||
<RadioGroupPrimitive.Root | ||
className={cn("grid gap-2", className)} | ||
{...props} | ||
ref={ref} | ||
/> | ||
); | ||
}); | ||
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName; | ||
|
||
const RadioGroupItem = React.forwardRef< | ||
React.ElementRef<typeof RadioGroupPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> | ||
>(({ className, ...props }, ref) => { | ||
return ( | ||
<RadioGroupPrimitive.Item | ||
ref={ref} | ||
className={cn( | ||
"aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50", | ||
className, | ||
)} | ||
{...props} | ||
> | ||
<RadioGroupPrimitive.Indicator className="flex items-center justify-center"> | ||
<DotFilledIcon className="h-3.5 w-3.5 fill-primary" /> | ||
</RadioGroupPrimitive.Indicator> | ||
</RadioGroupPrimitive.Item> | ||
); | ||
}); | ||
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName; | ||
|
||
export interface RadioGroupItemBoxProps | ||
extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> { | ||
label: string; | ||
} | ||
|
||
const RadioGroupItemBox = React.forwardRef< | ||
React.ElementRef<typeof RadioGroupPrimitive.Item>, | ||
RadioGroupItemBoxProps | ||
>(({ className, checked, label, value, ...radioProps }, ref) => { | ||
return ( | ||
<div | ||
className={cn( | ||
"cursor-pointer rounded-xl border border-border p-4", | ||
className, | ||
{ | ||
"border-primary": checked, | ||
}, | ||
)} | ||
> | ||
<div className="flex items-center gap-2"> | ||
<RadioGroupItem ref={ref} value={value} id={value} {...radioProps} /> | ||
<Label htmlFor={value}>{label}</Label> | ||
</div> | ||
</div> | ||
); | ||
}); | ||
|
||
RadioGroupItemBox.displayName = "RadioGroupItemBox"; | ||
|
||
export { RadioGroup, RadioGroupItem, RadioGroupItemBox }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function AssumptionsProjectForm() { | ||
return <div>AssumptionsProjectForm</div>; | ||
} |
3 changes: 3 additions & 0 deletions
3
client/src/containers/projects/form/cost-inputs-overrides/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function CostInputsOverridesProjectForm() { | ||
return <div>CostInputsOverridesProjectForm</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useFormContext } from "react-hook-form"; | ||
|
||
import AssumptionsProjectForm from "@/containers/projects/form/assumptions"; | ||
import CostInputsOverridesProjectForm from "@/containers/projects/form/cost-inputs-overrides"; | ||
import SetupProjectForm, { | ||
CreateCustomProjectForm, | ||
} from "@/containers/projects/form/setup"; | ||
|
||
import { Card } from "@/components/ui/card"; | ||
|
||
export default function ProjectForm({ onSubmit }: { onSubmit: () => void }) { | ||
const form = useFormContext<CreateCustomProjectForm>(); | ||
|
||
console.log(form.getValues()); | ||
|
||
return ( | ||
<form className="w-full space-y-8" onSubmit={onSubmit}> | ||
<div className="flex flex-col gap-3"> | ||
<Card className="flex flex-1 flex-col" variant="secondary"> | ||
<SetupProjectForm /> | ||
</Card> | ||
<Card className="flex flex-1 flex-col" variant="secondary"> | ||
<AssumptionsProjectForm /> | ||
</Card> | ||
<Card className="flex flex-1 flex-col" variant="secondary"> | ||
<CostInputsOverridesProjectForm /> | ||
</Card> | ||
</div> | ||
</form> | ||
); | ||
} |
64 changes: 64 additions & 0 deletions
64
client/src/containers/projects/form/setup/conservation-project-details/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as React from "react"; | ||
|
||
import { useFormContext } from "react-hook-form"; | ||
|
||
import { CreateCustomProjectForm } from "@/containers/projects/form/setup"; | ||
|
||
import { Card } from "@/components/ui/card"; | ||
import { | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@/components/ui/form"; | ||
import { Input } from "@/components/ui/input"; | ||
|
||
export default function ConservationProjectDetails() { | ||
const form = useFormContext<CreateCustomProjectForm>(); | ||
|
||
return ( | ||
<Card variant="secondary"> | ||
<h2 className="font-semibold">Conservation project details</h2> | ||
<p className="text-sm text-muted-foreground"> | ||
This information only applies for conservation projects | ||
</p> | ||
|
||
<FormField | ||
control={form?.control} | ||
name="initialCarbonPriceAssumption" | ||
render={({ field }) => ( | ||
<FormItem className="flex justify-between gap-4"> | ||
<FormLabel | ||
tooltip={{ | ||
title: "Initial carbon price assumption", | ||
content: "TBD", | ||
}} | ||
> | ||
Initial carbon price assumption in $ | ||
</FormLabel> | ||
<FormControl className="relative after:absolute after:right-9 after:inline-block after:text-sm after:text-muted-foreground after:content-['$']"> | ||
<div className="relative flex items-center"> | ||
<Input | ||
type="number" | ||
placeholder="Insert project name" | ||
className="min-w-[225px]" | ||
min={0} | ||
{...field} | ||
onChange={async (v) => { | ||
form?.setValue( | ||
"initialCarbonPriceAssumption", | ||
Number(v.target.value), | ||
); | ||
await form?.trigger("initialCarbonPriceAssumption"); | ||
}} | ||
/> | ||
</div> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
</Card> | ||
); | ||
} |
Oops, something went wrong.