-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #756 from Mat-icon/feat/HNG-ImageBody-team-bulldozer
Feat/hng image body team bulldozer
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/app/dashboard/(admin)/admin/email/edit-in-buit-templates/_components/ImageBody.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"use client"; | ||
|
||
import Image from "next/image"; | ||
import React, { useState } from "react"; | ||
|
||
const ImageBody: React.FC = () => { | ||
const [selectedImage, setSelectedImage] = useState< | ||
string | ArrayBuffer | undefined | ||
>(); | ||
|
||
const handleImageChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const file = event.target.files?.[0]; | ||
if (file) { | ||
const reader = new FileReader(); | ||
reader.onloadend = () => { | ||
setSelectedImage(reader.result ?? undefined); | ||
}; | ||
reader.readAsDataURL(file); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="h-96 w-3/5 rounded-sm border bg-white shadow-md hover:border-orange-500"> | ||
<label className="flex flex-col items-center"> | ||
<div className="flex h-48 w-full cursor-pointer items-center justify-center bg-gray-50"> | ||
{selectedImage ? ( | ||
<Image | ||
src={selectedImage as string} | ||
alt="Selected" | ||
className="h-full w-full object-contain" | ||
width={192} | ||
height={192} | ||
/> | ||
) : ( | ||
<div className="h-24 w-24"> | ||
<Image | ||
src="/images/icon.png" | ||
alt="Selected" | ||
width={192} | ||
height={192} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
<input | ||
type="file" | ||
accept="image/*" | ||
onChange={handleImageChange} | ||
className="hidden" | ||
/> | ||
</label> | ||
<div className="w-full p-5"> | ||
<h1 className="mt-6 text-center text-2xl font-semibold"> | ||
Welcome to Boilerplate! | ||
</h1> | ||
<p className="text-center text-gray-600">Thanks for signing up</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ImageBody; |