Skip to content

Commit

Permalink
Merge pull request #13 from HausDAO/update-metadata
Browse files Browse the repository at this point in the history
Update GitHub Actions workflow for Next.js project
  • Loading branch information
earth2travis authored Jan 22, 2025
2 parents 1b07707 + d04f93a commit a3489a5
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 159 deletions.
47 changes: 23 additions & 24 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,38 @@ name: Verify
on:
pull_request:
branches: [main]
workflow_call:
secrets:
STACK_DEPLOY_SSH_PRIVATE_KEY:
required: true
DEPOT_PROJECT_ID:
required: true
DOCKERHUB_USER:
required: true
DOCKERHUB_PASSWORD:
required: true

# Cancel in-progress workflows for the same PR or branch/tag

# Cancel in-progress workflows for the same PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# Needs to be a superset of what Verify workflow needs
permissions:
contents: read # Clone repo
id-token: write # Depot OIDC
contents: read

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
runs-on: depot-ubuntu-latest-arm
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
dockerhub-user: ${{ secrets.DOCKERHUB_USER }}
dockerhub-password: ${{ secrets.DOCKERHUB_PASSWORD }}
dockerfile: ./Dockerfile
depot: true
depot-project-id: ${{ secrets.DEPOT_PROJECT_ID }}
context: .
platforms: 'linux/arm64'
bun-version: latest

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Build
run: bun run build

# Optionally add linting/testing steps if needed
- name: Lint
run: bun run lint
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ Brewfile.lock.json
.eslintcache

# IDE configs
.idea/
.idea/

.next/cache/
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"clean": "rm -rf .next/cache",
"start": "next start",
"lint": "next lint",
"pages:build": "npx @cloudflare/next-on-pages",
"preview": "bun run pages:build && wrangler pages dev",
"deploy": "bun run pages:build && wrangler pages deploy"
"pages:build": "rm -rf .next && next build && rm -rf .next/cache",
"pages:deploy": "npx @cloudflare/next-on-pages deploy .next",
"preview": "bun run pages:build && wrangler pages dev"
},
"dependencies": {
"@farcaster/frame-sdk": "^0.0.16",
Expand Down
64 changes: 30 additions & 34 deletions src/components/forms/SampleForm.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
import { Card } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { Label } from "@/components/ui/label";
import { z } from "zod";
import { FormComponentProps } from "../app/FormSwitcher";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { Button } from "../ui/button";
import { Spinner } from "../ui/spinner";
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
import { InfoIcon } from "lucide-react";
import { FormActionButtons } from "../app/FormActionButtons";
} 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';

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',
}),
});

export const SampleForm = ({
formConfig,
handleSubmit,
loading,
confirmed,
Expand All @@ -53,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 @@ -205,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 * as React from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { Check } from "lucide-react";
import cn from "@/lib/cn";
import { cn } from '@/lib/cn';
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
import { Check } from 'lucide-react';
import * as React from 'react';

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
63 changes: 25 additions & 38 deletions src/hooks/useDao.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { GraphQLClient } from "graphql-request";
import { useQuery } from "@tanstack/react-query";
import { useQuery } from '@tanstack/react-query';
import { GraphQLClient } from 'graphql-request';

import { DaoItem, DaoProfile, RecordItem } from "@/lib/types";
import { getGraphUrl } from "@/lib/endpoints";
import { FIND_DAO } from "@/lib/graph-queries";
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,41 +25,28 @@ export const useDao = ({
chainid?: string;
daoid?: string;
}) => {
// All hooks must be called at the top level
const { config } = useDaoHooksConfig();

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

const dhUrl = getGraphUrl({
chainid: chainid || "",
graphKey: config.graphKey,
subgraphKey: "DAOHAUS",
});

const graphQLClient = new GraphQLClient(dhUrl);

const { data, ...rest } = useQuery({
queryKey: [`get-dao-${chainid}-${daoid}`, { chainid, daoid }],
queryFn: async (): Promise<{
dao: DaoItem;
}> => {
const daores = (await graphQLClient.request(FIND_DAO, {
daoid,
})) as {
const { data, ...rest } = useQuery<{ dao: DaoItem }>({
queryKey: [`get-dao-${chainid}-${daoid}`],
enabled: Boolean(chainid && daoid && config?.graphKey),
queryFn: async () => {
if (!chainid || !daoid || !config?.graphKey) {
return { dao: undefined as unknown as DaoItem };
}
const dhUrl = getGraphUrl({
chainid,
graphKey: config.graphKey,
subgraphKey: 'DAOHAUS',
});
const graphQLClient = new GraphQLClient(dhUrl);
const daores = (await graphQLClient.request(FIND_DAO, { daoid })) as {
dao: DaoItem;
};
const profile = addParsedContent<DaoProfile>(daores.dao.rawProfile[0]);

return {
dao: { ...daores.dao, profile },
};
return { dao: { ...daores.dao, profile } };
},
enabled: !!daoid && !!chainid,
});

return {
dao: data?.dao,
...rest,
};
return { dao: data?.dao, ...rest };
};
65 changes: 65 additions & 0 deletions src/hooks/useDaoSam.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { GraphQLClient } from "graphql-request";
import { useQuery } from "@tanstack/react-query";

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

export const addParsedContent = <T>(record?: RecordItem): T | undefined => {
if (record?.contentType === "json") {
try {
const obj = JSON.parse(record.content);
return obj;
} catch (e) {
console.log("err", e);
return;
}
}
};

export const useDao = ({
chainid,
daoid,
}: {
chainid?: string;
daoid?: string;
}) => {
const { config } = useDaoHooksConfig();

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

const dhUrl = getGraphUrl({
chainid: chainid || "",
graphKey: config.graphKey,
subgraphKey: "DAOHAUS",
});

const graphQLClient = new GraphQLClient(dhUrl);

const { data, ...rest } = useQuery({
queryKey: [`get-dao-${chainid}-${daoid}`, { chainid, daoid }],
queryFn: async (): Promise<{
dao: DaoItem;
}> => {
const daores = (await graphQLClient.request(FIND_DAO, {
daoid,
})) as {
dao: DaoItem;
};
const profile = addParsedContent<DaoProfile>(daores.dao.rawProfile[0]);

return {
dao: { ...daores.dao, profile },
};
},
enabled: !!daoid && !!chainid,
});

return {
dao: data?.dao,
...rest,
};
};
Loading

0 comments on commit a3489a5

Please sign in to comment.