Skip to content

Commit

Permalink
feat: impove ui
Browse files Browse the repository at this point in the history
  • Loading branch information
0xzio committed Dec 8, 2024
1 parent 566ff46 commit a7f62fd
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ NEXT_PUBLIC_THEME=penx-theme-garden

# DATABASE_URL=postgresql://user:[email protected]:5437/demo

DATABASE_URL="postgresql://user:[email protected]:5432/penx"
DATABASE_URL="postgresql://user:[email protected]:5432/penx"
2 changes: 1 addition & 1 deletion components/ContentRender/SlateContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function SlateContent() {
}}
{...attributes}
>
<li>{children}</li>
<li className="[&>*]:inline-flex">{children}</li>
</ul>
)
}
Expand Down
24 changes: 16 additions & 8 deletions components/PostActions/Comment/CommentInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand All @@ -52,7 +58,7 @@ export function CommentInput({ postId, parentId, refetchComments, onCancel }: Pr
postId,
userId: userID as string,
content,
parentId
parentId,
})

setContent('')
Expand All @@ -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.')
}
}

Expand All @@ -82,16 +89,17 @@ export function CommentInput({ postId, parentId, refetchComments, onCancel }: Pr
</div>

<div className="flex justify-end">
{
parentId && <Button
{parentId && (
<Button
onClick={() => {
setContent('')
onCancel && onCancel()
}}
className="w-20 text-xs h-8 mr-1">
className="w-20 text-xs h-8 mr-1"
>
<p>Cancel</p>
</Button>
}
)}

{!authenticated ? (
<WalletConnectButton className="w-30 text-xs h-8">
Expand Down
4 changes: 2 additions & 2 deletions components/Profile/WalletInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function WalletInfo() {
},
})

if (!address) return null
if (!address || !data || !penBalance) return null

if (isLoading) {
return (
Expand All @@ -39,7 +39,7 @@ export function WalletInfo() {
<div className="text-sm text-foreground/60">$ETH</div>
<div>
{typeof data !== 'undefined' &&
`${precision.toDecimal(data.value).toFixed(5)}`}
`${precision.toDecimal(data.value).toFixed(5) || '0'}`}
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions lib/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
})
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
86 changes: 43 additions & 43 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit a7f62fd

Please sign in to comment.