Skip to content

Commit e996639

Browse files
committed
re-organize
1 parent 8322776 commit e996639

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5880
-6757
lines changed

app/root.tsx

Lines changed: 3 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,22 @@ import {
66
type MetaFunction,
77
} from '@remix-run/node'
88
import {
9-
Form,
10-
Link,
119
Links,
1210
Meta,
1311
Outlet,
1412
Scripts,
1513
ScrollRestoration,
1614
useLoaderData,
17-
useSubmit,
1815
} from '@remix-run/react'
1916
import { withSentry } from '@sentry/remix'
20-
import { useRef } from 'react'
2117
import { HoneypotProvider } from 'remix-utils/honeypot/react'
2218
import { GeneralErrorBoundary } from './components/error-boundary.tsx'
2319
import { EpicProgress } from './components/progress-bar.tsx'
2420
import { useToast } from './components/toaster.tsx'
25-
import { Button } from './components/ui/button.tsx'
26-
import {
27-
DropdownMenu,
28-
DropdownMenuContent,
29-
DropdownMenuItem,
30-
DropdownMenuPortal,
31-
DropdownMenuTrigger,
32-
} from './components/ui/dropdown-menu.tsx'
33-
import { Icon, href as iconsHref } from './components/ui/icon.tsx'
21+
import { href as iconsHref } from './components/ui/icon.tsx'
3422
import { EpicToaster } from './components/ui/sonner.tsx'
3523
import { TooltipProvider } from './components/ui/tooltip.tsx'
36-
import { ThemeSwitch, useTheme } from './routes/resources+/theme-switch.tsx'
24+
import { useTheme } from './routes/resources+/theme-switch.tsx'
3725
import tailwindStyleSheetUrl from './styles/tailwind.css?url'
3826
import { getUserId, logout } from './utils/auth.server.ts'
3927
import { ClientHintCheck, getHints } from './utils/client-hints.tsx'
@@ -42,11 +30,9 @@ import { getEnv } from './utils/env.server.ts'
4230
import { honeypot } from './utils/honeypot.server.ts'
4331
import { combineHeaders, getDomainUrl } from './utils/misc.tsx'
4432
import { useNonce } from './utils/nonce-provider.ts'
45-
import { getCustomerProducts } from './utils/stripe.server.ts'
4633
import { getTheme, type Theme } from './utils/theme.server.ts'
4734
import { makeTimings, time } from './utils/timing.server.ts'
4835
import { getToast } from './utils/toast.server.ts'
49-
import { useOptionalUser, useUser } from './utils/user.ts'
5036

