Skip to content
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

Feat: #13 - Hero banner & Top Content #67

Merged
merged 20 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ NEXT_PUBLIC_NETWORK=mainnet
NEXT_PUBLIC_CONTRACT_NAME=potlock.near
NEXT_PUBLIC_SOCIAL_DB_CONTRACT_ID=social.near
NEXT_PUBLIC_NADABOT_CONTRACT_ID=v1.nadabot.near
NEXT_PUBLIC_POTLOCK_LISTS_CONTRACT_ID=lists.potlock.near
NEXT_PUBLIC_POTLOCK_DONATE_CONTRACT_ID=donate.potlock.near
NEXT_PUBLIC_POTLOCK_POT_FACTORY_CONTRACT_ID=v1.potfactory.potlock.near
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.51.5",
"react-copy-to-clipboard": "^5.1.0",
"react-infinite-scroll-component": "^6.1.0",
"react-redux": "^9.1.2",
"redux": "^5.0.1",
"sass": "^1.77.2",
"swr": "^2.2.5",
"styled-components": "^6.1.11",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8"
Expand All @@ -91,6 +93,7 @@
"@types/node": "^20",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-copy-to-clipboard": "^5.0.7",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"@unocss/preset-attributify": "^0.60.4",
Expand Down
2 changes: 1 addition & 1 deletion src/app/_layout/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@
100% {
transform: rotate(360deg);
}
}
}
7 changes: 6 additions & 1 deletion src/app/user/[userId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
// import DonationsInfo from "@/modules/profile/components/DonationsInfo";

import Info from "@/modules/profile/components/Info";
import ProfileBanner from "@/modules/profile/components/ProfileBanner";
import ProjectBanner from "@/modules/project/components/ProjectBanner";

export default async function Project({
params,
}: {
params: { userId: string };
params: { userId: string; potId?: string };
}) {
return (
<main className="flex flex-col">
<ProjectBanner projectId={params.userId} />
<ProfileBanner isProject={true} accountId={params.userId} />
<Info accountId={params.userId} />
{/* <DonationsInfo accountId={params.userId} potId={params.potId} /> */}
</main>
);
}
54 changes: 53 additions & 1 deletion src/common/api/potlock/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,60 @@ type GetAccountsResponse = {
results: Accounts[];
};

export type DonationInfo = {
chef: any;
chef_fee: any;
chef_fee_usd: any;
donated_at: string;
donor: string;
ft: string;
id: number;
matching_pool: boolean;
message: string;
net_amount: string;
net_amount_usd: string;
on_chain_id: number;
pot: any;
protocol_fee: string;
protocol_fee_usd: string;
recipient: string;
referrer: any;
referrer_fee: any;
referrer_fee_usd: any;
total_amount: string;
total_amount_usd: string;
tx_hash: any;
};

type GetAccountDonationsReceivedResponse = {
count: number;
next?: string;
previous?: string;
results: DonationInfo[];
};

export const getAccounts = async () => {
const res = await fetch(`${POTLOCK_API_ENDPOINT}/accounts`);
const res = await fetch(`${POTLOCK_API_ENDPOINT}/api/v1/accounts`);
const json = await res.json();
return json as GetAccountsResponse;
};

export const getAccount = async ({ accountId }: { accountId: string }) => {
const res = await fetch(
`${POTLOCK_API_ENDPOINT}/api/v1/accounts/${accountId}`,
);
const json = await res.json();
return json as GetAccountsResponse;
};

export const getAccountDonationsReceived = async ({
accountId,
}: {
accountId: string;
}) => {
const res = await fetch(
`${POTLOCK_API_ENDPOINT}/api/v1/accounts/${accountId}/donations_received`,
);
const json = await res.json();
return json as GetAccountDonationsReceivedResponse;
};
2 changes: 2 additions & 0 deletions src/common/api/potlock/generated/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from "./useV1AccountsActivePotsRetrieve";
export * from "./useV1AccountsDonationsReceivedRetrieve";
export * from "./useV1AccountsDonationsSentRetrieve";
export * from "./useV1AccountsRetrieve";
export * from "./useV1AccountsRetrieve2";
export * from "./useV1DonorsRetrieve";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import client from "@kubb/swagger-client/client";
import useSWR from "swr";
import type { SWRConfiguration, SWRResponse } from "swr";

import type {
V1AccountsDonationsReceivedRetrieve404,
V1AccountsDonationsReceivedRetrieve500,
V1AccountsDonationsReceivedRetrievePathParams,
V1AccountsDonationsReceivedRetrieveQueryResponse,
} from "../types/V1AccountsDonationsReceivedRetrieve";
import { v1AccountsDonationsReceivedRetrieveQueryResponseSchema } from "../zod/v1AccountsDonationsReceivedRetrieveSchema";

type V1AccountsDonationsReceivedRetrieveClient = typeof client<
V1AccountsDonationsReceivedRetrieveQueryResponse,
| V1AccountsDonationsReceivedRetrieve404
| V1AccountsDonationsReceivedRetrieve500,
never
>;
type V1AccountsDonationsReceivedRetrieve = {
data: V1AccountsDonationsReceivedRetrieveQueryResponse;
error:
| V1AccountsDonationsReceivedRetrieve404
| V1AccountsDonationsReceivedRetrieve500;
request: never;
pathParams: V1AccountsDonationsReceivedRetrievePathParams;
queryParams: never;
headerParams: never;
response: V1AccountsDonationsReceivedRetrieveQueryResponse;
client: {
parameters: Partial<
Parameters<V1AccountsDonationsReceivedRetrieveClient>[0]
>;
return: Awaited<ReturnType<V1AccountsDonationsReceivedRetrieveClient>>;
};
};
export function v1AccountsDonationsReceivedRetrieveQueryOptions<
TData = V1AccountsDonationsReceivedRetrieve["response"],
>(
accountId: V1AccountsDonationsReceivedRetrievePathParams["account_id"],
options: V1AccountsDonationsReceivedRetrieve["client"]["parameters"] = {},
): SWRConfiguration<TData, V1AccountsDonationsReceivedRetrieve["error"]> {
return {
fetcher: async () => {
const res = await client<
TData,
V1AccountsDonationsReceivedRetrieve["error"]
>({
method: "get",
url: `/api/v1/accounts/${accountId}/donations_received`,
...options,
});
return v1AccountsDonationsReceivedRetrieveQueryResponseSchema.parse(
res.data,
);
},
};
}
/**
* @link /api/v1/accounts/:account_id/donations_received
*/
export function useV1AccountsDonationsReceivedRetrieve<
TData = V1AccountsDonationsReceivedRetrieve["response"],
>(
accountId: V1AccountsDonationsReceivedRetrievePathParams["account_id"],
options?: {
query?: SWRConfiguration<
TData,
V1AccountsDonationsReceivedRetrieve["error"]
>;
client?: V1AccountsDonationsReceivedRetrieve["client"]["parameters"];
shouldFetch?: boolean;
},
): SWRResponse<TData, V1AccountsDonationsReceivedRetrieve["error"]> {
const {
query: queryOptions,
client: clientOptions = {},
shouldFetch = true,
} = options ?? {};
const url = `/api/v1/accounts/${accountId}/donations_received`;
const query = useSWR<
TData,
V1AccountsDonationsReceivedRetrieve["error"],
typeof url | null
>(shouldFetch ? url : null, {
...v1AccountsDonationsReceivedRetrieveQueryOptions<TData>(
accountId,
clientOptions,
),
...queryOptions,
});
return query;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import client from "@kubb/swagger-client/client";
import useSWR from "swr";
import type { SWRConfiguration, SWRResponse } from "swr";

import type {
V1AccountsDonationsSentRetrieve404,
V1AccountsDonationsSentRetrieve500,
V1AccountsDonationsSentRetrievePathParams,
V1AccountsDonationsSentRetrieveQueryResponse,
} from "../types/V1AccountsDonationsSentRetrieve";
import { v1AccountsDonationsSentRetrieveQueryResponseSchema } from "../zod/v1AccountsDonationsSentRetrieveSchema";

type V1AccountsDonationsSentRetrieveClient = typeof client<
V1AccountsDonationsSentRetrieveQueryResponse,
V1AccountsDonationsSentRetrieve404 | V1AccountsDonationsSentRetrieve500,
never
>;
type V1AccountsDonationsSentRetrieve = {
data: V1AccountsDonationsSentRetrieveQueryResponse;
error:
| V1AccountsDonationsSentRetrieve404
| V1AccountsDonationsSentRetrieve500;
request: never;
pathParams: V1AccountsDonationsSentRetrievePathParams;
queryParams: never;
headerParams: never;
response: V1AccountsDonationsSentRetrieveQueryResponse;
client: {
parameters: Partial<Parameters<V1AccountsDonationsSentRetrieveClient>[0]>;
return: Awaited<ReturnType<V1AccountsDonationsSentRetrieveClient>>;
};
};
export function v1AccountsDonationsSentRetrieveQueryOptions<
TData = V1AccountsDonationsSentRetrieve["response"],
>(
accountId: V1AccountsDonationsSentRetrievePathParams["account_id"],
options: V1AccountsDonationsSentRetrieve["client"]["parameters"] = {},
): SWRConfiguration<TData, V1AccountsDonationsSentRetrieve["error"]> {
return {
fetcher: async () => {
const res = await client<TData, V1AccountsDonationsSentRetrieve["error"]>(
{
method: "get",
url: `/api/v1/accounts/${accountId}/donations_sent`,
...options,
},
);
return v1AccountsDonationsSentRetrieveQueryResponseSchema.parse(res.data);
},
};
}
/**
* @link /api/v1/accounts/:account_id/donations_sent
*/
export function useV1AccountsDonationsSentRetrieve<
TData = V1AccountsDonationsSentRetrieve["response"],
>(
accountId: V1AccountsDonationsSentRetrievePathParams["account_id"],
options?: {
query?: SWRConfiguration<TData, V1AccountsDonationsSentRetrieve["error"]>;
client?: V1AccountsDonationsSentRetrieve["client"]["parameters"];
shouldFetch?: boolean;
},
): SWRResponse<TData, V1AccountsDonationsSentRetrieve["error"]> {
const {
query: queryOptions,
client: clientOptions = {},
shouldFetch = true,
} = options ?? {};
const url = `/api/v1/accounts/${accountId}/donations_sent`;
const query = useSWR<
TData,
V1AccountsDonationsSentRetrieve["error"],
typeof url | null
>(shouldFetch ? url : null, {
...v1AccountsDonationsSentRetrieveQueryOptions<TData>(
accountId,
clientOptions,
),
...queryOptions,
});
return query;
}
2 changes: 1 addition & 1 deletion src/common/api/potlock/generated/schemas/Donation.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type":"object","properties":{"id":{"description":"Donation id.","type":"integer","readOnly":true,"title":"Donation id"},"on_chain_id":{"description":"Donation id in contract","type":"integer","maximum":2147483647,"minimum":-2147483648,"title":"Contract donation id"},"total_amount":{"description":"Total amount.","type":"string","maxLength":64},"total_amount_usd":{"description":"Total amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total amount in USD"},"net_amount":{"description":"Net amount.","type":"string","maxLength":64},"net_amount_usd":{"description":"Net amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Net amount in USD"},"matching_pool":{"description":"Matching pool.","type":"boolean"},"message":{"description":"Donation message.","type":"string","maxLength":1024,"nullable":true},"donated_at":{"description":"Donation date.","type":"string","format":"date-time"},"protocol_fee":{"description":"Protocol fee.","type":"string","maxLength":64},"protocol_fee_usd":{"description":"Protocol fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Protocol fee in USD"},"referrer_fee":{"description":"Referrer fee.","type":"string","maxLength":64,"nullable":true},"referrer_fee_usd":{"description":"Referrer fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Referrer fee in USD"},"chef_fee":{"description":"Chef fee.","type":"string","maxLength":64,"nullable":true},"chef_fee_usd":{"description":"Chef fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Chef fee in USD"},"tx_hash":{"description":"Transaction hash.","type":"string","maxLength":64,"title":"Transaction hash"},"donor":{"description":"Donor.","type":"string","title":"Address"},"ft":{"description":"Donation FT.","type":"string","title":"Address"},"pot":{"description":"Donation pot.","type":"string","nullable":true,"title":"Address"},"recipient":{"description":"Donation recipient.","type":"string","nullable":true,"title":"Address"},"referrer":{"description":"Donation referrer.","type":"string","nullable":true,"title":"Address"},"chef":{"description":"Donation chef.","type":"string","nullable":true,"title":"Address"}},"required":["donated_at","donor","ft","id","matching_pool","net_amount","on_chain_id","pot","protocol_fee","total_amount","tx_hash"],"x-readme-ref-name":"Donation"}
{"type":"object","properties":{"id":{"description":"Donation id.","type":"integer","readOnly":true,"title":"Donation id"},"on_chain_id":{"description":"Donation id in contract","type":"integer","maximum":2147483647,"minimum":-2147483648,"title":"Contract donation id"},"total_amount":{"description":"Total amount.","type":"string","maxLength":64},"total_amount_usd":{"description":"Total amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total amount in USD"},"net_amount":{"description":"Net amount.","type":"string","maxLength":64},"net_amount_usd":{"description":"Net amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Net amount in USD"},"matching_pool":{"description":"Matching pool.","type":"boolean"},"message":{"description":"Donation message.","type":"string","maxLength":1024,"nullable":true},"donated_at":{"description":"Donation date.","type":"string","format":"date-time"},"protocol_fee":{"description":"Protocol fee.","type":"string","maxLength":64},"protocol_fee_usd":{"description":"Protocol fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Protocol fee in USD"},"referrer_fee":{"description":"Referrer fee.","type":"string","maxLength":64,"nullable":true},"referrer_fee_usd":{"description":"Referrer fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Referrer fee in USD"},"chef_fee":{"description":"Chef fee.","type":"string","maxLength":64,"nullable":true},"chef_fee_usd":{"description":"Chef fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Chef fee in USD"},"tx_hash":{"description":"Transaction hash.","type":"string","maxLength":64,"nullable":true,"title":"Transaction hash"},"donor":{"description":"Donor.","type":"string","title":"Address"},"ft":{"description":"Donation FT.","type":"string","title":"Address"},"pot":{"description":"Donation pot.","type":"string","nullable":true,"title":"Address"},"recipient":{"description":"Donation recipient.","type":"string","nullable":true,"title":"Address"},"referrer":{"description":"Donation referrer.","type":"string","nullable":true,"title":"Address"},"chef":{"description":"Donation chef.","type":"string","nullable":true,"title":"Address"}},"required":["donated_at","donor","ft","id","matching_pool","net_amount","on_chain_id","pot","protocol_fee","total_amount"],"x-readme-ref-name":"Donation"}
2 changes: 1 addition & 1 deletion src/common/api/potlock/generated/schemas/List.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type":"object","properties":{"id":{"description":"List id.","type":"integer","maximum":2147483647,"minimum":0,"title":"List id"},"name":{"description":"List name.","type":"string","maxLength":64},"description":{"description":"List description.","type":"string","maxLength":256,"nullable":true},"cover_image_url":{"description":"Cover image url.","type":"string","format":"uri","maxLength":200,"nullable":true},"admin_only_registrations":{"description":"Admin only registrations.","type":"boolean"},"default_registration_status":{"description":"Default registration status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","allOf":[{"description":"* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","type":"string","enum":["Pending","Approved","Rejected","Graylisted","Blacklisted"],"x-readme-ref-name":"DefaultRegistrationStatusEnum"}]},"created_at":{"description":"List creation date.","type":"string","format":"date-time"},"updated_at":{"description":"List last update date.","type":"string","format":"date-time"},"owner":{"description":"List owner.","type":"string","title":"Address"},"admins":{"description":"List admins.","type":"array","items":{"type":"string","title":"Address"}}},"required":["admin_only_registrations","admins","created_at","default_registration_status","id","name","owner","updated_at"],"x-readme-ref-name":"List"}
{"type":"object","properties":{"id":{"description":"List ID in DB (does not necessarily correspond to on-chain ID).","type":"integer","readOnly":true,"title":"List id"},"on_chain_id":{"description":"List ID in contract","type":"integer","maximum":2147483647,"minimum":-2147483648,"title":"Contract list ID"},"name":{"description":"List name.","type":"string","maxLength":64},"description":{"description":"List description.","type":"string","maxLength":256,"nullable":true},"cover_image_url":{"description":"Cover image url.","type":"string","format":"uri","maxLength":200,"nullable":true},"admin_only_registrations":{"description":"Admin only registrations.","type":"boolean"},"default_registration_status":{"description":"Default registration status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","allOf":[{"description":"* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","type":"string","enum":["Pending","Approved","Rejected","Graylisted","Blacklisted"],"x-readme-ref-name":"DefaultRegistrationStatusEnum"}]},"created_at":{"description":"List creation date.","type":"string","format":"date-time"},"updated_at":{"description":"List last update date.","type":"string","format":"date-time"},"owner":{"description":"List owner.","type":"string","title":"Address"},"admins":{"description":"List admins.","type":"array","items":{"type":"string","title":"Address"}}},"required":["admin_only_registrations","admins","created_at","default_registration_status","id","name","on_chain_id","owner","updated_at"],"x-readme-ref-name":"List"}
Loading
Loading