-
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
22 changed files
with
689 additions
and
243 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
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
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,58 @@ | ||
import { invariantResponse } from '@epic-web/invariant' | ||
import { json, type LoaderFunctionArgs } from '@remix-run/node' | ||
import { useLoaderData } from '@remix-run/react' | ||
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx' | ||
import { prisma } from '#app/utils/db.server.ts' | ||
import { requireCompanyUserWithRBAC } from '#app/utils/permissions.server.ts' | ||
import { CustomerAccountEditor, action } from './__customer-account-editor.tsx' | ||
|
||
export { action } | ||
|
||
export async function loader({ params, request }: LoaderFunctionArgs) { | ||
await requireCompanyUserWithRBAC({ | ||
request, | ||
companyId: params.companyId!, | ||
permission: 'create:company-account', | ||
}) | ||
|
||
const customerAccount = await prisma.customerAccount.findFirst({ | ||
where: { | ||
id: params.customerId!, | ||
companyId: params.companyId, | ||
}, | ||
select: { | ||
id: true, | ||
name: true, | ||
uniqueId: true, | ||
email: true, | ||
phone: true, | ||
address: true, | ||
country: true, | ||
city: true, | ||
state: true, | ||
zip: true, | ||
}, | ||
}) | ||
|
||
invariantResponse(customerAccount, 'Not found', { status: 404 }) | ||
|
||
return json({ customerAccount: customerAccount }) | ||
} | ||
|
||
export default function CompanyAccountsEdit() { | ||
const data = useLoaderData<typeof loader>() | ||
|
||
return <CustomerAccountEditor customerAccount={data.customerAccount} /> | ||
} | ||
|
||
export function ErrorBoundary() { | ||
return ( | ||
<GeneralErrorBoundary | ||
statusHandlers={{ | ||
404: ({ params }) => ( | ||
<p>No account with the id "{params.customerId}" exists</p> | ||
), | ||
}} | ||
/> | ||
) | ||
} |
Oops, something went wrong.