5137
export const links: LinksFunction = () => {
5238
return [
@@ -121,9 +107,6 @@ export async function loader({ request }: LoaderFunctionArgs) {
121107
return json(
122108
{
123109
user,
124-
isSubscribed: user?.stripeId
125-
? Boolean((await getCustomerProducts(user.stripeId)).products.length)
126-
: false,
127110
requestInfo: {
128111
hints: getHints(request),
129112
origin: getDomainUrl(request),
@@ -195,7 +178,6 @@ function Document({
195178
function App() {
196179
const data = useLoaderData<typeof loader>()
197180
const nonce = useNonce()
198-
const user = useOptionalUser()
199181
const theme = useTheme()
200182
const allowIndexing = data.ENV.ALLOW_INDEXING !== 'false'
201183
useToast(data.toast)
@@ -207,91 +189,13 @@ function App() {
207189
allowIndexing={allowIndexing}
208190
env={data.ENV}
209191
>
210-
<div className="flex h-screen flex-col justify-between">
211-
<header className="container py-6">
212-
<nav className="flex flex-wrap items-center justify-between gap-4 sm:flex-nowrap md:gap-8">
213-
<Logo />
214-
<div className="flex items-center gap-10">
215-
{user ? (
216-
<div className="flex gap-4">
217-
{data.isSubscribed ? null : (
218-
<Button variant="outline" asChild>
219-
<Link to="/settings/profile/subscription">
220-
Start your free trial
221-
</Link>
222-
</Button>
223-
)}
224-
<UserDropdown />
225-
</div>
226-
) : (
227-
<Button asChild variant="default" size="lg">
228-
<Link to="/login">Log In</Link>
229-
</Button>
230-
)}
231-
</div>
232-
</nav>
233-
</header>
234-
<div className="flex-1">
235-
<Outlet />
236-
</div>
237-
<footer className="container my-4 flex items-center justify-between pb-5">
238-
<div className="flex items-center gap-4">
239-
<Logo />
240-
<nav>
241-
<ul className="flex list-none flex-col gap-2 md:flex-row md:gap-4">
242-
<li>
243-
<Link
244-
to="/about"
245-
className="text-gray-600 hover:text-gray-900"
246-
>
247-
About
248-
</Link>
249-
</li>
250-
<li>
251-
<Link
252-
to="/privacy"
253-
className="text-gray-600 hover:text-gray-900"
254-
>
255-
Privacy
256-
</Link>
257-
</li>
258-
<li>
259-
<Link to="/tos" className="text-gray-600 hover:text-gray-900">
260-
Terms of Service
261-
</Link>
262-
</li>
263-
<li>
264-
<Link
265-
to="/support"
266-
className="text-gray-600 hover:text-gray-900"
267-
>
268-
Support
269-
</Link>
270-
</li>
271-
<li>
272-
<Link
273-
to="/contact"
274-
className="text-gray-600 hover:text-gray-900"
275-
>
276-
Contact
277-
</Link>
278-
</li>
279-
</ul>
280-
</nav>
281-
</div>
282-
<ThemeSwitch userPreference={data.requestInfo.userPrefs.theme} />
283-
</footer>{' '}
284-
</div>
192+
<Outlet />
285193
<EpicToaster closeButton position="top-center" theme={theme} />
286194
<EpicProgress />
287195
</Document>
288196
)
289197
}
290198

291-
function Logo() {
292-
return <Link to="/">GratiText</Link>
293-
}
294-
295199
function AppWithProviders() {
296200
const data = useLoaderData<typeof loader>()
297201
return (
@@ -305,62 +209,6 @@ function AppWithProviders() {
305209

306210
export default withSentry(AppWithProviders)
307211

308-
function UserDropdown() {
309-
const user = useUser()
310-
const submit = useSubmit()
311-
const formRef = useRef<HTMLFormElement>(null)
312-
return (
313-
<DropdownMenu>
314-
<DropdownMenuTrigger asChild>
315-
<Button asChild variant="secondary">
316-
<Link
317-
to={`/users/${user.username}`}
318-
// this is for progressive enhancement
319-
onClick={e => e.preventDefault()}
320-
className="flex items-center gap-2"
321-
>
322-
<span className="text-body-sm font-bold">
323-
{user.name ?? user.username}
324-
</span>
325-
</Link>
326-
</Button>
327-
</DropdownMenuTrigger>
328-
<DropdownMenuPortal>
329-
<DropdownMenuContent sideOffset={8} align="start">
330-
<DropdownMenuItem asChild>
331-
<Link prefetch="intent" to={`/users/${user.username}`}>
332-
<Icon className="text-body-md" name="avatar">
333-
Profile
334-
</Icon>
335-
</Link>
336-
</DropdownMenuItem>
337-
<DropdownMenuItem asChild>
338-
<Link prefetch="intent" to={`/recipients`}>
339-
<Icon className="text-body-md" name="pencil-2">
340-
Recipients
341-
</Icon>
342-
</Link>
343-
</DropdownMenuItem>
344-
<DropdownMenuItem
345-
asChild
346-
// this prevents the menu from closing before the form submission is completed
347-
onSelect={event => {
348-
event.preventDefault()
349-
submit(formRef.current)
350-
}}
351-
>
352-
<Form action="/logout" method="POST" ref={formRef}>
353-
<Icon className="text-body-md" name="exit">
354-
<button type="submit">Logout</button>
355-
</Icon>
356-
</Form>
357-
</DropdownMenuItem>
358-
</DropdownMenuContent>
359-
</DropdownMenuPortal>
360-
</DropdownMenu>
361-
)
362-
}
363-
364212
export function ErrorBoundary() {
365213
// the nonce doesn't rely on the loader so we can access that
366214
const nonce = useNonce()

app/routes/_auth+/login.server.ts renamed to app/routes/_app+/_auth+/login.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { invariant } from '@epic-web/invariant'
22
import { redirect } from '@remix-run/node'
33
import { safeRedirect } from 'remix-utils/safe-redirect'
4-
import { twoFAVerificationType } from '#app/routes/settings.profile+/two-factor.tsx'
4+
import { twoFAVerificationType } from '#app/routes/_app+/settings.profile+/two-factor.tsx'
55
import { getUserId, sessionKey } from '#app/utils/auth.server.ts'
66
import { prisma } from '#app/utils/db.server.ts'
77
import { combineResponseInits } from '#app/utils/misc.tsx'
File renamed without changes.
File renamed without changes.
File renamed without changes.

app/routes/_auth+/verify.server.ts renamed to app/routes/_app+/_auth+/verify.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { type Submission } from '@conform-to/react'
22
import { parseWithZod } from '@conform-to/zod'
33
import { json } from '@remix-run/node'
44
import { z } from 'zod'
5-
import { handleVerification as handleChangePhoneNumberVerification } from '#app/routes/settings.profile+/change-number.server.tsx'
6-
import { twoFAVerificationType } from '#app/routes/settings.profile+/two-factor.tsx'
5+
import { handleVerification as handleChangePhoneNumberVerification } from '#app/routes/_app+/settings.profile+/change-number.server.tsx'
6+
import { twoFAVerificationType } from '#app/routes/_app+/settings.profile+/two-factor.tsx'
77
import { requireUserId } from '#app/utils/auth.server.ts'
88
import { prisma } from '#app/utils/db.server.ts'
99
import { ensurePrimary } from '#app/utils/litefs.server.ts'
File renamed without changes.

0 commit comments

Comments
 (0)