Skip to content

Commit

Permalink
Merge pull request #20 from HausDAO/dev-merge
Browse files Browse the repository at this point in the history
Dev merge
  • Loading branch information
earth2travis authored Feb 5, 2025
2 parents 2c3a607 + fe0e211 commit e153cbb
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 118 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions src/app/dao/[chainid]/[daoid]/[proposaltype]/proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ export default function Proposal() {
localABIs: {},
};

// TODO: is safeID and chainID needed at both levels?
// how to swap txes for fundung?

const txPrep = await prepareTX({
tx: formConfig.tx,
chainId: daochain as ValidNetwork,
Expand Down
67 changes: 66 additions & 1 deletion src/components/forms/RequestFunding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Form } from "@/components/ui/form";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { FormComponentProps } from "../app/FormSwitcher";
import { useParams } from "next/navigation";
import { useDao } from "@/hooks/useDao";
import { useDaoTokenBalances } from "@/hooks/useDaoTokenBalances";
import { FormActionButtons } from "../app/FormActionButtons";
import { ProposalMetaFields } from "../app/ProposalMetaFields";
import { Input } from "@/components/ui/input";

const formSchema = z.object({
title: z.string().min(2, {
message: "Title must be at least 2 characters.",
}),
description: z.string(),
link: z.string().url().optional().or(z.literal("")),
recipient: z.string(),
tokenAddress: z.string(),
tokenAmount: z.string(),
});

export const RequestFunding = ({
Expand All @@ -33,6 +44,9 @@ export const RequestFunding = ({
title: "",
description: "",
link: "",
recipient: "",
tokenAmount: "",
tokenAddress: "",
},
});

Expand Down Expand Up @@ -63,6 +77,57 @@ export const RequestFunding = ({
>
<ProposalMetaFields disabled={disabled} />

<FormField
control={form.control}
name="recipient"
disabled={disabled}
render={({ field }) => (
<FormItem>
<div className="flex mb-2 justify-between">
<FormLabel>Recipient</FormLabel>
</div>
<FormControl>
<Input id="recipient" placeholder="Address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormField
control={form.control}
name="tokenAddress"
disabled={disabled}
render={({ field }) => (
<FormItem>
<div className="flex mb-2 justify-between">
<FormLabel>Token Address</FormLabel>
</div>
<FormControl>
<Input id="tokenAddress" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormField
control={form.control}
name="tokenAmount"
disabled={disabled}
render={({ field }) => (
<FormItem>
<div className="flex mb-2 justify-between">
<FormLabel>Funding Requested</FormLabel>
</div>
<FormControl>
<Input id="tokenAmount" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormActionButtons
submitButtonText={submitButtonText}
loading={loading}
Expand Down
48 changes: 24 additions & 24 deletions src/components/forms/SampleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ import {
FormItem,
FormLabel,
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { Textarea } from '@/components/ui/textarea';
import { zodResolver } from '@hookform/resolvers/zod';
import { InfoIcon } from 'lucide-react';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
import { FormActionButtons } from '../app/FormActionButtons';
import { FormComponentProps } from '../app/FormSwitcher';
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { zodResolver } from "@hookform/resolvers/zod";
import { InfoIcon } from "lucide-react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { FormActionButtons } from "../app/FormActionButtons";
import { FormComponentProps } from "../app/FormSwitcher";
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";

const formSchema = z.object({
title: z.string().min(2, {
message: 'Try harder',
message: "Try harder",
}),
description: z.string().min(1, {
message: 'Write something',
message: "Write something",
}),
model: z.string().min(1, {
message: 'Make a selection',
message: "Make a selection",
}),
choice: z.enum(['all', 'some', 'none'], {
required_error: 'Choose an option',
choice: z.enum(["all", "some", "none"], {
required_error: "Choose an option",
}),
});

Expand All @@ -49,18 +49,18 @@ export const SampleForm = ({
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
title: '',
description: '',
model: '',
title: "",
description: "",
model: "",
},
});

const onSubmit = (values: z.infer<typeof formSchema>) => {
const preparedValues = {
...values,
};
console.log('values', values);
console.log('preparedValues', preparedValues);
console.log("values", values);
console.log("preparedValues", preparedValues);
console.log(handleSubmit);
// handleSubmit(preparedValues);
};
Expand Down Expand Up @@ -201,7 +201,7 @@ export const SampleForm = ({
/>

<FormActionButtons
submitButtonText={'Create Proposal'}
submitButtonText={"Create Proposal"}
loading={loading}
confirmed={confirmed}
disabled={disabled}
Expand Down
14 changes: 7 additions & 7 deletions src/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client';
"use client";

import { cn } from '@/lib/cn';
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
import { Check } from 'lucide-react';
import * as React from 'react';
import * as React from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { Check } from "lucide-react";
import { cn } from "@/lib/cn";

const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
Expand All @@ -12,13 +12,13 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Root
ref={ref}
className={cn(
'peer h-4 w-4 shrink-0 rounded-sm border border-aliceBlue ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
"peer h-4 w-4 shrink-0 rounded-sm border border-aliceBlue ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn('flex items-center justify-center text-current')}
className={cn("flex items-center justify-center text-current")}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
Expand Down
5 changes: 4 additions & 1 deletion src/components/ui/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ function Header() {
<div className="text-3xl font-fraktur pt-[2px] leading-[30px] h-[30px] text-primary">
proposals
</div>
<HeaderLogoSvg className="opacity-100" onClick={onLogoClick} />
<HeaderLogoSvg
className="opacity-100 hover:cursor-pointer"
onClick={onLogoClick}
/>
</div>
);
}
Expand Down
21 changes: 11 additions & 10 deletions src/hooks/useDao.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { useQuery } from '@tanstack/react-query';
import { GraphQLClient } from 'graphql-request';
import { useQuery } from "@tanstack/react-query";
import { GraphQLClient } from "graphql-request";

import { getGraphUrl } from '@/lib/endpoints';
import { FIND_DAO } from '@/lib/graph-queries';
import { DaoItem, DaoProfile, RecordItem } from '@/lib/types';
import { useDaoHooksConfig } from '@/providers/DaoHooksProvider';
import { getGraphUrl } from "@/lib/endpoints";
import { FIND_DAO } from "@/lib/graph-queries";
import { DaoItem, DaoProfile, RecordItem } from "@/lib/types";
import { useDaoHooksConfig } from "@/providers/DaoHooksProvider";

export const addParsedContent = <T>(record?: RecordItem): T | undefined => {
if (record?.contentType === 'json') {
if (record?.contentType === "json") {
try {
const obj = JSON.parse(record.content);
return obj;
} catch (e) {
console.log('err', e);
console.log("err", e);
return;
}
}
Expand All @@ -25,8 +25,9 @@ export const useDao = ({
chainid?: string;
daoid?: string;
}) => {
// All hooks must be called at the top level
const { config } = useDaoHooksConfig();

console.log("useDao config", config);
const { data, ...rest } = useQuery<{ dao: DaoItem }>({
queryKey: [`get-dao-${chainid}-${daoid}`],
enabled: Boolean(chainid && daoid && config?.graphKey),
Expand All @@ -37,7 +38,7 @@ export const useDao = ({
const dhUrl = getGraphUrl({
chainid,
graphKey: config.graphKey,
subgraphKey: 'DAOHAUS',
subgraphKey: "DAOHAUS",
});
const graphQLClient = new GraphQLClient(dhUrl);
const daores = (await graphQLClient.request(FIND_DAO, { daoid })) as {
Expand Down
65 changes: 0 additions & 65 deletions src/hooks/useDaoSam.ts

This file was deleted.

6 changes: 1 addition & 5 deletions src/hooks/useDaoTokenBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export const useDaoTokenBalances = ({
}) => {
const { config } = useDaoHooksConfig();

if (!config || !config.graphKey) {
throw new Error("DaoHooksContext must be used within a DaoHooksProvider");
}

const gnosisUrl = getGnosisUrl({
chainid: chainid || "",
});
Expand All @@ -28,6 +24,7 @@ export const useDaoTokenBalances = ({
`get-dao-token-balances${chainid}-${safeAddress}`,
{ chainid, safeAddress },
],
enabled: Boolean(chainid && safeAddress && config?.graphKey),
queryFn: async (): Promise<{
tokens: TokenBalance[];
}> => {
Expand All @@ -44,7 +41,6 @@ export const useDaoTokenBalances = ({

return { tokens: balances };
},
enabled: !!safeAddress && !!chainid,
});

return {
Expand Down
Loading

0 comments on commit e153cbb

Please sign in to comment.