reformat with prettier with semicolons and tabs

This commit is contained in:
m5r
2021-07-31 23:57:43 +08:00
parent fc4278ca7b
commit 079241ddb0
80 changed files with 1187 additions and 1270 deletions

View File

@ -1,3 +1,3 @@
import type { NextApiRequest, NextApiResponse } from "next"
import type { NextApiRequest, NextApiResponse } from "next";
export default async function incomingCallHandler(req: NextApiRequest, res: NextApiResponse) {}

View File

@ -1,3 +1,3 @@
import type { NextApiRequest, NextApiResponse } from "next"
import type { NextApiRequest, NextApiResponse } from "next";
export default async function outgoingCallHandler(req: NextApiRequest, res: NextApiResponse) {}

View File

@ -1,24 +1,24 @@
import { Direction } from "../../../db"
import usePhoneCalls from "../hooks/use-phone-calls"
import { Direction } from "../../../db";
import usePhoneCalls from "../hooks/use-phone-calls";
export default function PhoneCallsList() {
const phoneCalls = usePhoneCalls()
const phoneCalls = usePhoneCalls();
if (phoneCalls.length === 0) {
return <div>empty state</div>
return <div>empty state</div>;
}
return (
<ul className="divide-y">
{phoneCalls.map((phoneCall) => {
const recipient = Direction.Outbound ? phoneCall.to : phoneCall.from
const recipient = Direction.Outbound ? phoneCall.to : phoneCall.from;
return (
<li key={phoneCall.twilioSid} className="flex flex-row justify-between py-2">
<div>{recipient}</div>
<div>{new Date(phoneCall.createdAt).toLocaleString("fr-FR")}</div>
</li>
)
);
})}
</ul>
)
);
}

View File

@ -1,15 +1,15 @@
import { useQuery } from "blitz"
import { useQuery } from "blitz";
import useCurrentCustomer from "../../core/hooks/use-current-customer"
import getPhoneCalls from "../queries/get-phone-calls"
import useCurrentCustomer from "../../core/hooks/use-current-customer";
import getPhoneCalls from "../queries/get-phone-calls";
export default function usePhoneCalls() {
const { customer } = useCurrentCustomer()
const { customer } = useCurrentCustomer();
if (!customer) {
throw new Error("customer not found")
throw new Error("customer not found");
}
const { phoneCalls } = useQuery(getPhoneCalls, { customerId: customer.id })[0]
const { phoneCalls } = useQuery(getPhoneCalls, { customerId: customer.id })[0];
return phoneCalls
return phoneCalls;
}

View File

@ -1,25 +1,25 @@
import { Suspense } from "react"
import type { BlitzPage } from "blitz"
import { Suspense } from "react";
import type { BlitzPage } from "blitz";
import Layout from "../../core/layouts/layout"
import PhoneCallsList from "../components/phone-calls-list"
import useRequireOnboarding from "../../core/hooks/use-require-onboarding"
import Layout from "../../core/layouts/layout";
import PhoneCallsList from "../components/phone-calls-list";
import useRequireOnboarding from "../../core/hooks/use-require-onboarding";
const PhoneCalls: BlitzPage = () => {
useRequireOnboarding()
useRequireOnboarding();
return (
<Layout title="Calls">
<div className="flex flex-col space-y-6 p-6">
<p>PhoneCalls page</p>
<p>Calls page</p>
</div>
<Suspense fallback="Loading...">
<PhoneCallsList />
</Suspense>
</Layout>
)
}
);
};
PhoneCalls.authenticate = true
PhoneCalls.authenticate = true;
export default PhoneCalls
export default PhoneCalls;

View File

@ -1,9 +1,9 @@
import { paginate, resolver } from "blitz"
import db, { Prisma, Customer } from "db"
import { paginate, resolver } from "blitz";
import db, { Prisma, Customer } from "db";
interface GetPhoneCallsInput
extends Pick<Prisma.PhoneCallFindManyArgs, "where" | "orderBy" | "skip" | "take"> {
customerId: Customer["id"]
customerId: Customer["id"];
}
export default resolver.pipe(
@ -20,13 +20,13 @@ export default resolver.pipe(
take,
count: () => db.phoneCall.count({ where }),
query: (paginateArgs) => db.phoneCall.findMany({ ...paginateArgs, where, orderBy }),
})
});
return {
phoneCalls,
nextPage,
hasMore,
count,
}
};
}
)
);