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(dashboard): adding button for callbackPortalUrl #4340

Merged
merged 1 commit into from
Apr 23, 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: 2 additions & 1 deletion apps/dashboard/app/callback/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default async function page() {
}

const endpoints = response.data.me?.defaultAccount.callbackEndpoints || []
const callbackPortalUrl = session?.userData?.data?.me?.defaultAccount.callbackPortalUrl

return (
<ContentContainer>
Expand All @@ -36,7 +37,7 @@ export default async function page() {
width: "100%",
}}
>
<CreateCallBack />
<CreateCallBack callbackPortalUrl={callbackPortalUrl} />
<Box
sx={{
display: {
Expand Down
32 changes: 25 additions & 7 deletions apps/dashboard/components/callback/callback-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ import InfoOutlined from "@mui/icons-material/InfoOutlined"

import { useFormStatus, useFormState } from "react-dom"

import Link from "next/link"

import FormSubmitButton from "../form-submit-button"

import { createCallbackAction } from "@/app/callback/server-actions"
import { CallBackAdditionResponse } from "@/app/callback/callback.types"

function CreateCallBack() {
type Props = {
callbackPortalUrl: string | undefined
}

function CreateCallBack({ callbackPortalUrl }: Props) {
const [open, setOpen] = useState<boolean>(false)
const { pending } = useFormStatus()
const [state, formAction] = useFormState<CallBackAdditionResponse, FormData>(
Expand Down Expand Up @@ -118,13 +124,25 @@ function CreateCallBack() {
<Typography id="modal-desc" textColor="text.tertiary" textAlign="left">
Attach Callback Endpoints
</Typography>
<Button
data-testid="add-callback-btn"
loading={pending}
onClick={() => setOpen(true)}
<Box
sx={{
display: "flex",
gap: 2,
}}
>
<AddIcon />
</Button>
{callbackPortalUrl && (
<Link href={callbackPortalUrl} passHref target="_blank">
<Button>Callback Portal</Button>
</Link>
)}
<Button
data-testid="add-callback-btn"
loading={pending}
onClick={() => setOpen(true)}
>
<AddIcon />
</Button>
</Box>
</Box>
</>
)
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/services/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2420,7 +2420,7 @@ export type GetDefaultWalletByUsernameQuery = { readonly __typename: 'Query', re
export type MeQueryVariables = Exact<{ [key: string]: never; }>;


export type MeQuery = { readonly __typename: 'Query', readonly me?: { readonly __typename: 'User', readonly createdAt: number, readonly id: string, readonly language: string, readonly phone?: string | null, readonly totpEnabled: boolean, readonly username?: string | null, readonly defaultAccount: { readonly __typename: 'ConsumerAccount', readonly defaultWalletId: string, readonly displayCurrency: string, readonly id: string, readonly level: AccountLevel, readonly wallets: ReadonlyArray<{ readonly __typename: 'BTCWallet', readonly accountId: string, readonly balance: number, readonly id: string, readonly pendingIncomingBalance: number, readonly walletCurrency: WalletCurrency } | { readonly __typename: 'UsdWallet', readonly accountId: string, readonly balance: number, readonly id: string, readonly pendingIncomingBalance: number, readonly walletCurrency: WalletCurrency }> }, readonly email?: { readonly __typename: 'Email', readonly address?: string | null, readonly verified?: boolean | null } | null } | null };
export type MeQuery = { readonly __typename: 'Query', readonly me?: { readonly __typename: 'User', readonly createdAt: number, readonly id: string, readonly language: string, readonly phone?: string | null, readonly totpEnabled: boolean, readonly username?: string | null, readonly defaultAccount: { readonly __typename: 'ConsumerAccount', readonly defaultWalletId: string, readonly displayCurrency: string, readonly id: string, readonly level: AccountLevel, readonly callbackPortalUrl: string, readonly wallets: ReadonlyArray<{ readonly __typename: 'BTCWallet', readonly accountId: string, readonly balance: number, readonly id: string, readonly pendingIncomingBalance: number, readonly walletCurrency: WalletCurrency } | { readonly __typename: 'UsdWallet', readonly accountId: string, readonly balance: number, readonly id: string, readonly pendingIncomingBalance: number, readonly walletCurrency: WalletCurrency }> }, readonly email?: { readonly __typename: 'Email', readonly address?: string | null, readonly verified?: boolean | null } | null } | null };

export type RealtimePriceQueryVariables = Exact<{
currency?: InputMaybe<Scalars['DisplayCurrency']['input']>;
Expand Down Expand Up @@ -3236,6 +3236,7 @@ export const MeDocument = gql`
pendingIncomingBalance
walletCurrency
}
callbackPortalUrl
}
totpEnabled
username
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/services/graphql/queries/me-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gql`
pendingIncomingBalance
walletCurrency
}
callbackPortalUrl
}
totpEnabled
username
Expand Down
Loading