generated from 202306-NEA-DZ-FEW/capstone-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #69 from 24-profile
Create an account page with the following features: updating profile information, deleting items, and modifying item data.
- Loading branch information
Showing
13 changed files
with
532 additions
and
84 deletions.
There are no files selected for viewing
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,46 @@ | ||
import { useState } from "react"; | ||
|
||
import { deleteDocData } from "@/lib/firebase/firestoreFunctions"; | ||
|
||
import Button from "../button/Button"; | ||
|
||
export default function DeleteWarning({ | ||
setDeleteWarningItem, | ||
deleteWarningItem, | ||
setItems, | ||
items, | ||
}) { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const handleDelete = async () => { | ||
setIsLoading(true); | ||
await deleteDocData("items", deleteWarningItem); | ||
setItems(items.filter((item) => item.id !== deleteWarningItem)); | ||
setDeleteWarningItem(false); | ||
setIsLoading(false); | ||
}; | ||
return ( | ||
<div className='fixed w-full h-full inset-0 z-40 flex justify-center items-center overflow-hidden transition-opacity'> | ||
<div className='absolute w-full h-full bg-[black] opacity-80 right-0 top-0'></div> | ||
<div className='relative text-white py-12 px-16 bg-[#00000059] rounded-lg z-60 shadow-xl border border-slate-200 '> | ||
<p> Do you want to delete this item?</p> | ||
<div className='flex gap-9 mt-10 w-full justify-center'> | ||
<Button | ||
className={`${isLoading ? "bg-slate-300 " : "bg-red"}`} | ||
onClick={handleDelete} | ||
disabled={isLoading} | ||
> | ||
Delete | ||
</Button> | ||
<Button | ||
onClick={() => setDeleteWarningItem(false)} | ||
variant='outlinePrimary' | ||
className={`${isLoading ? "bg-slate-300 " : ""}`} | ||
disabled={isLoading} | ||
> | ||
Cancel | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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
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
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,42 @@ | ||
import clsx from "clsx"; | ||
const Input = ({ | ||
name, | ||
type, | ||
labelText, | ||
placeholder, | ||
register, | ||
requiredMessage, | ||
validation, | ||
errors, | ||
}) => { | ||
return ( | ||
<> | ||
<label | ||
htmlFor={name} | ||
className='block text-base font-light text-slate-700 -mb-4' | ||
> | ||
{labelText} | ||
</label> | ||
<input | ||
{...register(name, { | ||
required: requiredMessage, | ||
...validation, | ||
})} | ||
placeholder={placeholder} | ||
type={type} | ||
className={clsx( | ||
"p-2 block w-full border rounded-md focus:outline-none focus:ring-2 focus:ring-green", | ||
{ | ||
"border-red": errors[name], | ||
"border-slate-300": !errors[name], | ||
}, | ||
)} | ||
/> | ||
{errors[name] && ( | ||
<span className='text-red'>{errors[name].message}</span> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default Input; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
/* eslint-disable @next/next/no-img-element */ | ||
import { AiFillCamera } from "react-icons/ai"; | ||
|
||
function AvatarUploadImage({ image, setFile, file }) { | ||
return ( | ||
<> | ||
<div className='group w-24 h-24 rounded-full relative '> | ||
<input | ||
onChange={(e) => { | ||
setFile(e.target.files[0]); | ||
}} | ||
type='file' | ||
className='absolute top-0 left-0 right-0 bottom-0 rounded-full opacity-0 z-30 cursor-pointer' | ||
/> | ||
<div className='hidden group-hover:flex justify-center items-center absolute top-0 left-0 right-0 bottom-0 '> | ||
<div className='absolute top-0 left-0 right-0 bottom-0 bg-black opacity-60 rounded-full'></div> | ||
<AiFillCamera className='text-5xl text-white z-10' /> | ||
</div> | ||
<img | ||
src={file ? URL.createObjectURL(file) : image} | ||
alt='avatar' | ||
className='rounded-full object-cover w-full h-full' | ||
/> | ||
</div> | ||
<p className='text-sm text-black -mt-4'> | ||
Change your profile picture | ||
</p> | ||
</> | ||
); | ||
} | ||
|
||
export default AvatarUploadImage; |
Oops, something went wrong.