From faadf88d110321a9ec5e21f24fa4d2da46e210a5 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 7 Sep 2023 09:59:16 -0400 Subject: [PATCH] feat: additional prefix support --- package.json | 2 +- src/components/forms/OrgCreateFormModal.js | 29 ++++++++++++++++++ src/components/forms/OrgEditFormModal.js | 30 ++++++++++++++++++- src/pages/Organization/index.js | 18 +++++++++++ src/store/actions/climateWarehouseActions.js | 2 ++ .../validations/organization.validation.js | 1 + src/translations/tokens/en-US.json | 2 ++ 7 files changed, 82 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 464205b4..7f6c97d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "core-registry-cadt-ui", - "version": "1.2.7", + "version": "1.2.8", "private": true, "author": "Chia Network Inc. ", "homepage": "./", diff --git a/src/components/forms/OrgCreateFormModal.js b/src/components/forms/OrgCreateFormModal.js index 7bad9f62..9c780d11 100644 --- a/src/components/forms/OrgCreateFormModal.js +++ b/src/components/forms/OrgCreateFormModal.js @@ -40,11 +40,13 @@ const OrgCreateFormModal = ({ onClose }) => { const [formData, setFormData] = useState({ name: '', png: null, + prefix: '', }); const [importedOrgUid, setImportedOrgUid] = useState(''); const [tabValue, setTabValue] = useState(0); const nameIsValid = formData?.name?.length > 0; + const prefixIsValid = formData?.prefix?.length > 0; const isOrgUidValid = importedOrgUid?.length > 4; const handleTabChange = (event, newValue) => { @@ -113,6 +115,33 @@ const OrgCreateFormModal = ({ onClose }) => { )} + + + + * + + + + + setFormData(prevState => ({ + ...prevState, + prefix: value, + })) + } + /> + + {!prefixIsValid && ( + + {intl.formatMessage({ + id: 'add-valid-organization-prefix', + })} + + )} + diff --git a/src/components/forms/OrgEditFormModal.js b/src/components/forms/OrgEditFormModal.js index f037bc0c..6b77d661 100644 --- a/src/components/forms/OrgEditFormModal.js +++ b/src/components/forms/OrgEditFormModal.js @@ -17,12 +17,13 @@ import { } from '..'; import { editExistingOrg } from '../../store/actions/climateWarehouseActions'; -const OrgEditFormModal = ({ onClose, name, icon }) => { +const OrgEditFormModal = ({ onClose, name, prefix, icon }) => { const intl = useIntl(); const dispatch = useDispatch(); const { notification } = useSelector(state => state.app); const [formData, setFormData] = useState({ name, + prefix, png: icon, }); @@ -81,6 +82,33 @@ const OrgEditFormModal = ({ onClose, name, icon }) => { )} + + + + * + + + + + setFormData(prevState => ({ + ...prevState, + prefix: value, + })) + } + /> + + {!nameIsValid && ( + + {intl.formatMessage({ + id: 'add-valid-organization-prefix', + })} + + )} + diff --git a/src/pages/Organization/index.js b/src/pages/Organization/index.js index d84b5e28..475d43fb 100644 --- a/src/pages/Organization/index.js +++ b/src/pages/Organization/index.js @@ -97,6 +97,23 @@ const Organization = () => { + + + + + + {myOrganization.prefix} + + { + navigator.clipboard.writeText(myOrganization.prefix); + }} + /> + + + @@ -207,6 +224,7 @@ const Organization = () => { onClose={() => setIsEditModalOpen(false)} name={myOrganization?.name} icon={myOrganization?.icon} + prefix={myOrganization?.prefix} /> )} {isDeleteModalOpen && ( diff --git a/src/store/actions/climateWarehouseActions.js b/src/store/actions/climateWarehouseActions.js index 4dd0ca17..b776c306 100644 --- a/src/store/actions/climateWarehouseActions.js +++ b/src/store/actions/climateWarehouseActions.js @@ -1847,6 +1847,7 @@ export const postNewOrg = data => { const formData = new FormData(); formData.append('file', data.png); formData.append('name', data.name); + formData.append('prefix', data.prefix); const url = `${constants.API_HOST}/organizations/create`; const payload = { @@ -1896,6 +1897,7 @@ export const editExistingOrg = data => { const formData = new FormData(); formData.append('file', data.png); formData.append('name', data.name); + formData.append('prefix', data.prefix); const url = `${constants.API_HOST}/organizations/edit`; const payload = { diff --git a/src/store/validations/organization.validation.js b/src/store/validations/organization.validation.js index 93a1b053..d2a542b1 100644 --- a/src/store/validations/organization.validation.js +++ b/src/store/validations/organization.validation.js @@ -3,6 +3,7 @@ import { validateUrl } from '../../utils/urlUtils'; export const organizationSchema = yup.object().shape({ name: yup.string().required('Required Field'), + prefix: yup.string().optional(), icon: yup .string() .test({ diff --git a/src/translations/tokens/en-US.json b/src/translations/tokens/en-US.json index e3beb234..f7f33e42 100644 --- a/src/translations/tokens/en-US.json +++ b/src/translations/tokens/en-US.json @@ -293,6 +293,7 @@ "create-organization": "Create Organization", "you-need-to-create-organization": "You need to create your Organization to have full access to the Registry.", "organization-name": "Organization Name", + "organization-prefix": "Organization Prefix", "organization-icon": "Organization Icon", "organization-website": "Organization Website", "organization-created": "Your organization was successfully added.", @@ -327,6 +328,7 @@ "add-valid-server-address": "Add a valid server address", "add-valid-api-key": "Add a valid Api key", "add-valid-organization-name": "Add a valid organization name", + "add-valid-organization-prefix": "Add a valid organization prefix", "project-one": "Project 1", "project-two": "Project 2", "first-project": "First Project",