forked from github/plane
3c2f5d12ed
* chore: add next theme and initial setup * chore: add dark mode colors to layouts * chore: user general setting page theming * chore: dashboard theming * chore: project page theming * chore: workspace setting page theming * chore: my issue page theming * chore: cmdk theming * chore: change hardcode bg and text color to theme * chore: change color name according to the design * style: fix card in the dashboard * style: fix merge conflict design issues * style: add light high contrast and dark high contrast * style: fix cmd k menu color and selection * feat: change theme from cmdk menu * chore: add multiple theme field to custom theme * chore: removed custom theming * fix: build error --------- Co-authored-by: Saheb Giri <iamsahebgiri@gmail.com>
87 lines
2.5 KiB
TypeScript
87 lines
2.5 KiB
TypeScript
// types
|
|
import { useForm } from "react-hook-form";
|
|
import useToast from "hooks/use-toast";
|
|
import workspaceService from "services/workspace.service";
|
|
import { IUser } from "types";
|
|
// ui components
|
|
import { MultiInput, PrimaryButton, SecondaryButton } from "components/ui";
|
|
|
|
type Props = {
|
|
setStep: React.Dispatch<React.SetStateAction<number>>;
|
|
workspace: any;
|
|
};
|
|
|
|
export const InviteMembers: React.FC<Props> = ({ setStep, workspace }) => {
|
|
const { setToastAlert } = useToast();
|
|
|
|
const {
|
|
setValue,
|
|
watch,
|
|
handleSubmit,
|
|
formState: { isSubmitting },
|
|
} = useForm<IUser>();
|
|
|
|
const onSubmit = async (formData: IUser) => {
|
|
await workspaceService
|
|
.inviteWorkspace(workspace.slug, formData)
|
|
.then(() => {
|
|
setToastAlert({
|
|
type: "success",
|
|
title: "Invitations sent!",
|
|
});
|
|
setStep(4);
|
|
})
|
|
.catch((err) => console.log(err));
|
|
};
|
|
|
|
const checkEmail = watch("emails") && watch("emails").length > 0 ;
|
|
return (
|
|
<form
|
|
className="flex w-full items-center justify-center"
|
|
onSubmit={handleSubmit(onSubmit)}
|
|
onKeyDown={(e) => {
|
|
if (e.code === "Enter") e.preventDefault();
|
|
}}
|
|
>
|
|
<div className="flex w-full max-w-xl flex-col gap-12">
|
|
<div className="flex flex-col gap-6 rounded-[10px] bg-brand-surface-2 px-10 py-7 shadow-md">
|
|
<h2 className="text-2xl font-medium ">Invite co-workers to your team</h2>
|
|
<div className="flex flex-col items-start justify-center gap-2.5 ">
|
|
<span>Email</span>
|
|
<div className="w-full">
|
|
<MultiInput
|
|
name="emails"
|
|
placeholder="Enter co-workers Email IDs"
|
|
watch={watch}
|
|
setValue={setValue}
|
|
className="w-full"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex w-full flex-col items-center justify-center gap-3 ">
|
|
<PrimaryButton
|
|
type="submit"
|
|
className="flex w-1/2 items-center justify-center text-center"
|
|
disabled={isSubmitting || !checkEmail}
|
|
size="md"
|
|
>
|
|
{isSubmitting ? "Inviting..." : "Continue"}
|
|
</PrimaryButton>
|
|
|
|
<SecondaryButton
|
|
type="button"
|
|
className="w-1/2 rounded-lg bg-transparent border-none"
|
|
size="md"
|
|
outline
|
|
onClick={() => setStep(4)}
|
|
>
|
|
Skip
|
|
</SecondaryButton>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
);
|
|
};
|