Skip to content

Commit

Permalink
fix img tag to next image
Browse files Browse the repository at this point in the history
  • Loading branch information
dEdmishka committed Jan 29, 2024
1 parent 99e3123 commit 3700623
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/pages/profile/file-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Icons } from '@/components/ui/icons'
import { Progress } from '@/components/ui/progress'
import { PROGRESS_TIMEOUT_DELAY } from '@/constants'
import { cn } from '@/lib/utils'
import Image from 'next/image'
import { FC, FormEvent, useRef, useState } from 'react'

type FileInputProps = {
Expand Down Expand Up @@ -32,17 +33,13 @@ const FileInput: FC<FileInputProps> = ({ className }) => {
setImage(file)

const fileReader = new FileReader()

fileReader.readAsDataURL(file)

fileReader.onloadstart = () => {
setProgress(0)
}

fileReader.onprogress = (progress) => {
setProgress((progress.loaded / progress.total) * 100)
}

fileReader.onload = () => {
setPreview(fileReader.result as string)
setTimeout(() => setProgress(0), PROGRESS_TIMEOUT_DELAY)
Expand All @@ -69,7 +66,11 @@ const FileInput: FC<FileInputProps> = ({ className }) => {
<div className="relative">
{preview ? (
<div>
<img className="w-[144px] h-[144px] rounded-3xl" src={preview} />
<Image
alt="avatar"
className="w-[144px] h-[144px] rounded-3xl"
src={preview}
/>
<Icons.cross
className="absolute z-10 top-4 right-4 text-base-white dark:text-base-black"
onClick={clearSelectFile}
Expand Down

0 comments on commit 3700623

Please sign in to comment.