mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-22 19:55:37 +02:00
Fix #860
This commit is contained in:
parent
57315a36ee
commit
c409266954
1 changed files with 13 additions and 7 deletions
|
@ -82,7 +82,14 @@ export default function StepperForm() {
|
||||||
);
|
);
|
||||||
|
|
||||||
const generateId = (name: string) => {
|
const generateId = (name: string) => {
|
||||||
return name.toLowerCase().replace(/\s+/g, "-");
|
// Replace any character that is not a letter, number, space, or hyphen with a hyphen
|
||||||
|
// Also collapse multiple hyphens and trim
|
||||||
|
return name
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/[^a-z0-9\s-]/g, "-")
|
||||||
|
.replace(/\s+/g, "-")
|
||||||
|
.replace(/-+/g, "-")
|
||||||
|
.replace(/^-+|-+$/g, "");
|
||||||
};
|
};
|
||||||
|
|
||||||
async function orgSubmit(values: z.infer<typeof orgSchema>) {
|
async function orgSubmit(values: z.infer<typeof orgSchema>) {
|
||||||
|
@ -207,23 +214,22 @@ export default function StepperForm() {
|
||||||
type="text"
|
type="text"
|
||||||
{...field}
|
{...field}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const orgId =
|
// Prevent "/" in orgName input
|
||||||
generateId(
|
const sanitizedValue = e.target.value.replace(/\//g, "-");
|
||||||
e.target
|
const orgId = generateId(sanitizedValue);
|
||||||
.value
|
|
||||||
);
|
|
||||||
orgForm.setValue(
|
orgForm.setValue(
|
||||||
"orgId",
|
"orgId",
|
||||||
orgId
|
orgId
|
||||||
);
|
);
|
||||||
orgForm.setValue(
|
orgForm.setValue(
|
||||||
"orgName",
|
"orgName",
|
||||||
e.target.value
|
sanitizedValue
|
||||||
);
|
);
|
||||||
debouncedCheckOrgIdAvailability(
|
debouncedCheckOrgIdAvailability(
|
||||||
orgId
|
orgId
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
value={field.value.replace(/\//g, "-")}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue