-
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.
Ajout de nouveau component pour handle les contactPoint update et vie…
…w, et test v1 sur Person, ajout de liens externes dans PersonsingleView/edit
- Loading branch information
1 parent
12ca846
commit 9bfc24b
Showing
7 changed files
with
217 additions
and
24 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
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
90 changes: 90 additions & 0 deletions
90
src/DataTypes/common/Forms/UpdateContactPoint/UpdateContactPoint.js
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,90 @@ | ||
import React, { useEffect } from 'react'; | ||
|
||
//context | ||
import { lang } from '@/src/common/Data/GlobalConstants'; | ||
|
||
//components | ||
import Input from '@/src/common/FormElements/Input/Input'; | ||
import { useFormUtils } from '@/src/hooks/useFormUtils/useFormUtils'; | ||
|
||
|
||
const UpdateContactPoint = ({model, name, formTools, ...props}) => { | ||
|
||
const contactFormUtils = useFormUtils( | ||
{ | ||
tel: { | ||
value: model.contactPoint?.tel?.num ?? "", | ||
isValid: true | ||
}, | ||
ext: { | ||
value: model.contactPoint?.tel?.ext ?? "", | ||
isValid: true | ||
}, | ||
email: { | ||
value: model.contactPoint?.email?.address ?? "", | ||
isValid: true | ||
}, | ||
website: { | ||
value: model.contactPoint?.website?.url ?? "", | ||
isValid: true | ||
}, | ||
}, | ||
//Pass a set of rules to execute a valid response of an api request | ||
{ | ||
displayResMessage: true, | ||
} | ||
) | ||
|
||
//Update the main form state | ||
const { inputHandler } = formTools; | ||
useEffect( () => { | ||
inputHandler(name, | ||
{ | ||
tel: { | ||
num: contactFormUtils.formState.inputs.tel.value ?? "", | ||
ext: contactFormUtils.formState.inputs.ext.value ?? "", | ||
}, | ||
email: { | ||
address: contactFormUtils.formState.inputs.email.value ?? "", | ||
}, | ||
website: { | ||
url: contactFormUtils.formState.inputs.website.value ?? "", | ||
}, | ||
|
||
}, true) | ||
},[contactFormUtils.formState.inputs]) | ||
|
||
return ( | ||
<> | ||
<div className="row"> | ||
<Input | ||
className="col py-2" | ||
name="tel" | ||
label={lang.phoneNumber} | ||
formTools={contactFormUtils.formTools} | ||
/> | ||
<Input | ||
className="col py-2" | ||
name="ext" | ||
label={lang.phoneExtension} | ||
formTools={contactFormUtils.formTools} | ||
/> | ||
</div> | ||
<Input | ||
className="py-2" | ||
name="email" | ||
label={lang.email} | ||
formTools={contactFormUtils.formTools} | ||
/> | ||
<Input | ||
className="py-2" | ||
name="website" | ||
label={lang.website} | ||
formTools={contactFormUtils.formTools} | ||
/> | ||
</> | ||
) | ||
}; | ||
|
||
|
||
export default UpdateContactPoint; |
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
34 changes: 34 additions & 0 deletions
34
src/DataTypes/common/layouts/ContactPointView/ContactPointView.js
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,34 @@ | ||
import { lang } from "@/src/common/Data/GlobalConstants"; | ||
|
||
const ContactPointView = ({contact, ...props}) => { | ||
const {tel, email, website} = contact; | ||
|
||
const telSection = tel.num !== "" && ( | ||
<article className={`d-flex flex-column p-2 mb-2`}> | ||
<h5 className="text-dark mb-2">{lang.phoneNumber}</h5> | ||
{tel.num}{tel.ext !== "" && `#${tel.ext}`} | ||
</article> | ||
) | ||
const emailAddressSection = email.address !== "" && ( | ||
<article className={`d-flex flex-column p-2 mb-2`}> | ||
<h5 className="text-dark mb-2">{lang.email}</h5> | ||
{email.address} | ||
</article> | ||
) | ||
const websiteUrlSection = website.url !== "" && ( | ||
<article className={`d-flex flex-column p-2 mb-2`}> | ||
<h5 className="text-dark mb-2">{lang.website}</h5> | ||
{website.url} | ||
</article> | ||
) | ||
return ( | ||
<> | ||
{telSection} | ||
{emailAddressSection} | ||
{websiteUrlSection} | ||
|
||
</> | ||
) | ||
} | ||
|
||
export {ContactPointView} |
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