Skip to content

Commit

Permalink
upd url
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnLuIoT committed Sep 1, 2024
1 parent 48f0175 commit c688b5f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/app/api/uploadthing/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ const onUploadComplete = async ({
key: file.key,
name: file.name,
userId: metadata.userId,
url: `https://uploadthing-prod.s3.us-west-2.amazonaws.com/${file.key}`,
url: file.url,
// url: `https://uploadthing-prod.s3.us-west-2.amazonaws.com/${file.key}`,
uploadStatus: 'PROCESSING'
}
})

try {
const response = await fetch(`https://uploadthing-prod.s3.us-west-2.amazonaws.com/${file.key}`)
const response = await fetch(file.url)

const blob = await response.blob()

Expand Down
2 changes: 0 additions & 2 deletions src/components/PdfRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ const PdfRenderer = ({ url }: PdfRendererProps) => {
resolver: zodResolver(CustomPageValidator)
})

console.log(errors)

const { width, ref, height } = useResizeDetector()

const handlePageSubmit = ({ page }: TCustomPageValidator) => {
Expand Down
33 changes: 33 additions & 0 deletions src/components/button/UploadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ import { useToast } from '../ui/use-toast'
import { trpc } from '@/app/_trpc/client'
import { useRouter } from 'next/navigation'

function UploadProgressComponent({ uploadProgress }: { uploadProgress: number }) {
return (
<div className="m-4 h-64 rounded-lg border border-dashed border-gray-300">
<div className="flex h-full w-full items-center justify-center">
<div className="flex h-full w-full flex-col items-center justify-center rounded-lg bg-gray-50">
<div className="mx-auto mt-4 w-full max-w-xs">
<Progress
indicatorColor={uploadProgress === 100 ? 'bg-green-500' : ''}
value={uploadProgress}
className="h-1 w-full bg-zinc-200"
/>
{uploadProgress === 100 ? (
<div className="flex items-center justify-center gap-1 pt-2 text-center text-sm text-zinc-700">
<Loader2 className="h-3 w-3 animate-spin" />
Redirecting...
</div>
) : (
<div className="flex items-center justify-center gap-1 pt-2 text-center text-sm text-zinc-700">
<Loader2 className="h-3 w-3 animate-spin" />
Uploading...
</div>
)}
</div>
</div>
</div>
</div>
)
}

const UploadDropzone = ({ isSubscribed }: { isSubscribed: boolean }) => {
const router = useRouter()

Expand Down Expand Up @@ -45,6 +74,10 @@ const UploadDropzone = ({ isSubscribed }: { isSubscribed: boolean }) => {
return interval
}

if (isUploading) {
return <UploadProgressComponent uploadProgress={uploadProgress} />
}

return (
<Dropzone
multiple={false}
Expand Down
1 change: 0 additions & 1 deletion src/components/chat/ChatWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const ChatWrapper = ({ fileId, isSubscribed }: ChatWrapperProps) => {
<div className="mb-28 flex flex-1 flex-col justify-between">
<Messages fileId={fileId} />
</div>

<ChatInput />
</div>
</ChatContextProvider>
Expand Down

0 comments on commit c688b5f

Please sign in to comment.