Skip to content

Commit

Permalink
fix: Validate the collection name when creating it
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Jul 3, 2024
1 parent 3a4e383 commit d648c1d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const CreateLinkedWearablesCollectionModal: FC<Props> = (props: Props) =>
})),
[selectedThirdParty, imgSrcByNetwork]
)
const isCollectionNameInvalid = useMemo(() => collectionName.includes(':'), [collectionName])

const handleNameChange = useCallback(
(_: SyntheticEvent, data: InputOnChangeData) => {
Expand Down Expand Up @@ -129,6 +130,7 @@ export const CreateLinkedWearablesCollectionModal: FC<Props> = (props: Props) =>
const isSubmittable =
collectionName &&
ownerAddress &&
!isCollectionNameInvalid &&
((selectedThirdPartyVersion === ThirdPartyVersion.V2 && linkedContract) ||
(selectedThirdPartyVersion === ThirdPartyVersion.V1 && collectionId)) &&
!isCreatingCollection
Expand Down Expand Up @@ -170,6 +172,8 @@ export const CreateLinkedWearablesCollectionModal: FC<Props> = (props: Props) =>
value={collectionName}
maxLength={TP_COLLECTION_NAME_MAX_LENGTH}
onChange={handleNameChange}
error={isCollectionNameInvalid}
message={isCollectionNameInvalid ? t('create_linked_wearable_collection_modal.name_field.message') : ''}
disabled={isLoading}
/>
{selectedThirdPartyVersion === ThirdPartyVersion.V1 && (
Expand Down
3 changes: 2 additions & 1 deletion src/modules/translation/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@
"message": "No contracts available. Ask the DAO committee to to add one."
},
"name_field": {
"label": "Name"
"label": "Name",
"message": "The collection name can't contain the ':' character."
},
"collection_id_field": {
"label": "Id",
Expand Down
3 changes: 2 additions & 1 deletion src/modules/translation/languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@
"message": "No tienes contratos disponibles. Ponte en contacto con un DAO committee para agregar uno."
},
"name_field": {
"label": "Nombre"
"label": "Nombre",
"message": "El nombre de la colección no puede contener el caracter ':'."
},
"collection_id_field": {
"label": "Id",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/translation/languages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
},
"name_field": {
"label": "姓名",
"message": "名称最多可以是 {maxLength} 个字符"
"message": "集合名称不能包含“:”字符"
},
"urn_suffix_field": {
"label": "Id",
Expand Down

0 comments on commit d648c1d

Please sign in to comment.