-
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 #1128 from culturecreates/develop
Develop
- Loading branch information
Showing
52 changed files
with
3,720 additions
and
262 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
/node_modules | ||
/.pnp | ||
.pnp.js | ||
/.vscode | ||
|
||
# testing | ||
/coverage | ||
|
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,14 @@ | ||
import React from 'react'; | ||
import './addField.css'; | ||
|
||
function AddField(props) { | ||
const { label, onClick, icon, disabled } = props; | ||
return ( | ||
<div type="text" size="large" onClick={onClick} {...props} className={`add-field-wrapper`}> | ||
<span className={`add-field-icon ${disabled ? 'disabled' : 'enabled'}`}>{icon}</span> | ||
<span className={`add-field-label ${disabled ? 'disabled' : 'enabled'}`}> {label}</span> | ||
</div> | ||
); | ||
} | ||
|
||
export default AddField; |
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,39 @@ | ||
.add-field-wrapper { | ||
display: flex; | ||
gap: 8px; | ||
} | ||
|
||
.add-field-wrapper .disabled { | ||
background-color: #f7f7f7; | ||
color: #646d7b; | ||
cursor: not-allowed; | ||
} | ||
|
||
.add-field-wrapper .enabled { | ||
background: #eff2ff; | ||
color: #1b3de6; | ||
cursor: pointer; | ||
} | ||
|
||
.add-field-wrapper .add-field-icon { | ||
border-radius: 4px; | ||
border: 0px; | ||
height: 20px; | ||
width: 20px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.add-field-wrapper .add-field-label { | ||
font-family: 'Roboto'; | ||
font-style: normal; | ||
font-weight: 400; | ||
font-size: 16px; | ||
max-width: 170px; | ||
height: auto; | ||
text-align: left; | ||
white-space: pre-line; | ||
display: contents; | ||
word-break: break-word; | ||
} |
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 @@ | ||
export { default } from './AddField'; |
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,113 @@ | ||
import React, { useState } from 'react'; | ||
import './mandatoryField.css'; | ||
import { Card, Col, Divider, Row } from 'antd'; | ||
import { PlusOutlined, MinusOutlined } from '@ant-design/icons'; | ||
import { bilingual } from '../../../utils/bilingual'; | ||
import { useSelector } from 'react-redux'; | ||
import { getUserDetails } from '../../../redux/reducer/userSlice'; | ||
import AddField from '../../Button/AddField'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
function MandatoryField(props) { | ||
const { field, formName, formLabel } = props; | ||
let { updatedFormFields } = props; | ||
const { user } = useSelector(getUserDetails); | ||
const { t } = useTranslation(); | ||
|
||
const [addedFields, setAddedFields] = useState(field?.filter((f) => f?.isRequiredField || f?.preFilled)); | ||
const [availableFields, setAvailableFields] = useState( | ||
field?.filter((f) => !f?.isRequiredField && !f?.preFilled && !f?.isAdminOnlyField), | ||
); | ||
|
||
const removeFromFields = (index) => { | ||
let removedField = addedFields[index]; | ||
removedField = { | ||
...removedField, | ||
isRequiredField: false, | ||
}; | ||
if (!removedField?.preFilled) { | ||
let updatedFields = addedFields.filter((field, i) => i !== index); | ||
updatedFormFields = updatedFormFields?.map((f) => { | ||
if (f.formName === formName) { | ||
f.formFields = updatedFields?.concat([...availableFields, removedField]); | ||
} | ||
return f; | ||
}); | ||
|
||
setAddedFields(updatedFields); | ||
setAvailableFields([...availableFields, removedField]); | ||
} | ||
}; | ||
|
||
const addToFields = (field) => { | ||
let updatedFields = availableFields.filter((f) => f?.mappedField !== field?.mappedField); | ||
updatedFields = updatedFields?.map((f) => { | ||
return { | ||
...f, | ||
isRequiredField: false, | ||
}; | ||
}); | ||
updatedFormFields = updatedFormFields?.map((f) => { | ||
if (f.formName === formName) { | ||
f.formFields = updatedFields?.concat([...addedFields, { ...field, isRequiredField: true }]); | ||
} | ||
return f; | ||
}); | ||
setAddedFields([...addedFields, { ...field, isRequiredField: true }]); | ||
setAvailableFields(updatedFields); | ||
}; | ||
|
||
return ( | ||
<Card className="mandatory-card-wrapper" bodyStyle={{ padding: '24px 16px 24px 16px' }}> | ||
<Row gutter={[0, 18]}> | ||
<Col span={24}> | ||
<h5 className="mandatory-field-class-heading">{formLabel}</h5> | ||
</Col> | ||
<Col span={11}> | ||
<h5 className="mandatory-field-required">{t('dashboard.settings.mandatoryFields.title')}</h5> | ||
{addedFields.map((field, index) => ( | ||
<Row key={index}> | ||
<Col span={24}> | ||
<AddField | ||
key={index} | ||
label={bilingual({ | ||
en: field?.label?.en, | ||
fr: field?.label?.fr, | ||
interfaceLanguage: user?.interfaceLanguage?.toLowerCase(), | ||
})} | ||
disabled={field?.preFilled} | ||
onClick={() => removeFromFields(index)} | ||
icon={<MinusOutlined />} | ||
/> | ||
</Col> | ||
</Row> | ||
))} | ||
</Col> | ||
<Col> | ||
<Divider type="vertical" style={{ height: '100%', border: '1px solid #B6C1C9' }} /> | ||
</Col> | ||
<Col span={11} push={1}> | ||
<h5 className="mandatory-field-available">{t('dashboard.settings.mandatoryFields.availableFields')}</h5> | ||
{availableFields.map((field, index) => ( | ||
<Row key={index}> | ||
<Col span={24}> | ||
<AddField | ||
key={index} | ||
label={bilingual({ | ||
en: field?.label?.en, | ||
fr: field?.label?.fr, | ||
interfaceLanguage: user?.interfaceLanguage?.toLowerCase(), | ||
})} | ||
onClick={() => addToFields(field)} | ||
icon={<PlusOutlined />} | ||
/> | ||
</Col> | ||
</Row> | ||
))} | ||
</Col> | ||
</Row> | ||
</Card> | ||
); | ||
} | ||
|
||
export default MandatoryField; |
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 @@ | ||
export { default } from './MandatoryFields.jsx'; |
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,15 @@ | ||
.mandatory-card-wrapper { | ||
border: 1px solid #b6c1c9; | ||
border-radius: 8px; | ||
} | ||
|
||
.mandatory-card-wrapper .mandatory-field-class-heading { | ||
font-size: 20px; | ||
font-weight: 700; | ||
} | ||
|
||
.mandatory-card-wrapper .mandatory-field-available, | ||
.mandatory-card-wrapper .mandatory-field-required { | ||
font-size: 12px; | ||
font-weight: 700; | ||
} |
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
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
Oops, something went wrong.