-
Notifications
You must be signed in to change notification settings - Fork 31
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
51 changed files
with
521 additions
and
208 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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
export * from './pubkey-protocol-provider' | ||
export * from './use-mutation-add-authority' | ||
export * from './use-mutation-add-identity' | ||
export * from './use-mutation-create-community' | ||
export * from './use-mutation-create-profile' | ||
export * from './use-mutation-remove-authority' | ||
export * from './use-mutation-remove-identity' | ||
export * from './use-mutation-update-avatar-url' | ||
export * from './use-pubkey-protocol-sdk' | ||
export * from './use-query-get-community-by-slug' | ||
export * from './use-query-get-pointers' | ||
export * from './use-query-get-profile-by-provider-nullable' | ||
export * from './use-query-get-profile-by-username' | ||
export * from './use-query-get-profiles' | ||
export { useGetProfileByProviderNullable } from './use-get-profile-by-provider-nullable' |
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
4 changes: 2 additions & 2 deletions
4
web/src/app/features/pubkey-protocol/data-access/use-mutation-add-authority.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
4 changes: 2 additions & 2 deletions
4
web/src/app/features/pubkey-protocol/data-access/use-mutation-add-identity.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
23 changes: 23 additions & 0 deletions
23
web/src/app/features/pubkey-protocol/data-access/use-mutation-create-community.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,23 @@ | ||
import { CreateCommunityOptions } from '@pubkey-protocol/sdk' | ||
import { useMutation } from '@tanstack/react-query' | ||
import { usePubKeyProtocol } from './pubkey-protocol-provider' | ||
|
||
export type PubKeyCommunityCreateInput = Omit<CreateCommunityOptions, 'authority' | 'feePayer'> | ||
|
||
export function useMutationCreateCommunity() { | ||
const { authority, feePayer, sdk, signAndConfirmTransaction, onError, onSuccess } = usePubKeyProtocol() | ||
|
||
return useMutation({ | ||
mutationFn: (options: PubKeyCommunityCreateInput) => | ||
sdk | ||
.createCommunity({ | ||
...options, | ||
avatarUrl: options.avatarUrl || `https://api.dicebear.com/9.x/bottts-neutral/svg?seed=${options.slug}`, | ||
authority, | ||
feePayer, | ||
}) | ||
.then(signAndConfirmTransaction), | ||
onError, | ||
onSuccess, | ||
}) | ||
} |
4 changes: 2 additions & 2 deletions
4
web/src/app/features/pubkey-protocol/data-access/use-mutation-create-profile.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
4 changes: 2 additions & 2 deletions
4
web/src/app/features/pubkey-protocol/data-access/use-mutation-remove-authority.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
4 changes: 2 additions & 2 deletions
4
web/src/app/features/pubkey-protocol/data-access/use-mutation-remove-identity.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
4 changes: 2 additions & 2 deletions
4
web/src/app/features/pubkey-protocol/data-access/use-mutation-update-avatar-url.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
11 changes: 11 additions & 0 deletions
11
web/src/app/features/pubkey-protocol/data-access/use-query-get-community-by-slug.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,11 @@ | ||
import { usePubKeyProtocol } from './pubkey-protocol-provider' | ||
import { useQuery } from '@tanstack/react-query' | ||
|
||
export function useQueryGetCommunityBySlug({ slug }: { slug: string }) { | ||
const { sdk, cluster } = usePubKeyProtocol() | ||
|
||
return useQuery({ | ||
queryKey: ['pubkey-protocol', 'getCommunityBySlug', { cluster, slug }], | ||
queryFn: () => sdk.getCommunityBySlug({ slug }), | ||
}) | ||
} |
4 changes: 2 additions & 2 deletions
4
web/src/app/features/pubkey-protocol/data-access/use-query-get-pointers.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
6 changes: 3 additions & 3 deletions
6
.../use-get-profile-by-provider-nullable.tsx → ...uery-get-profile-by-provider-nullable.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
4 changes: 2 additions & 2 deletions
4
web/src/app/features/pubkey-protocol/data-access/use-query-get-profile-by-username.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
12 changes: 10 additions & 2 deletions
12
web/src/app/features/pubkey-protocol/data-access/use-query-get-profiles.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 |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import { useQuery } from '@tanstack/react-query' | ||
import { usePubKeyProfile } from './pubkey-protocol-provider' | ||
import { usePubKeyProtocol } from './pubkey-protocol-provider' | ||
|
||
export function useQueryGetProfiles() { | ||
const { cluster, sdk } = usePubKeyProfile() | ||
const { cluster, sdk } = usePubKeyProtocol() | ||
|
||
return useQuery({ | ||
queryKey: ['pubkey-protocol', 'getProfiles', { cluster }], | ||
queryFn: () => sdk.getProfiles(), | ||
}) | ||
} | ||
export function useQueryGetCommunities() { | ||
const { cluster, sdk } = usePubKeyProtocol() | ||
|
||
return useQuery({ | ||
queryKey: ['pubkey-protocol', 'getCommunities', { cluster }], | ||
queryFn: () => sdk.getCommunities(), | ||
}) | ||
} |
23 changes: 23 additions & 0 deletions
23
web/src/app/features/pubkey-protocol/feature/pubkey-protocol-feature-community-create.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,23 @@ | ||
import { toastError, toastSuccess, UiCard, UiPage } from '@pubkey-ui/core' | ||
import { IconUserPlus } from '@tabler/icons-react' | ||
import { useMutationCreateCommunity } from '../data-access' | ||
import { PubkeyProtocolUiCommunityCreateForm } from '../ui' | ||
|
||
export function PubkeyProtocolFeatureCommunityCreate() { | ||
const mutation = useMutationCreateCommunity() | ||
|
||
return ( | ||
<UiPage leftAction={<IconUserPlus />} title="Create Community"> | ||
<UiCard title="Create Community"> | ||
<PubkeyProtocolUiCommunityCreateForm | ||
submit={(input) => | ||
mutation | ||
.mutateAsync(input) | ||
.then(() => toastSuccess(`Community created`)) | ||
.catch((err) => toastError(`Error: ${err}`)) | ||
} | ||
/> | ||
</UiCard> | ||
</UiPage> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
web/src/app/features/pubkey-protocol/feature/pubkey-protocol-feature-community-detail.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,23 @@ | ||
import { UiLoader, UiPage, UiWarning } from '@pubkey-ui/core' | ||
import { IconUsersGroup } from '@tabler/icons-react' | ||
import { useParams } from 'react-router-dom' | ||
import { useQueryGetCommunityBySlug } from '../data-access' | ||
import { PubkeyProtocolUiCommunityCard } from '../ui' | ||
|
||
export function PubkeyProtocolFeatureCommunityDetail() { | ||
const { slug } = useParams() as { slug: string } | ||
|
||
const query = useQueryGetCommunityBySlug({ slug }) | ||
|
||
return ( | ||
<UiPage leftAction={<IconUsersGroup />} title={slug}> | ||
{query.isLoading ? ( | ||
<UiLoader /> | ||
) : query.data ? ( | ||
<PubkeyProtocolUiCommunityCard community={query.data} /> | ||
) : ( | ||
<UiWarning message="User not found" /> | ||
)} | ||
</UiPage> | ||
) | ||
} |
Oops, something went wrong.