make app usable without account, remove extra stuff

This commit is contained in:
m5r
2023-04-29 18:30:07 +02:00
parent cb35455722
commit 03ae466c66
128 changed files with 617 additions and 14061 deletions

View File

@ -2,9 +2,9 @@ import { type LoaderArgs, json } from "@remix-run/node";
import { type PhoneNumber, Prisma } from "@prisma/client";
import db from "~/utils/db.server";
import { requireLoggedIn } from "~/utils/auth.server";
import logger from "~/utils/logger.server";
import { decrypt } from "~/utils/encryption";
import { getSession } from "~/utils/session.server";
export type PhoneSettingsLoaderData = {
accountSid?: string;
@ -13,14 +13,15 @@ export type PhoneSettingsLoaderData = {
};
const loader = async ({ request }: LoaderArgs) => {
const { organization, twilio } = await requireLoggedIn(request);
const session = await getSession(request);
const twilio = session.get("twilio");
if (!twilio) {
logger.warn("Twilio account is not connected");
return json({ phoneNumbers: [] });
}
const phoneNumbers = await db.phoneNumber.findMany({
where: { twilioAccount: { organizationId: organization.id } },
where: { twilioAccount: { accountSid: twilio.accountSid } },
select: { id: true, number: true, isCurrent: true },
orderBy: { id: Prisma.SortOrder.desc },
});