fix: set up organization field validation (#10154)

Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
This commit is contained in:
Nafees Nazik
2023-07-21 08:48:43 +00:00
committed by GitHub
co-authored by Carina Wollendorfer
parent c7a276eb1d
commit 797d3a7f98
@@ -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));
}