fix: project identifier cursor behaviour in create project modal. (#3320)

This commit is contained in:
Prateek Shourya 2024-01-05 14:38:09 +05:30 committed by sriram veeraghanta
parent 9eb8f41008
commit 266f14d550

View File

@ -126,6 +126,8 @@ export const CreateProjectModal: FC<Props> = observer((props) => {
else payload.emoji = formData.emoji_and_icon; else payload.emoji = formData.emoji_and_icon;
payload.project_lead = formData.project_lead_member; payload.project_lead = formData.project_lead_member;
// Upper case identifier
payload.identifier = payload.identifier.toUpperCase();
return createProject(workspaceSlug.toString(), payload) return createProject(workspaceSlug.toString(), payload)
.then((res) => { .then((res) => {
@ -176,14 +178,7 @@ export const CreateProjectModal: FC<Props> = observer((props) => {
return; return;
} }
if (e.target.value === "") setValue("identifier", ""); if (e.target.value === "") setValue("identifier", "");
else else setValue("identifier", e.target.value.replace(/[^ÇŞĞIİÖÜA-Za-z0-9]/g, "").substring(0, 5));
setValue(
"identifier",
e.target.value
.replace(/[^ÇŞĞIİÖÜA-Za-z0-9]/g, "")
.toUpperCase()
.substring(0, 5)
);
onChange(e); onChange(e);
}; };
@ -191,7 +186,7 @@ export const CreateProjectModal: FC<Props> = observer((props) => {
const { value } = e.target; const { value } = e.target;
const alphanumericValue = value.replace(/[^ÇŞĞIİÖÜA-Za-z0-9]/g, ""); const alphanumericValue = value.replace(/[^ÇŞĞIİÖÜA-Za-z0-9]/g, "");
setIsChangeInIdentifierRequired(false); setIsChangeInIdentifierRequired(false);
onChange(alphanumericValue.toUpperCase()); onChange(alphanumericValue);
}; };
return ( return (
@ -301,7 +296,8 @@ export const CreateProjectModal: FC<Props> = observer((props) => {
required: "Identifier is required", required: "Identifier is required",
// allow only alphanumeric & non-latin characters // allow only alphanumeric & non-latin characters
validate: (value) => validate: (value) =>
/^[ÇŞĞIİÖÜA-Z0-9]+$/.test(value.toUpperCase()) || "Identifier must be in uppercase.", /^[ÇŞĞIİÖÜA-Z0-9]+$/.test(value.toUpperCase()) ||
"Only Alphanumeric & Non-latin characters are allowed.",
minLength: { minLength: {
value: 1, value: 1,
message: "Identifier must at least be of 1 character", message: "Identifier must at least be of 1 character",
@ -321,7 +317,7 @@ export const CreateProjectModal: FC<Props> = observer((props) => {
onChange={handleIdentifierChange(onChange)} onChange={handleIdentifierChange(onChange)}
hasError={Boolean(errors.identifier)} hasError={Boolean(errors.identifier)}
placeholder="Identifier" placeholder="Identifier"
className="w-full text-xs focus:border-blue-400" className="w-full text-xs focus:border-blue-400 uppercase"
/> />
)} )}
/> />