Skip to content

Commit

Permalink
chore: pkg update
Browse files Browse the repository at this point in the history
itsmegood committed Mar 1, 2024
1 parent e5ca9a5 commit 2543ddc
Showing 10 changed files with 349 additions and 362 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -140,10 +140,9 @@
# name: 🚀 Deploy
# runs-on: ubuntu-22.04
# needs: [lint, typecheck, vitest, playwright]
# # only build/deploy main branch on pushes
# if:
# ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') &&
# github.event_name == 'push' }}
# # only build/deploy branches on pushes
# if:
# ${{ github.event_name == 'push' }}

# steps:
# - name: ⬇️ Checkout repo
11 changes: 4 additions & 7 deletions app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { parseWithZod } from '@conform-to/zod'
import { invariantResponse } from '@epic-web/invariant'
import { cssBundleHref } from '@remix-run/css-bundle'
import {
json,
type LoaderFunctionArgs,
@@ -10,12 +9,12 @@ import {
type MetaFunction,
} from '@remix-run/node'
import {
Links,
Links,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useFetchers,
useFetchers,
useLoaderData,
useRouteLoaderData,
} from '@remix-run/react'
@@ -46,7 +45,6 @@ export const links: LinksFunction = () => {
{ rel: 'preload', href: iconsHref, as: 'image' },
// Preload CSS as a resource to avoid render blocking
{ rel: 'preload', href: tailwindStyleSheetUrl, as: 'style' },
cssBundleHref ? { rel: 'preload', href: cssBundleHref, as: 'style' } : null,
{ rel: 'mask-icon', href: '/favicons/mask-icon.svg' },
{
rel: 'alternate icon',
@@ -62,7 +60,6 @@ export const links: LinksFunction = () => {
//These should match the css preloads above to avoid css as render blocking resource
{ rel: 'icon', type: 'image/svg+xml', href: '/favicons/favicon.svg' },
{ rel: 'stylesheet', href: tailwindStyleSheetUrl },
cssBundleHref ? { rel: 'stylesheet', href: cssBundleHref } : null,
].filter(Boolean)
}

@@ -202,8 +199,8 @@ function Document({
function App() {
const data = useLoaderData<typeof loader>()
const nonce = useNonce()
const theme = useTheme()
const theme = useTheme()

useToast(data.toast)

return (
103 changes: 103 additions & 0 deletions app/routes/c.$companyId.accounts+/__account-editor.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { parseWithZod } from '@conform-to/zod'
import {
json,
type ActionFunctionArgs,
redirect,
} from '@remix-run/node'
import { z } from 'zod'
import { prisma } from '#app/utils/db.server'
import { requireCompanyUserWithRBAC } from '#app/utils/permissions.server'
import {CompanyAccountsEditorSchema} from './__account-editor'


export async function action({ request, params }: ActionFunctionArgs) {
const user = await requireCompanyUserWithRBAC({
request,
companyId: params.companyId!,
permission: 'create:company-account',
select: {
userCompanies: {
select: {
id: true,
},
},
},
})

const formData = await request.formData()

const submission = await parseWithZod(formData, {
schema: CompanyAccountsEditorSchema.superRefine(async (data, ctx) => {
const checkName = await prisma.company.findFirst({
where: {
accounts: {
some: {
name: data.name,
},
},
},
})

if (checkName) {
ctx.addIssue({
path: ['name'],
code: z.ZodIssueCode.custom,
message: 'Name already exists',
})
}
}),
async: true,
})

if (submission.status !== 'success') {
return json(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
}

const {
id: accountId,
name,
uniqueId,
email,
phone,
address,
city,
state,
country,
zip,
} = submission.value

await prisma.account.upsert({
where: {
id: accountId ?? '__new_account__',
},
create: {
name,
uniqueId,
email,
phone,
address,
city,
state,
country,
zip,
companyId: params.companyId!,
createdById: user.userCompanies[0].id,
},
update: {
name,
uniqueId,
email,
phone,
address,
city,
state,
country,
zip,
},
})

return redirect(`/c/${params.companyId}/accounts`)
}
101 changes: 3 additions & 98 deletions app/routes/c.$companyId.accounts+/__account-editor.tsx
Original file line number Diff line number Diff line change
@@ -2,22 +2,19 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type Account } from '@prisma/client'
import {
json,
type ActionFunctionArgs,
type SerializeFrom,
} from '@remix-run/node'
import { Form, redirect, useActionData } from '@remix-run/react'
import { Form, useActionData } from '@remix-run/react'
import { z } from 'zod'
import { Field } from '#app/components/forms'
import { StatusButton } from '#app/components/ui/status-button'
import { prisma } from '#app/utils/db.server'
import { useIsPending } from '#app/utils/misc'
import { requireCompanyUserWithRBAC } from '#app/utils/permissions.server'
import {type action} from "./__account-editor.server"

// TODO: Make a better component to handle country, state, and city inputs
// ? Maybe a select component with api data

const CompanyAccountsEditorSchema = z.object({
export const CompanyAccountsEditorSchema = z.object({
id: z.string().optional(),
name: z.string().min(3).max(40),
uniqueId: z.string().min(4).max(24).optional(),
@@ -31,98 +28,6 @@ const CompanyAccountsEditorSchema = z.object({
// description: z.string().min(4).max(80).optional(),
})

export async function action({ request, params }: ActionFunctionArgs) {
const user = await requireCompanyUserWithRBAC({
request,
companyId: params.companyId!,
permission: 'create:company-account',
select: {
userCompanies: {
select: {
id: true,
},
},
},
})

const formData = await request.formData()

const submission = await parseWithZod(formData, {
schema: CompanyAccountsEditorSchema.superRefine(async (data, ctx) => {
const checkName = await prisma.company.findFirst({
where: {
accounts: {
some: {
name: data.name,
},
},
},
})

if (checkName) {
ctx.addIssue({
path: ['name'],
code: z.ZodIssueCode.custom,
message: 'Name already exists',
})
}
}),
async: true,
})

if (submission.status !== 'success') {
return json(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
}

const {
id: accountId,
name,
uniqueId,
email,
phone,
address,
city,
state,
country,
zip,
} = submission.value

await prisma.account.upsert({
where: {
id: accountId ?? '__new_account__',
},
create: {
name,
uniqueId,
email,
phone,
address,
city,
state,
country,
zip,
companyId: params.companyId!,
createdById: user.userCompanies[0].id,
},
update: {
name,
uniqueId,
email,
phone,
address,
city,
state,
country,
zip,
},
})

return redirect(`/c/${params.companyId}/customers`)
}

export function AccountEditor({
account,
}: {
4 changes: 2 additions & 2 deletions app/routes/c.$companyId.accounts+/cust.$accountId_.edit.tsx
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@ 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 { AccountEditor, action } from './__account-editor.js'
import { AccountEditor } from './__account-editor.tsx'

export { action }
export { action } from './__account-editor.server.tsx'

export async function loader({ params, request }: LoaderFunctionArgs) {
await requireCompanyUserWithRBAC({
4 changes: 2 additions & 2 deletions app/routes/c.$companyId.accounts+/new.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type LoaderFunctionArgs } from '@remix-run/node'
import { requireCompanyUserWithRBAC } from '#app/utils/permissions.server'
import { AccountEditor, action } from './__account-editor'
import { AccountEditor} from './__account-editor'

export async function loader({ request, params }: LoaderFunctionArgs) {
await requireCompanyUserWithRBAC({
@@ -12,5 +12,5 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return null
}

export { action }
export { action } from './__account-editor.server'
export default AccountEditor
6 changes: 4 additions & 2 deletions other/Dockerfile
Original file line number Diff line number Diff line change
@@ -53,6 +53,9 @@ ENV INTERNAL_PORT="8080"
ENV PORT="8081"
ENV NODE_ENV="production"

# For WAL support: https://github.com/prisma/prisma-engines/issues/4675#issuecomment-1914383246
ENV PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK = "1"

# add shortcut for connecting to database CLI
RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli

@@ -63,13 +66,12 @@ COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma

COPY --from=build /myapp/server-build /myapp/server-build
COPY --from=build /myapp/build /myapp/build
COPY --from=build /myapp/public /myapp/public
COPY --from=build /myapp/package.json /myapp/package.json
COPY --from=build /myapp/prisma /myapp/prisma
COPY --from=build /myapp/app/components/ui/icons /myapp/app/components/ui/icons

# prepare for litefs
COPY --from=flyio/litefs:0.5.8 /usr/local/bin/litefs /usr/local/bin/litefs
COPY --from=flyio/litefs:0.5.11 /usr/local/bin/litefs /usr/local/bin/litefs
ADD other/litefs.yml /etc/litefs.yml
RUN mkdir -p /data ${LITEFS_DIR}

9 changes: 0 additions & 9 deletions other/litefs.yml
Original file line number Diff line number Diff line change
@@ -34,13 +34,4 @@ exec:
- cmd: npx prisma migrate deploy
if-candidate: true

# re-enable these when this is fixed: https://github.com/superfly/litefs/issues/425
# # Set the journal mode for the database to WAL. This reduces concurrency deadlock issues
# - cmd: sqlite3 $DATABASE_PATH "PRAGMA journal_mode = WAL;"
# if-candidate: true

# # Set the journal mode for the cache to WAL. This reduces concurrency deadlock issues
# - cmd: sqlite3 $CACHE_DATABASE_PATH "PRAGMA journal_mode = WAL;"
# if-candidate: true

- cmd: npm start
415 changes: 203 additions & 212 deletions package-lock.json

Large diffs are not rendered by default.

51 changes: 25 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -49,21 +49,20 @@
"@paralleldrive/cuid2": "^2.2.2",
"@prisma/client": "^5.10.2",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@react-email/components": "0.0.15",
"@remix-run/css-bundle": "2.7.2",
"@remix-run/express": "2.7.2",
"@remix-run/node": "2.7.2",
"@remix-run/react": "2.7.2",
"@remix-run/server-runtime": "2.7.2",
"@sentry/profiling-node": "^7.102.1",
"@sentry/remix": "^7.102.1",
"address": "^2.0.1",
"@remix-run/express": "2.8.0",
"@remix-run/node": "2.8.0",
"@remix-run/react": "2.8.0",
"@remix-run/server-runtime": "2.8.0",
"@sentry/profiling-node": "^7.104.0",
"@sentry/remix": "^7.104.0",
"address": "^2.0.2",
"bcryptjs": "^2.4.3",
"better-sqlite3": "^9.4.3",
"chalk": "^5.3.0",
@@ -78,25 +77,25 @@
"dotenv": "^16.4.5",
"eslint-plugin-remix-react-routes": "^1.0.5",
"execa": "^8.0.1",
"express": "^4.18.2",
"express": "^4.18.3",
"express-rate-limit": "^7.1.5",
"get-port": "^7.0.0",
"glob": "^10.3.10",
"helmet": "^7.1.0",
"intl-parse-accept-language": "^1.0.0",
"isbot": "^5.1.0",
"isbot": "^5.1.1",
"litefs-js": "^1.1.2",
"lru-cache": "^10.2.0",
"morgan": "^1.10.0",
"qrcode": "^1.5.3",
"qrcode": "^1.5.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remix-auth": "^3.6.0",
"remix-auth-form": "^1.4.0",
"remix-auth-github": "^1.6.0",
"remix-utils": "^7.5.0",
"set-cookie-parser": "^2.6.0",
"sonner": "^1.4.0",
"sonner": "^1.4.3",
"source-map-support": "^0.5.21",
"spin-delay": "^1.2.0",
"tailwind-merge": "^2.2.1",
@@ -107,11 +106,11 @@
},
"devDependencies": {
"@faker-js/faker": "^8.4.1",
"@playwright/test": "^1.41.2",
"@remix-run/dev": "2.7.2",
"@remix-run/eslint-config": "2.7.2",
"@remix-run/serve": "2.7.2",
"@remix-run/testing": "2.7.2",
"@playwright/test": "^1.42.0",
"@remix-run/dev": "2.8.0",
"@remix-run/eslint-config": "2.8.0",
"@remix-run/serve": "2.8.0",
"@remix-run/testing": "2.8.0",
"@sly-cli/sly": "^1.8.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
@@ -121,35 +120,35 @@
"@types/better-sqlite3": "^7.6.9",
"@types/compression": "^1.7.5",
"@types/cookie": "^0.6.0",
"@types/eslint": "^8.56.3",
"@types/eslint": "^8.56.5",
"@types/express": "^4.17.21",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0",
"@types/morgan": "^1.9.9",
"@types/node": "^20.11.20",
"@types/node": "^20.11.24",
"@types/qrcode": "^1.5.5",
"@types/react": "^18.2.57",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"@types/set-cookie-parser": "^2.4.7",
"@types/source-map-support": "^0.5.10",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.3.1",
"autoprefixer": "^10.4.17",
"enforce-unique": "^1.2.0",
"enforce-unique": "^1.3.0",
"esbuild": "^0.20.1",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"fs-extra": "^11.2.0",
"jsdom": "^24.0.0",
"msw": "2.2.1",
"msw": "2.2.2",
"node-html-parser": "^6.1.12",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"prettier-plugin-sql": "^0.18.0",
"prettier-plugin-tailwindcss": "^0.5.11",
"prisma": "^5.10.2",
"prisma": "^5.10.2",
"remix-flat-routes": "^0.6.4",
"rimraf": "^5.0.5",
"rimraf": "^5.0.5",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"vite": "^5.1.4",

0 comments on commit 2543ddc

Please sign in to comment.