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

[AMB-32] refactor: QA updates #16

Merged
merged 24 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
af13866
chore: remove comments
secondl1ght Jul 9, 2024
b3d4c5b
fix: only set initial document state on client
secondl1ght Jul 9, 2024
8dbe3f9
chore: format
secondl1ght Jul 9, 2024
cd25609
chore: delete not used file
secondl1ght Jul 9, 2024
8eaf2ce
refactor: update console logs and toasts
secondl1ght Jul 9, 2024
1810aeb
refactor: match file names to comp
secondl1ght Jul 9, 2024
479764e
style: move css into one layer
secondl1ght Jul 9, 2024
8f1f55b
refactor: use route groups to cleanup routing
secondl1ght Jul 9, 2024
6fd7350
refactor: create more comp directories
secondl1ght Jul 9, 2024
7c564fe
Merge branch 'main' of github.com:AmbossTech/amboss-banco into qa
secondl1ght Jul 9, 2024
f659898
refactor: move cn fn to utils dir
secondl1ght Jul 9, 2024
ed9ee81
fix: import
secondl1ght Jul 9, 2024
503666b
chore: copy clarify
secondl1ght Jul 10, 2024
3fce00f
feat: mobile menu missing parts
secondl1ght Jul 10, 2024
8a5915f
fix: dont allow empty messages
secondl1ght Jul 10, 2024
9969bf7
fix: console errors and copy fn
secondl1ght Jul 10, 2024
bbbcd97
refactor: move dupe file
secondl1ght Jul 10, 2024
46f332d
style: responsive and copy improvements
secondl1ght Jul 10, 2024
6e6fa8b
feat: set active contact after adding
secondl1ght Jul 10, 2024
26d4f7b
feat: dynamic external header links
secondl1ght Jul 10, 2024
c36f55b
style: make table responsive
secondl1ght Jul 10, 2024
447d329
feat: set active wallet on creation
secondl1ght Jul 10, 2024
cfe996c
fix: show zero
secondl1ght Jul 10, 2024
24ac5f2
fix: reset input on send
secondl1ght Jul 10, 2024
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
8 changes: 0 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,12 @@ WORKDIR /app
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

# RUN addgroup --system --gid 1001 nodejs
# RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

RUN mkdir .next
# RUN chown nextjs:nodejs .next

COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
# COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

# USER nextjs

EXPOSE 3000

Expand Down
3 changes: 1 addition & 2 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
"components": "@/components"
}
}
1 change: 0 additions & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ import en from './messages/en.json';
type Messages = typeof en;

declare global {
// Use type safe message keys with `next-intl`
interface IntlMessages extends Messages {}
}
2 changes: 0 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const nextConfig = {
config.resolve.fallback.fs = false;
}

// // Perform customizations to webpack config
config.plugins.push(
new webpack.IgnorePlugin({ resourceRegExp: /\/__tests__\// })
);
Expand All @@ -39,7 +38,6 @@ const nextConfig = {
layers: true,
};

// Important: return the modified config
return config;
},
};
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions src/app/(app)/(layout)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

import { AppLayout } from '@/components/layout/AppLayout';

export default function Layout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return <AppLayout>{children}</AppLayout>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default function Page({
return (
<div className="mt-4 flex w-full flex-col items-center justify-center">
<h1 className="text-lg font-bold">Payment Options</h1>
<div className="mt-4 flex justify-center gap-4">
<div className="mt-4 flex flex-col justify-center gap-4 md:flex-row">
<Link
href={ROUTES.app.wallet.send.invoice(
href={ROUTES.wallet.send.invoice(
params.walletId,
params.accountId,
assetId
Expand All @@ -36,7 +36,7 @@ export default function Page({
</Link>

<Link
href={ROUTES.app.wallet.send.address(
href={ROUTES.wallet.send.address(
params.walletId,
params.accountId,
assetId
Expand Down
3 changes: 1 addition & 2 deletions src/app/app/layout.tsx → src/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { redirect } from 'next/navigation';

import { AppLayout } from '@/components/layout/AppLayout';
import { useUserQuery } from '@/graphql/queries/__generated__/user.generated';
import { ROUTES } from '@/utils/routes';

Expand All @@ -21,5 +20,5 @@ export default function Layout({
redirect(ROUTES.login);
}

return <AppLayout>{children}</AppLayout>;
return <>{children}</>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ROUTES } from '@/utils/routes';

export default function Page() {
return (
<div className="flex justify-center py-4">
<div className="flex justify-center p-4">
<Card>
<CardHeader>
<CardTitle>Welcome to Banco.</CardTitle>
Expand Down
32 changes: 32 additions & 0 deletions src/app/(public)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use client';

import { redirect } from 'next/navigation';

import { ExternalHeader } from '@/components/header/ExternalHeader';
import { useUserQuery } from '@/graphql/queries/__generated__/user.generated';
import { ROUTES } from '@/utils/routes';

export default function Layout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const { data, loading } = useUserQuery();

if (loading) {
return null;
}

if (data?.user.id) {
redirect(ROUTES.dashboard);
}

return (
<main className="flex min-h-screen flex-col items-center justify-start p-2">
<ExternalHeader />
<div className="flex w-full max-w-5xl items-center justify-center py-10">
{children}
</div>
</main>
);
}
5 changes: 5 additions & 0 deletions src/app/(public)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LoginForm } from '@/components/form/LoginForm';

export default function Page() {
return <LoginForm />;
}
5 changes: 5 additions & 0 deletions src/app/(public)/sign-up/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignUpForm } from '@/components/form/SignUpForm';

export default function Page() {
return <SignUpForm />;
}
17 changes: 8 additions & 9 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
@tailwind utilities;

@layer base {
* {
@apply border-border;
}

body {
@apply bg-background text-foreground;
}

:root {
--background: 0 0% 100%;
--foreground: 224 71.4% 4.1%;
Expand Down Expand Up @@ -48,12 +56,3 @@
--ring: 263.4 70% 50.4%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
13 changes: 0 additions & 13 deletions src/app/login/page.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/app/sign-up/page.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions src/components/Wasm.tsx

This file was deleted.

17 changes: 15 additions & 2 deletions src/components/button/LogoutButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ import { ROUTES } from '@/utils/routes';

import { Button } from '../ui/button';
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip';
import { useToast } from '../ui/use-toast';

export const LogoutButtonWithTooltip = () => {
const { toast } = useToast();

const [logout] = useLogoutMutation({
onCompleted: () => {
window.location.href = ROUTES.home;
},
onError: err => console.log('ERROR', err),
onError: () =>
toast({
variant: 'destructive',
title: 'Error logging out.',
}),
});

return (
Expand All @@ -38,12 +45,18 @@ export const LogoutButtonWithTooltip = () => {
};

export const LogoutButton = () => {
const { toast } = useToast();

const [logout] = useLogoutMutation({
onCompleted: () => {
localStorage.removeItem(LOCALSTORAGE_KEYS.currentWalletId);
window.location.href = ROUTES.home;
},
onError: err => console.log('ERROR', err),
onError: () =>
toast({
variant: 'destructive',
title: 'Error logging out.',
}),
});

return (
Expand Down
9 changes: 8 additions & 1 deletion src/components/button/RefreshWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ import { FC } from 'react';
import { useRefreshWalletMutation } from '@/graphql/mutations/__generated__/refreshWallet.generated';

import { CommandItem } from '../ui/command';
import { useToast } from '../ui/use-toast';

export const RefreshWallet: FC<{
title: string;
walletId: string;
fullScan: boolean;
}> = ({ walletId, fullScan, title }) => {
const { toast } = useToast();

const [refresh, { loading }] = useRefreshWalletMutation({
variables: { input: { wallet_id: walletId, full_scan: fullScan } },
refetchQueries: ['getWallet'],
onError: err => console.log('ERROR', err),
onError: () =>
toast({
variant: 'destructive',
title: 'Error refeshing wallet.',
}),
});

return (
Expand Down
17 changes: 7 additions & 10 deletions src/components/button/VaultButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { z } from 'zod';

import { useCheckPasswordMutation } from '@/graphql/mutations/__generated__/checkPassword.generated';
import { useUserQuery } from '@/graphql/queries/__generated__/user.generated';
import { cn } from '@/lib/utils';
import { useKeyStore } from '@/stores/keys';
import { cn } from '@/utils/cn';
import { handleApolloError } from '@/utils/error';
import { WorkerMessage, WorkerResponse } from '@/workers/account/types';

Expand Down Expand Up @@ -59,13 +59,9 @@ const UnlockDialogContent: FC<{ callback: () => void }> = ({ callback }) => {
const { data } = useUserQuery({ errorPolicy: 'ignore' });

const [checkPassword] = useCheckPasswordMutation({
onCompleted: data => {
if (!data.checkPassword) {
// TODO INVALID PASSWORD
} else {
setMasterKey(tempMasterKey);
callback();
}
onCompleted: () => {
setMasterKey(tempMasterKey);
callback();
},
onError: error => {
const messages = handleApolloError(error);
Expand Down Expand Up @@ -139,7 +135,7 @@ const UnlockDialogContent: FC<{ callback: () => void }> = ({ callback }) => {
<DialogHeader>
<DialogTitle>Unlock your vault</DialogTitle>
<DialogDescription>
This will allow you to encrypt and decrypt your private keys
This will allow you to send funds and messages.
</DialogDescription>
</DialogHeader>
<Form {...form}>
Expand Down Expand Up @@ -235,7 +231,8 @@ export const VaultButton: FC<{
<DialogHeader>
<DialogTitle>Lock your vault</DialogTitle>
<DialogDescription>
You will not be able to encrypt or decrypt your private keys
You will not be able to send funds or messages until the vault
is unlocked with your Master Password.
</DialogDescription>
</DialogHeader>
<DialogFooter className="gap-2 sm:justify-center">
Expand Down
7 changes: 3 additions & 4 deletions src/components/button/WalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
PopoverTrigger,
} from '@/components/ui/popover';
import { useGetAllWalletsQuery } from '@/graphql/queries/__generated__/wallet.generated';
import { cn } from '@/lib/utils';
import { useChat, useContactStore } from '@/stores/contacts';
import { cn } from '@/utils/cn';
import { LOCALSTORAGE_KEYS } from '@/utils/constants';
import { ROUTES } from '@/utils/routes';

Expand Down Expand Up @@ -50,7 +50,6 @@ export function WalletButton() {
}, [value, data, setValue]);

const wallets = useMemo(() => {
// return [];
const walletData = data?.wallets.find_many || [];

return walletData.map(w => {
Expand Down Expand Up @@ -94,7 +93,7 @@ export function WalletButton() {
value={w.value}
onSelect={currentValue => {
setValue(currentValue);
push(ROUTES.app.home);
push(ROUTES.dashboard);
setOpen(false);
setCurrentContact(undefined);
setCurrentPaymentOption(undefined);
Expand Down Expand Up @@ -131,7 +130,7 @@ export function WalletButton() {
}}
>
<Link
href={ROUTES.app.wallet.settings(value)}
href={ROUTES.wallet.settings(value)}
className="flex w-full items-center justify-between"
>
Settings
Expand Down
Loading
Loading