Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6175a7f
feat: add data table hook
G3root Aug 28, 2024
9267b5a
feat: add new data table hook
G3root Aug 28, 2024
c8ae1ac
chore: rename hook
G3root Aug 28, 2024
a0106f4
feat: add paginated hook
G3root Aug 28, 2024
99ff880
feat: add offset schema
G3root Aug 28, 2024
07f2d55
feat: use offset schema
G3root Aug 28, 2024
5c8a3d3
fix: session
G3root Aug 28, 2024
1238f71
feat: add const
G3root Aug 28, 2024
612238a
chore: fix error handling
G3root Aug 28, 2024
733b70d
chore: make header optional
G3root Aug 28, 2024
36c9a72
feat: add api client
G3root Aug 28, 2024
bcede0d
chore: add nuqs
G3root Aug 28, 2024
399b222
feat: use pagination
G3root Aug 28, 2024
b207ff0
refactor: hook
G3root Aug 29, 2024
fd34967
feat: add sort
G3root Aug 29, 2024
e7e7449
feat: add sort
G3root Aug 29, 2024
85116f3
chore: hide select
G3root Aug 29, 2024
4ddcf2a
feat: add search filter
G3root Aug 29, 2024
9851bf3
feat: refactor data
G3root Aug 29, 2024
69a423e
feat: add debounce component
G3root Aug 29, 2024
2409c0d
feat: add debounce input
G3root Aug 29, 2024
3523911
feat: add search
G3root Aug 30, 2024
8810540
fix: query
G3root Aug 30, 2024
5acdd81
feat: update tables
G3root Aug 30, 2024
6c5d5f1
feat: add seed
G3root Aug 30, 2024
2fe228f
Merge branch 'main' into pagination-table
G3root Aug 30, 2024
92d651d
chore: add tax id
G3root Sep 2, 2024
e733531
chore: upgrade trpc
G3root Sep 2, 2024
fcf2db6
feat: use new trpc
G3root Sep 2, 2024
9ca66a6
feat: add error boundary
G3root Sep 2, 2024
233b004
chore: rename loading
G3root Sep 2, 2024
33ba09b
feat: use useSuspense
G3root Sep 2, 2024
b91f92d
fix: data
G3root Sep 2, 2024
c477f15
feat: add search param hook
G3root Sep 17, 2024
160cf3d
feat: add search
G3root Sep 17, 2024
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
Prev Previous commit
Next Next commit
feat: use new trpc
  • Loading branch information
G3root committed Sep 2, 2024
commit fcf2db64585b542c8fb537fe6c1682d5929b17f3
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const AuditsPage = async () => {
return <UnAuthorizedState />;
}

