-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
421 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ const salesRoutes = [ | |
}, | ||
{ | ||
title: 'New Sale', | ||
href: '../search', | ||
href: 'new-invoice', | ||
}, | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { invariantResponse } from '@epic-web/invariant' | ||
import { type LoaderFunctionArgs, json } from '@remix-run/node' | ||
import { Link, useLoaderData } from '@remix-run/react' | ||
import { Button } from '#app/components/ui/button' | ||
import { requireUserId } from '#app/utils/auth.server' | ||
import { PLATFORM_STATUS } from '#app/utils/constants/platform-status' | ||
import { prisma } from '#app/utils/db.server' | ||
|
||
export async function loader({ request, params }: LoaderFunctionArgs) { | ||
const userId = await requireUserId(request) | ||
|
||
const company = await prisma.company.findUnique({ | ||
where: { | ||
id: params.companyId, | ||
users: { | ||
some: { | ||
userId: userId, | ||
}, | ||
}, | ||
platformStatusKey: PLATFORM_STATUS.ACTIVE.KEY, | ||
}, | ||
select: { | ||
accounts: { | ||
select: { | ||
id: true, | ||
name: true, | ||
uniqueId: true, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
invariantResponse(company, 'Not found', { status: 404 }) | ||
|
||
return json({ company }) | ||
} | ||
|
||
export default function CompanyAccountsCustomer() { | ||
const data = useLoaderData<typeof loader>() | ||
|
||
return ( | ||
<> | ||
<table className="min-w-full divide-y"> | ||
<thead> | ||
<tr className="text-left text-sm font-semibold"> | ||
<th scope="col" className="py-3.5 pr-3"> | ||
Name | ||
</th> | ||
<th scope="col" className="hidden px-3 py-3.5 lg:table-cell"> | ||
Unique Id | ||
</th> | ||
<th scope="col" className="relative py-3.5 pl-3 pr-4 sm:pr-0"> | ||
<span className="sr-only">Edit</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody className="divide-y"> | ||
{data.company.accounts.map(customer => ( | ||
<tr key={customer.id}> | ||
<td className="w-full max-w-0 py-4 pr-3 font-medium sm:w-auto sm:max-w-none"> | ||
{customer.name} | ||
<dl className="font-normal lg:hidden"> | ||
<dt className="sr-only sm:hidden">Unique Id</dt> | ||
<dd className="mt-1 truncate text-sm sm:hidden"> | ||
{customer.uniqueId ?? '-'} | ||
</dd> | ||
</dl> | ||
</td> | ||
<td className="hidden px-3 py-4 sm:table-cell"> | ||
{customer.uniqueId ?? '-'} | ||
</td> | ||
<td className="py-4 pl-3 pr-4 text-right font-medium sm:pr-0"> | ||
<Link to={`${customer.id}`}> | ||
<Button variant="link">View</Button> | ||
</Link> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { type LoaderFunctionArgs } from '@remix-run/node' | ||
import { json, redirect, useLoaderData } from '@remix-run/react' | ||
import { prisma } from '#app/utils/db.server' | ||
import { requireCompanyUserWithRBAC } from '#app/utils/permissions.server' | ||
|
||
export async function loader({ request, params }: LoaderFunctionArgs) { | ||
await requireCompanyUserWithRBAC({ | ||
request, | ||
companyId: params.companyId!, | ||
permission: 'create:company-account', | ||
}) | ||
|
||
const url = new URL(request.url) | ||
const searchParams = url.searchParams | ||
|
||
// ! Removing guest mode for now I can just make a misc account for all guest stuff | ||
// const checkGuest = searchParams.get('guest') | ||
// if (checkGuest) return null | ||
|
||
const accountId = searchParams.get('accountId') | ||
|
||
if (!accountId || accountId.length >= 25 || accountId.length <= 36) | ||
return redirect(`/c/${params.companyId}/search?q=acc:`) | ||
|
||
const account = await prisma.account.findFirst({ | ||
where: { | ||
id: params.accountId, | ||
companyId: params.companyId, | ||
}, | ||
select: { | ||
id: true, | ||
name: true, | ||
balance: true, | ||
uniqueId: true, | ||
// phone: true, | ||
}, | ||
}) | ||
return json({ account }) | ||
} | ||
|
||
export default function CompanySaleNew() { | ||
// const data = useLoaderData() | ||
|
||
return <div>Hello</div> | ||
} | ||
|
||
// ! Remove the guest stuff completely | ||
// export default function CompanySaleNew() { | ||
// const data = useLoaderData<typeof loader>() | ||
|
||
// const params = useParams() | ||
|
||
// // create a modal to select whether to enter guest mode or search account using tailwindcss and react | ||
// return ( | ||
// <div className="flex h-screen flex-col items-center justify-center space-y-4"> | ||
// <Link | ||
// to="?guest=true" | ||
// className="rounded bg-blue-500 px-6 py-2 text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-opacity-50" | ||
// autoFocus | ||
// onClick={() => console.log('Entering Guest Mode')} | ||
// > | ||
// Guest Mode | ||
// </Link> | ||
// <Link to={`/c/${params.companyId}/search`} | ||
// className="rounded bg-green-500 px-6 py-2 text-white hover:bg-green-600 focus:outline-none focus:ring-2 focus:ring-green-700 focus:ring-opacity-50" | ||
// onClick={() => console.log('Searching Account')} | ||
// > | ||
// Search Account | ||
// </Link> | ||
// </div> | ||
|
||
// ) | ||
// } |
Oops, something went wrong.