fix: add a `returnTo` query param in new team url path (#5967)
* fix: remove optional from schema. * schema success state is always true because of the optional property. so we are getting undefined if returnTo query Param doesn't exist * fix: add a return to query param * nit: turn querySchema into an object Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Bailey Pumfleet <bailey@pumfleet.co.uk>pull/6061/head^2
parent
78da7ba338
commit
6be0fd52e7
|
@ -14,7 +14,7 @@ function Teams() {
|
||||||
heading={t("teams")}
|
heading={t("teams")}
|
||||||
subtitle={t("create_manage_teams_collaborative")}
|
subtitle={t("create_manage_teams_collaborative")}
|
||||||
CTA={
|
CTA={
|
||||||
<Button type="button" href={`${WEBAPP_URL}/settings/teams/new`}>
|
<Button type="button" href={`${WEBAPP_URL}/settings/teams/new?returnTo=/teams`}>
|
||||||
<Icon.FiPlus className="inline-block h-3.5 w-3.5 text-white group-hover:text-black ltr:mr-2 rtl:ml-2" />
|
<Icon.FiPlus className="inline-block h-3.5 w-3.5 text-white group-hover:text-black ltr:mr-2 rtl:ml-2" />
|
||||||
{t("new")}
|
{t("new")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -9,17 +9,17 @@ import { Avatar, Button, Form, Icon, ImageUploader, TextField } from "@calcom/ui
|
||||||
|
|
||||||
import { NewTeamFormValues } from "../lib/types";
|
import { NewTeamFormValues } from "../lib/types";
|
||||||
|
|
||||||
const querySchema = z.optional(z.string());
|
const querySchema = z.object({
|
||||||
|
returnTo: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
export const CreateANewTeamForm = () => {
|
export const CreateANewTeamForm = () => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const {
|
|
||||||
query: { returnTo },
|
|
||||||
} = router;
|
|
||||||
const returnToParsed = querySchema.safeParse(returnTo);
|
|
||||||
|
|
||||||
const returnToParam = returnToParsed.success ? returnToParsed.data : "/settings/teams";
|
const returnToParsed = querySchema.safeParse(router.query);
|
||||||
|
|
||||||
|
const returnToParam = returnToParsed.success ? returnToParsed.data.returnTo : "/settings/teams";
|
||||||
|
|
||||||
const newTeamFormMethods = useForm<NewTeamFormValues>();
|
const newTeamFormMethods = useForm<NewTeamFormValues>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue