From a7f62fdb455aa1cba52f94eddf81fbbf0ea4ce42 Mon Sep 17 00:00:00 2001 From: 0xzio Date: Sun, 8 Dec 2024 13:21:32 +0800 Subject: [PATCH] feat: impove ui --- .env | 2 +- components/ContentRender/SlateContent.tsx | 2 +- .../PostActions/Comment/CommentInput.tsx | 24 ++++-- components/Profile/WalletInfo.tsx | 4 +- lib/worker/worker.ts | 4 +- package.json | 12 +-- pnpm-lock.yaml | 86 +++++++++---------- server/trpc.ts | 2 +- 8 files changed, 72 insertions(+), 64 deletions(-) diff --git a/.env b/.env index 8e33e333..f68e590f 100644 --- a/.env +++ b/.env @@ -3,4 +3,4 @@ NEXT_PUBLIC_THEME=penx-theme-garden # DATABASE_URL=postgresql://user:demo@43.154.135.183:5437/demo -DATABASE_URL="postgresql://user:penx@43.154.135.183:5432/penx" \ No newline at end of file +DATABASE_URL="postgresql://user:penx@43.154.135.183:5432/penx" diff --git a/components/ContentRender/SlateContent.tsx b/components/ContentRender/SlateContent.tsx index b677cb89..f24a2cdb 100644 --- a/components/ContentRender/SlateContent.tsx +++ b/components/ContentRender/SlateContent.tsx @@ -39,7 +39,7 @@ export function SlateContent() { }} {...attributes} > -
  • {children}
  • +
  • {children}
  • ) } diff --git a/components/PostActions/Comment/CommentInput.tsx b/components/PostActions/Comment/CommentInput.tsx index e471f559..0fc4a2f1 100644 --- a/components/PostActions/Comment/CommentInput.tsx +++ b/components/PostActions/Comment/CommentInput.tsx @@ -4,6 +4,7 @@ import LoadingDots from '@/components/icons/loading-dots' import { Button } from '@/components/ui/button' import { Textarea } from '@/components/ui/textarea' import { WalletConnectButton } from '@/components/WalletConnectButton' +import { extractErrorMessage } from '@/lib/extractErrorMessage' import { trpc } from '@/lib/trpc' import { useSession } from 'next-auth/react' import { toast } from 'sonner' @@ -19,14 +20,19 @@ const CommentSchema = z.object({ interface Props { postId: string // For reply - parentId?: string; + parentId?: string refetchComments: () => void onCancel?: () => void } const maxCharacters = 1000 -export function CommentInput({ postId, parentId, refetchComments, onCancel }: Props) { +export function CommentInput({ + postId, + parentId, + refetchComments, + onCancel, +}: Props) { const userID = useAddress() const [content, setContent] = useState('') const { isPending, mutateAsync } = trpc.comment.create.useMutation() @@ -52,7 +58,7 @@ export function CommentInput({ postId, parentId, refetchComments, onCancel }: Pr postId, userId: userID as string, content, - parentId + parentId, }) setContent('') @@ -61,7 +67,8 @@ export function CommentInput({ postId, parentId, refetchComments, onCancel }: Pr toast.success('Comment submitted successfully!') } catch (error) { console.log('Failed to submit comment.', 'color:red', error) - toast.error('Failed to submit comment.') + const msg = extractErrorMessage(error) + toast.error(msg || 'Failed to submit comment.') } } @@ -82,16 +89,17 @@ export function CommentInput({ postId, parentId, refetchComments, onCancel }: Pr
    - { - parentId && - } + )} {!authenticated ? ( diff --git a/components/Profile/WalletInfo.tsx b/components/Profile/WalletInfo.tsx index 8ea05e14..b8b09755 100644 --- a/components/Profile/WalletInfo.tsx +++ b/components/Profile/WalletInfo.tsx @@ -22,7 +22,7 @@ export function WalletInfo() { }, }) - if (!address) return null + if (!address || !data || !penBalance) return null if (isLoading) { return ( @@ -39,7 +39,7 @@ export function WalletInfo() {
    $ETH
    {typeof data !== 'undefined' && - `${precision.toDecimal(data.value).toFixed(5)}`} + `${precision.toDecimal(data.value).toFixed(5) || '0'}`}
    diff --git a/lib/worker/worker.ts b/lib/worker/worker.ts index 12323231..f3df5ee3 100644 --- a/lib/worker/worker.ts +++ b/lib/worker/worker.ts @@ -5,7 +5,7 @@ import { pollingCloudSync } from './pollingCloudSync' self.addEventListener('message', async (event) => { if (event.data === WorkerEvents.START_POLLING) { console.log('===========start polling......') - pollingBackupToGoogle() - pollingCloudSync() + // pollingBackupToGoogle() + // pollingCloudSync() } }) diff --git a/package.json b/package.json index adc17482..83dc183f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@floating-ui/react": "^0.25.4", "@glideapps/glide-data-grid": "^6.0.3", "@hookform/resolvers": "^3.9.0", - "@penxio/types": "^0.0.6", + "@penxio/types": "^0.0.9", "@prisma/client": "^5.21.1", "@privy-io/server-auth": "^1.15.0", "@radix-ui/react-accordion": "^1.2.1", @@ -146,11 +146,11 @@ "octokit": "^4.0.2", "openai-edge": "^1.2.2", "p-retry": "^6.2.0", - "penx-theme-card": "^0.0.6", - "penx-theme-garden": "^0.0.6", - "penx-theme-micro": "^0.0.6", - "penx-theme-minimal": "^0.0.6", - "penx-theme-photo": "^0.0.6", + "penx-theme-card": "^0.0.9", + "penx-theme-garden": "^0.0.9", + "penx-theme-micro": "^0.0.9", + "penx-theme-minimal": "^0.0.9", + "penx-theme-photo": "^0.0.9", "prisma-extension-pagination": "^0.7.4", "prismjs": "^1.29.0", "rc-table": "^7.48.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1a2a024b..604947ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,8 +36,8 @@ importers: specifier: ^3.9.0 version: 3.9.0(react-hook-form@7.53.1(react@18.2.0)) '@penxio/types': - specifier: ^0.0.6 - version: 0.0.6 + specifier: ^0.0.9 + version: 0.0.9 '@prisma/client': specifier: ^5.21.1 version: 5.21.1(prisma@5.21.1) @@ -402,20 +402,20 @@ importers: specifier: ^6.2.0 version: 6.2.0 penx-theme-card: - specifier: ^0.0.6 - version: 0.0.6 + specifier: ^0.0.9 + version: 0.0.9 penx-theme-garden: - specifier: ^0.0.6 - version: 0.0.6 + specifier: ^0.0.9 + version: 0.0.9 penx-theme-micro: - specifier: ^0.0.6 - version: 0.0.6 + specifier: ^0.0.9 + version: 0.0.9 penx-theme-minimal: - specifier: ^0.0.6 - version: 0.0.6 + specifier: ^0.0.9 + version: 0.0.9 penx-theme-photo: - specifier: ^0.0.6 - version: 0.0.6 + specifier: ^0.0.9 + version: 0.0.9 prisma-extension-pagination: specifier: ^0.7.4 version: 0.7.4(@prisma/client@5.21.1(prisma@5.21.1)) @@ -2190,11 +2190,11 @@ packages: resolution: {integrity: sha512-HNjmfLQEVRZmHRET336f20H/8kOozUGwk7yajvsonjNxbj2wBTK1WsQuHkD5yYh9RxFGL2EyDHryOihOwUoKDA==} engines: {node: '>= 10.0.0'} - '@penxio/types@0.0.6': - resolution: {integrity: sha512-yXxRUtJ16XgNX3br7qsxCgX3zhunEsQKWs0iEewmbuwj8AZ+QyK4tDg7Qa69nHdtGdl7l3I7ms/+sL0kOfW3mw==} + '@penxio/types@0.0.9': + resolution: {integrity: sha512-3RLn51E/xGvsANJy7yFnztXsdJJYEf1JEACJt9v0x5/BVBi7eh2l7gqjtgmj389aqmYMvbDZyc07pco2VdGVTA==} - '@penxio/utils@0.0.6': - resolution: {integrity: sha512-sZJpENSP2LMiVrbSVte5UJPI0MdY5/+yKrK2HewpO3djB2931o+4GUoDe+H64R5fgbW4JufazhCCCszfsOyxzQ==} + '@penxio/utils@0.0.9': + resolution: {integrity: sha512-axF+PTPe4O5cwHPzYtn2nEG2fC1GCnGLZpQDTAJjfYOtD4jAVQBM4HI47a/5hMWg5sDBSAsJUzz1ZmPmHDO9KA==} '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} @@ -7390,20 +7390,20 @@ packages: pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} - penx-theme-card@0.0.6: - resolution: {integrity: sha512-rYnddosdT9itz6lK2I61El6+K1Lq6k52KTGSofKLL7fRIBAtFqY52UmjFVxMcHkGgnkbvclE2WIofsaxgH8ScA==} + penx-theme-card@0.0.9: + resolution: {integrity: sha512-elLLSvWekNqGH0QKhYtnoM18G7N20enCwGZKH1LTBrIMJqk7d5CB1YrHp8oSCJ43N1B72YyzNREjJxr8/1tcgw==} - penx-theme-garden@0.0.6: - resolution: {integrity: sha512-xuem+96PV5ya5ja2npxRntG5nFtODikXWlc/k0lGtlzgdYCjTVLnyMfnCLysLDec8Ju2EHgmm5E9d5HmQhe8xA==} + penx-theme-garden@0.0.9: + resolution: {integrity: sha512-Bo+sB5MHboFZ/WGK9MRxUIjmbiQcV24dgbhH2TNfTW01UOdqV9Y//Qqpi25QqJc0C2IpUiGZrvDXdw+oGxf95w==} - penx-theme-micro@0.0.6: - resolution: {integrity: sha512-Mw0245JA5Ke3MggKsG3LQuYS8mi0eF0Qi8zkNP85eV9FKsA75g97VpN4yusuhU5nXNdWgvZdQsyoKuyiv9IRdQ==} + penx-theme-micro@0.0.9: + resolution: {integrity: sha512-ctHZ+35nFXbLvMKdNsuToSA97nK3mzAB4aQX/cWirntjfhsU7nKx1d/bw73S/UOJw8bnpJ3AIQw5zA6u+lq4ZQ==} - penx-theme-minimal@0.0.6: - resolution: {integrity: sha512-fSJY8akN504BNuF5+MeclVGq/vUxfAkCka5FcHh3d3h1Um85msJhK2MykM9jmGDTQh0w5wf5SZK/WUdKrLiemA==} + penx-theme-minimal@0.0.9: + resolution: {integrity: sha512-/fkhezG/DDNDznd7JtFKLjsPaM0nMj4HNaWsyo0jR/jTelgZzZYMqFsOaaJJMq2961dCZiz8W9BxY87ql+SqRg==} - penx-theme-photo@0.0.6: - resolution: {integrity: sha512-CMtDXKnS2WNBQeROWDP/fCQuIy3gHWayjpnp1Wj6CdOxbhlpTEAPNdyCHBigLuZriCMSVyuyxfeYI8ErDykSSQ==} + penx-theme-photo@0.0.9: + resolution: {integrity: sha512-74F7XqXn0qbEMFqdmwxznc8+QOjZPeil78+VrtcNwoBJZ8BTPVCwBOt+twajj7nbliu4WIX5nWZcWoUP/Tk5zQ==} performance-now@2.1.0: resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} @@ -11465,9 +11465,9 @@ snapshots: '@parcel/watcher-win32-ia32': 2.4.1 '@parcel/watcher-win32-x64': 2.4.1 - '@penxio/types@0.0.6': {} + '@penxio/types@0.0.9': {} - '@penxio/utils@0.0.6': + '@penxio/utils@0.0.9': dependencies: clsx: 2.1.1 tailwind-merge: 2.5.4 @@ -17989,42 +17989,42 @@ snapshots: pathe@1.1.2: {} - penx-theme-card@0.0.6: + penx-theme-card@0.0.9: dependencies: - '@penxio/types': 0.0.6 - '@penxio/utils': 0.0.6 + '@penxio/types': 0.0.9 + '@penxio/utils': 0.0.9 clsx: 2.1.1 github-slugger: 2.0.0 tailwind-merge: 2.5.4 - penx-theme-garden@0.0.6: + penx-theme-garden@0.0.9: dependencies: - '@penxio/types': 0.0.6 - '@penxio/utils': 0.0.6 + '@penxio/types': 0.0.9 + '@penxio/utils': 0.0.9 clsx: 2.1.1 github-slugger: 2.0.0 tailwind-merge: 2.5.4 - penx-theme-micro@0.0.6: + penx-theme-micro@0.0.9: dependencies: - '@penxio/types': 0.0.6 - '@penxio/utils': 0.0.6 + '@penxio/types': 0.0.9 + '@penxio/utils': 0.0.9 clsx: 2.1.1 github-slugger: 2.0.0 tailwind-merge: 2.5.4 - penx-theme-minimal@0.0.6: + penx-theme-minimal@0.0.9: dependencies: - '@penxio/types': 0.0.6 - '@penxio/utils': 0.0.6 + '@penxio/types': 0.0.9 + '@penxio/utils': 0.0.9 clsx: 2.1.1 github-slugger: 2.0.0 tailwind-merge: 2.5.4 - penx-theme-photo@0.0.6: + penx-theme-photo@0.0.9: dependencies: - '@penxio/types': 0.0.6 - '@penxio/utils': 0.0.6 + '@penxio/types': 0.0.9 + '@penxio/utils': 0.0.9 clsx: 2.1.1 github-slugger: 2.0.0 tailwind-merge: 2.5.4 diff --git a/server/trpc.ts b/server/trpc.ts index 9bbfc565..5e6d5918 100644 --- a/server/trpc.ts +++ b/server/trpc.ts @@ -64,7 +64,7 @@ export const protectedProcedure = t.procedure.use( if ( ![UserRole.ADMIN, UserRole.AUTHOR].includes(role) && - path !== 'user.me' + !['user.me', 'comment.create'].includes(path) ) { throw new TRPCError({ code: 'UNAUTHORIZED',