fix: set up organization field validation (#10154)

Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
pull/9822/head^2
Nafees Nazik 2023-07-21 14:18:43 +05:30 committed by GitHub
parent c7a276eb1d
commit 797d3a7f98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -223,8 +223,11 @@ export const CreateANewOrganizationForm = ({ slug }: { slug?: string }) => {
defaultValue={value}
onChange={(e) => {
const domain = extractDomainFromEmail(e?.target.value);
newOrganizationFormMethods.setValue("adminEmail", e?.target.value);
newOrganizationFormMethods.setValue("adminUsername", e?.target.value.split("@")[0]);
newOrganizationFormMethods.setValue("adminEmail", e?.target.value.trim());
newOrganizationFormMethods.setValue(
"adminUsername",
e?.target.value.split("@")[0].trim()
);
if (newOrganizationFormMethods.getValues("slug") === "") {
newOrganizationFormMethods.setValue("slug", domain);
}
@ -256,7 +259,7 @@ export const CreateANewOrganizationForm = ({ slug }: { slug?: string }) => {
label={t("organization_name")}
defaultValue={value}
onChange={(e) => {
newOrganizationFormMethods.setValue("name", e?.target.value);
newOrganizationFormMethods.setValue("name", e?.target.value.trim());
if (newOrganizationFormMethods.formState.touchedFields["slug"] === undefined) {
newOrganizationFormMethods.setValue("slug", slugify(e?.target.value));
}