const audits = await api.audit.getAudits.query({});
const audits = await api.audit.getAudits({});
return (
<div className="flex flex-col gap-y-3">
<div className="flex items-center justify-between gap-y-3 ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const DataRoomSettinsPage = async ({
}: {
params: { publicId: string; dataRoomPublicId: string };
}) => {
const { dataRoom, documents } = await api.dataRoom.getDataRoom.query({
const { dataRoom, documents } = await api.dataRoom.getDataRoom({
dataRoomPublicId,
include: {
company: false,
recipients: true,
documents: true,
},
});
const contacts = await api.common.getContacts.query();
const contacts = await api.common.getContacts();

if (!dataRoom) {
return notFound();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ const EsignTemplateDetailPage = async ({
}) => {
const session = await withServerComponentSession();

const { name, status, url, fields, recipients } =
await api.template.get.query({
publicId: templatePublicId,
isDraftOnly: true,
});
const { name, status, url, fields, recipients } = await api.template.get({
publicId: templatePublicId,
isDraftOnly: true,
});

return (
<TemplateFieldProvider recipients={recipients} fields={fields}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const metadata: Metadata = {

const EsignDocumentPage = async () => {
const session = await withServerComponentSession();
const { documents } = await api.template.all.query();
const { documents } = await api.template.all();

if (documents.length === 0) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export default async function TemplateDetailViewPage({
const { allow } = await serverAccessControl();

const [{ name, status, url, fields }, auditsData] = await Promise.all([
api.template.get.query({
api.template.get({
publicId: templatePublicId,
isDraftOnly: false,
}),

allow(
api.audit.allEsignAudits.query({
api.audit.allEsignAudits({
templatePublicId: templatePublicId,
}),
["audits", "read"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ const DocumentsPage = async () => {
const { allow } = await serverAccessControl();
const session = await withServerComponentSession();

const documents = await allow(api.document.getAll.query(), [
"documents",
"read",
]);
const documents = await allow(api.document.getAll(), ["documents", "read"]);

const canUpload = allow(true, ["documents", "read"]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const metadata: Metadata = {
};

const DocumentsPage = async () => {
const documents = await api.document.getAll.query();
const documents = await api.document.getAll();
const session = await withServerComponentSession();

if (documents.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const metadata: Metadata = {
};

const SafePage = async () => {
const safes = await api.safe.getSafes.query();
const safes = await api.safe.getSafes();

if (!safes?.data?.length) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const metadata: Metadata = {
};

const OptionsPage = async () => {
const options = await api.securities.getOptions.query();
const stakeholders = await api.stakeholder.getStakeholders.query();
const equityPlans = await api.equityPlan.getPlans.query();
const options = await api.securities.getOptions();
const stakeholders = await api.stakeholder.getStakeholders();
const equityPlans = await api.equityPlan.getPlans();

if (options?.data?.length === 0) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const metadata: Metadata = {
};

const SharesPage = async () => {
const shares = await api.securities.getShares.query();
const stakeholders = await api.stakeholder.getStakeholders.query();
const shareClasses = await api.shareClass.get.query();
const shares = await api.securities.getShares();
const stakeholders = await api.stakeholder.getStakeholders();
const shareClasses = await api.shareClass.get();

if (shares?.data?.length === 0) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const metadata: Metadata = {
const ApiSettingsPage = async () => {
const { allow } = await serverAccessControl();

const data = await allow(api.bankAccounts.getAll.query(), [
const data = await allow(api.bankAccounts.getAll(), [
"bank-accounts",
"read",
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const metadata: Metadata = {
};
const BillingPage = async () => {
const [{ products }, { subscription }] = await Promise.all([
api.billing.getProducts.query(),
api.billing.getSubscription.query(),
api.billing.getProducts(),
api.billing.getSubscription(),
]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export const metadata: Metadata = {

const CompanySettingsPage = async () => {
const { allow } = await serverAccessControl();
const data = await allow(api.company.getCompany.query(), [
"company",
"update",
]);
const data = await allow(api.company.getCompany(), ["company", "update"]);

if (!data?.company) {
return <UnAuthorizedState />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const metadata: Metadata = {
title: "Developer settings",
};
const AccessTokenPage = async () => {
const data = await api.accessToken.listAll.query({
const data = await api.accessToken.listAll({
typeEnum: "api",
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ProfileSettings } from "@/components/member/member-profile";
import { api } from "@/trpc/server";
import { type Metadata } from "next";
import type { Metadata } from "next";

export const metadata: Metadata = {
title: "Profile",
};

const ProfileSettingsPage = async () => {
const memberProfile = await api.member.getProfile.query();
const memberProfile = await api.member.getProfile();

return <ProfileSettings memberProfile={memberProfile} />;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { api } from "@/trpc/server";
export default async function RolesPage() {
const { allow } = await serverAccessControl();

const data = await allow(api.rbac.listRoles.query(), ["roles", "read"]);
const data = await allow(api.rbac.listRoles(), ["roles", "read"]);

const canCreate = allow(true, ["roles", "create"]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const metadata: Metadata = {
title: "Security",
};
export default async function PasskeyPage() {
const passkeys = await api.passkey.find.query();
const passkeys = await api.passkey.find();
return (
<div className="flex flex-col gap-y-3">
<div className="flex items-center justify-between gap-y-3 ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const metadata: Metadata = {

const TeamMembersPage = async () => {
const [members, roles] = await Promise.all([
api.member.getMembers.query(),
api.rbac.listRoles.query(),
api.member.getMembers(),
api.rbac.listRoles(),
]);
return (
<div className="flex flex-col gap-y-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const StakeholdersPage = async () => {
const session = await withServerSession();

const { allow } = await serverAccessControl();
const stakeholders = await allow(api.stakeholder.getStakeholders.query(), [
const stakeholders = await allow(api.stakeholder.getStakeholders(), [
"stakeholder",
"read",
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const UpdatesPage = async ({
}: {
params: { publicId: string };
}) => {
const updates = await api.update.get.query();
const updates = await api.update.get();

if (updates.data.length === 0) {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/app/(documents)/esign/[token]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default async function SigningPage(props: SigningPageProps) {
templateId,
signableFields,
status: templateStatus,
} = await api.template.getSigningFields.query({
} = await api.template.getSigningFields({
token,
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/dashboard/overview/activities-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Props = {
};

const ActivityCard = async ({ className, publicId }: Props) => {
const activity = await api.audit.getAudits.query({ take: 4 });
const activity = await api.audit.getAudits({ take: 4 });

return (
<Card className={className}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/safe/steps/investor-details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { InvestorDetailsForm } from "./form";
export { type TFormSchema } from "./form";

export async function InvestorDetails() {
const stakeholders = await api.stakeholder.getStakeholders.query();
const stakeholders = await api.stakeholder.getStakeholders();
return <InvestorDetailsForm stakeholders={stakeholders} />;
}
4 changes: 2 additions & 2 deletions src/components/securities/shares/share-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { GeneralDetails } from "./steps/general-details";
import { RelevantDates } from "./steps/relevant-dates";

async function ContributionDetailsStep() {
const stakeholders = await api.stakeholder.getStakeholders.query();
const stakeholders = await api.stakeholder.getStakeholders();
return <ContributionDetails stakeholders={stakeholders} />;
}

async function GeneralDetailsStep() {
const shareClasses = await api.shareClass.get.query();
const shareClasses = await api.shareClass.get();
return <GeneralDetails shareClasses={shareClasses} />;
}

Expand Down
32 changes: 12 additions & 20 deletions src/trpc/api/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { getServerAuthSession } from "@/server/auth";
import { db } from "@/server/db";
import * as Sentry from "@sentry/nextjs";
import { cache } from "react";

interface Meta {
policies: addPolicyOption;
Expand All @@ -38,7 +39,7 @@ interface Meta {
*
* @see https://trpc.io/docs/server/context
*/
export const createTRPCContext = async (opts: { headers: Headers }) => {
export const createTRPCContext = cache(async (opts: { headers: Headers }) => {
const session = await getServerAuthSession();

return {
Expand All @@ -48,12 +49,11 @@ export const createTRPCContext = async (opts: { headers: Headers }) => {
userAgent: getUserAgent(opts.headers),
...opts,
};
};
});

export type CreateTRPCContextType = Awaited<
ReturnType<typeof createTRPCContext>
>;

const withAuthTrpcContext = ({ session, ...rest }: CreateTRPCContextType) => {
if (!session || !session.user) {
throw new TRPCError({ code: "UNAUTHORIZED" });
Expand Down Expand Up @@ -126,22 +126,12 @@ export type withAccessControlTrpcContextType = ReturnType<
* ZodErrors so that you get typesafety on the frontend if your procedure fails due to validation
* errors on the backend.
*/
const t = initTRPC
.context<typeof createTRPCContext>()
.meta<Meta>()
.create({
transformer: superjson,
errorFormatter({ shape, error }) {
return {
...shape,
data: {
...shape.data,
zodError:
error.cause instanceof ZodError ? error.cause.flatten() : null,
},
};
},
});
const t = initTRPC.context<CreateTRPCContextType>().meta<Meta>().create({
/**
* @see https://trpc.io/docs/server/data-transformers
*/
transformer: superjson,
});

/**
* 3. ROUTER & PROCEDURE (THE IMPORTANT BIT)
Expand All @@ -155,7 +145,6 @@ const t = initTRPC
*
* @see https://trpc.io/docs/router
*/
export const createTRPCRouter = t.router;

const sentryMiddleware = t.middleware(
Sentry.trpcMiddleware({
Expand Down Expand Up @@ -213,3 +202,6 @@ export const withAccessControl = t.procedure.use(
});
}),
);

export const createTRPCRouter = t.router;
export const createCallerFactory = t.createCallerFactory;
Loading