fix: reduce share errors
This commit is contained in:
@@ -19,9 +19,14 @@ interface OverviewShareProps {
|
|||||||
export function OverviewShare({ projectId }: OverviewShareProps) {
|
export function OverviewShare({ projectId }: OverviewShareProps) {
|
||||||
const trpc = useTRPC();
|
const trpc = useTRPC();
|
||||||
const query = useQuery(
|
const query = useQuery(
|
||||||
trpc.share.overview.queryOptions({
|
trpc.share.overview.queryOptions(
|
||||||
|
{
|
||||||
projectId,
|
projectId,
|
||||||
}),
|
},
|
||||||
|
{
|
||||||
|
retry: 0,
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
const data = query.data;
|
const data = query.data;
|
||||||
const mutation = useMutation(
|
const mutation = useMutation(
|
||||||
|
|||||||
@@ -48,9 +48,14 @@ export const shareRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!share) {
|
if (!share) {
|
||||||
|
// Throw error if shareId is provided, otherwise return null
|
||||||
|
if ('shareId' in input) {
|
||||||
throw TRPCNotFoundError('Share not found');
|
throw TRPCNotFoundError('Share not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...share,
|
...share,
|
||||||
hasAccess: !!ctx.cookies[`shared-overview-${share?.id}`],
|
hasAccess: !!ctx.cookies[`shared-overview-${share?.id}`],
|
||||||
|
|||||||
Reference in New Issue
Block a user