Skip to content

Commit

Permalink
feat: additional prefix support
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Sep 7, 2023
1 parent 41229b4 commit faadf88
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "core-registry-cadt-ui",
"version": "1.2.7",
"version": "1.2.8",
"private": true,
"author": "Chia Network Inc. <[email protected]>",
"homepage": "./",
Expand Down
29 changes: 29 additions & 0 deletions src/components/forms/OrgCreateFormModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -113,6 +115,33 @@ const OrgCreateFormModal = ({ onClose }) => {
</Body>
)}
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body>
*<FormattedMessage id="organization-prefix" />
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
size={InputSizeEnum.large}
variant={InputVariantEnum.default}
value={formData.prefix}
onChange={value =>
setFormData(prevState => ({
...prevState,
prefix: value,
}))
}
/>
</InputContainer>
{!prefixIsValid && (
<Body size="Small" color="red">
{intl.formatMessage({
id: 'add-valid-organization-prefix',
})}
</Body>
)}
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body>
Expand Down
30 changes: 29 additions & 1 deletion src/components/forms/OrgEditFormModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down Expand Up @@ -81,6 +82,33 @@ const OrgEditFormModal = ({ onClose, name, icon }) => {
</Body>
)}
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body>
*<FormattedMessage id="organization-prefix" />
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
size={InputSizeEnum.large}
variant={InputVariantEnum.default}
value={formData.prefix}
onChange={value =>
setFormData(prevState => ({
...prevState,
prefix: value,
}))
}
/>
</InputContainer>
{!nameIsValid && (
<Body size="Small" color="red">
{intl.formatMessage({
id: 'add-valid-organization-prefix',
})}
</Body>
)}
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body>
Expand Down
18 changes: 18 additions & 0 deletions src/pages/Organization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ const Organization = () => {
</StyledCopyIconContainer>
</Body>
</StyledItemContainer>
<StyledItemContainer>
<Body size="Big Bold">
<FormattedMessage id="organization-prefix" />
</Body>
<Body size="Big">
{myOrganization.prefix}
<StyledCopyIconContainer>
<CopyIcon
height={18}
width={18}
onClick={() => {
navigator.clipboard.writeText(myOrganization.prefix);
}}
/>
</StyledCopyIconContainer>
</Body>
</StyledItemContainer>
<StyledItemContainer>
<Body size="Big Bold">
<FormattedMessage id="org-uid" />
Expand Down Expand Up @@ -207,6 +224,7 @@ const Organization = () => {
onClose={() => setIsEditModalOpen(false)}
name={myOrganization?.name}
icon={myOrganization?.icon}
prefix={myOrganization?.prefix}
/>
)}
{isDeleteModalOpen && (
Expand Down
2 changes: 2 additions & 0 deletions src/store/actions/climateWarehouseActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions src/store/validations/organization.validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions src/translations/tokens/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit faadf88

Please sign in to comment.