-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reading additionnal user infos in front-end
- Loading branch information
Showing
14 changed files
with
130 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,83 @@ | ||
import {useForm,FieldError} from 'react-hook-form'; | ||
import { useAccountContext } from '../../contexts/Account_Context'; | ||
import { useAppContext } from '../../contexts/AppContext'; | ||
import { Button } from 'flowbite-react'; | ||
|
||
|
||
type Details = { | ||
picture: string; | ||
fullname: string; | ||
email: string; | ||
website: string; | ||
reason: string; | ||
notes: string; | ||
} | ||
|
||
|
||
|
||
export function DetailsPage(){ | ||
const {register,handleSubmit,formState:{errors}}= useForm<Details>(); | ||
const { api, selectedAccount } = useAppContext(); | ||
const { role,infos,dispatch0 } = useAccountContext(); | ||
|
||
|
||
|
||
function onSubmit(details:Details){ | ||
let pic=""; | ||
if (!details.picture||details.picture===""){ | ||
pic=`../../../johndoe.png` | ||
|
||
}else{pic=details.picture} | ||
let all_infos:string = `${details.fullname}:${pic}:${details.email}:${details.website}:${details.reason}:${details.notes}`; | ||
dispatch0({type:`SET_INFOS`,payload:all_infos}); | ||
//console.log(infos.split(`:`)[1]); | ||
|
||
} | ||
|
||
function getEditorStyle(fieldError: FieldError|undefined){ | ||
return fieldError?'border-red-500':``; | ||
} | ||
|
||
const fieldstyle = "flex flex-col mb-2" | ||
return( | ||
<div> | ||
<form noValidate onSubmit={handleSubmit(onSubmit)}> | ||
<div className={fieldstyle}> | ||
<label htmlFor='picture'>Link to Avatar Picture</label> | ||
<input type='text' id="picture" {...register('picture')}/> | ||
</div> | ||
<div className={fieldstyle}> | ||
<label htmlFor='fullname' >Full Name</label> | ||
<input type='text' id="fullname" className={getEditorStyle(errors.fullname)}{...register('fullname',{ | ||
required:`You must enter your full name` | ||
})}/> | ||
</div> | ||
<div className={fieldstyle}> | ||
<label htmlFor='email'>e-mail address</label> | ||
<input type='text' id ="email" className={getEditorStyle(errors.email)}{...register('email',{ | ||
required:`You must enter your e-mail address` | ||
})}/> | ||
</div> | ||
<div className={fieldstyle}> | ||
<label htmlFor='website'>One of your social website(Linkedin, Facebook, etc...)</label> | ||
<input type='text' id="website" {...register('website')}/> | ||
</div> | ||
<div className={fieldstyle}> | ||
<label htmlFor='reason'>Subscription Motivation</label> | ||
<input type='text' id="reason" {...register('reason')}/> | ||
</div> | ||
<div className={fieldstyle}> | ||
<label htmlFor='notes'>Additional Informations</label> | ||
<input type='text' id="notes" {...register('notes')}/> | ||
</div> | ||
<div> | ||
<Button | ||
type="submit" | ||
className="bg-blue-600 text-white font-bold text-xl"> | ||
Submit | ||
</Button> | ||
</div> | ||
</form> | ||
</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
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