Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export const Client: React.FC<Props> = ({ permission }) => {
toast.success("Permission updated");
router.refresh();
},
onError(err) {
toast.error(err.message);
},
});

async function onSubmit(values: z.infer<typeof formSchema>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export const DeletePermission: React.FC<Props> = ({ trigger, permission }) => {
revalidate("/authorization/permissions");
router.push("/authorization/permissions");
},
onError(err) {
toast.error(err.message);
},
});

async function onSubmit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export const CreateNewPermission: React.FC<Props> = ({ trigger }) => {
});
setOpen(false);
},
onError(err) {
toast.error(err.message);
},
});

async function onSubmit(values: z.infer<typeof formSchema>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export const DeleteRole: React.FC<Props> = ({ trigger, role }) => {
toast.success("Role deleted successfully");
router.push("/authorization/roles");
},
onError(err) {
toast.error(err.message);
},
});

async function onSubmit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export const UpdateRole: React.FC<Props> = ({ trigger, role }) => {
router.refresh();
setOpen(false);
},
onError(err) {
toast.error(err.message);
},
});

async function onSubmit(values: z.infer<typeof formSchema>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export const UpdateCard: React.FC<Props> = ({ overrideId, defaultValues }) => {
});
router.refresh();
},
onError(err) {
toast.error(err.message);
},
});

const deleteOverride = trpc.ratelimit.override.delete.useMutation({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const CreateNewOverride: React.FC<Props> = ({ namespaceId }) => {
});
router.refresh();
},
onError(err) {
toast.error(err.message);
},
});
async function onSubmit(values: z.infer<typeof formSchema>) {
create.mutate({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export const DeleteNamespace: React.FC<Props> = ({ namespace }) => {

router.push("/ratelimits");
},
onError(err) {
toast.error(err.message);
},
});

const isValid = form.watch("intent") === intent && form.watch("name") === namespace.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const UpdateNamespaceName: React.FC<Props> = ({ namespace }) => {
toast.success("Your namespace name has been renamed!");
router.refresh();
},
onError(err) {
toast.error(err.message);
},
});
async function onSubmit(values: z.infer<typeof formSchema>) {
if (values.name === namespace.name || !values.name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const CreateNamespaceButton = ({
router.refresh();
router.push(`/ratelimits/${res.id}`);
},
onError(err) {
toast.error(err.message);
},
});
async function onSubmit(values: z.infer<typeof formSchema>) {
create.mutate(values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const UpdateWorkspaceName: React.FC<Props> = ({ workspace }) => {
user?.reload();
router.refresh();
},
onError(err) {
toast.error(err.message);
},
});

async function onSubmit(values: z.infer<typeof formSchema>) {
Expand Down
3 changes: 3 additions & 0 deletions apps/dashboard/components/opt-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export const OptIn: React.FC<Props> = ({ title, description, feature }) => {
toast.success("Successfully opted in");
router.refresh();
},
onError(err) {
toast.error(err.message);
},
});
return (
<EmptyPlaceholder className="h-full">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ export const deleteNamespace = rateLimitedProcedure(ratelimit.delete)
userAgent: ctx.audit.userAgent,
},
})),
);
).catch((_err) => {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message:
"We are unable to delete the namespaces. Please contact support using support@unkey.dev",
});
});
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ export const updateNamespaceName = rateLimitedProcedure(ratelimit.update)
location: ctx.audit.location,
userAgent: ctx.audit.userAgent,
},
}).catch((_err) => {
throw new TRPCError({
message:
"We are unable to update the namespace name. Please contact support using support@unkey.dev",
code: "INTERNAL_SERVER_ERROR",
});
});
});
});
6 changes: 6 additions & 0 deletions apps/dashboard/lib/trpc/routers/ratelimit/updateOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ export const updateOverride = rateLimitedProcedure(ratelimit.update)
location: ctx.audit.location,
userAgent: ctx.audit.userAgent,
},
}).catch((_err) => {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message:
"We are unable to update the override. Please contact support using support@unkey.dev",
});
});
});
});
7 changes: 7 additions & 0 deletions apps/dashboard/lib/trpc/routers/rbac/deleteRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ export const deleteRole = rateLimitedProcedure(ratelimit.delete)
location: ctx.audit.location,
userAgent: ctx.audit.userAgent,
},
}).catch((err) => {
console.error(err);
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message:
"We are unable to delete the role. Please contact support using support@unkey.dev.",
});
});
});
});