fix(bug): default role implemented#1524
Conversation
|
@adityadeshlahre is attempting to deploy a commit to the formbricks Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for following the naming conventions for pull request titles! 🙏 |
|
The code looks good overall, but I have a suggestion regarding the default role assignment. Currently, you are assigning the Instead, consider assigning a less privileged role as the default, or better yet, make the role selection mandatory and show an error if no role is selected. Here's how you can make the role selection mandatory: const { register, getValues, handleSubmit, reset, control, formState: { errors } } = useForm<{
name: string;
email: string;
role: MembershipRole;
}>();
// ...
<Controller
name="role"
control={control}
rules={{ required: true }}
render={({ field: { onChange, value } }) => (
<div>
<Label>Role</Label>
<Select value={value} onValueChange={(v) => onChange(v as MembershipRole)}>
<SelectTrigger className="capitalize">
<SelectValue placeholder={<span className="text-slate-400">Select role</span>} />
</SelectTrigger>
<SelectContent>
<SelectGroup>
{Object.values(MembershipRole).map((role) => (
<SelectItem className="capitalize" key={role} value={role}>
{role}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
{errors.role && <span className="text-red-500">Role is required</span>}
</div>
)}
/>This way, the form will not be submitted until a role is selected, and an error message will be displayed if the role is not selected. |
mattinannt
left a comment
There was a problem hiding this comment.
@adityadeshlahre thanks a lot for the fix :-)
* main: (28 commits) chore: Add Table of Contents to README (formbricks#1427) fix: account deletion failing issue (formbricks#1509) fix: remove welcome card from email preview (formbricks#1495) fix(bug): default role implemented (formbricks#1524) fix: changing description of Code Action (formbricks#1522) refactor: Migrate activity service (formbricks#1471) fix: Error in Docs navigation formbricks#1518 (formbricks#1521) feat: dynamic title and description (formbricks#1459) fix: Spelling Errors (formbricks#1517) fix: added scrollbar whenever overflowed in the settings/profile page (formbricks#1498) fix: long url not getting reset after closing modal (formbricks#1502) fix: Unexpected Behavior when Toggling Italics in Text Editor and improve clarity of formatting status (formbricks#1506) fix: zod pin validation failing (formbricks#1507) fix: Error message on Login not shown (formbricks#1508) fix: downgrade nextjs to fix error with react email (formbricks#1516) chore: downgrade next version in formbricks-com (formbricks#1513) feat: picture selection question (formbricks#1388) feat: formtribe leaderboard update as per today (formbricks#1505) fix: Added if statement for preventing use of reserved word in question ID (formbricks#1435) fix: Disabling Welcome Card leads buggy preview (formbricks#1320) ...
What does this PR do?
set default role to admin of new invited member. If user doesn't select any role!
Fixes #1523

Type of change
How should this be tested?
Checklist
Required
pnpm buildconsole.logsgit pull origin mainAppreciated