Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xvvvyz committed Feb 15, 2024
1 parent 9659fe8 commit 56c9f0d
Show file tree
Hide file tree
Showing 282 changed files with 5,727 additions and 5,170 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Preview
on:
push:
branches-ignore:
- main
env:
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
NEXT_PUBLIC_SUPABASE_PRO: ${{ secrets.NEXT_PUBLIC_SUPABASE_PRO }}
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD_INLINE: ${{ secrets.SUPABASE_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
jobs:
Deploy:
runs-on: ubuntu-latest
environment: Preview
steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v1
- run: bun i
- run: bun vercel pull -y --environment=preview --token="$VERCEL_TOKEN"
- run: bun supabase link --project-ref "$SUPABASE_PROJECT_ID"
- run: bun db:start
- run: bun db:types
- run: bun next telemetry disable
- run: bun vercel build
- run: bun supabase db push --password "$SUPABASE_DB_PASSWORD_INLINE"
- run: bun vercel deploy --prebuilt --token="$VERCEL_TOKEN"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ next-env.d.ts
node_modules/
supabase/.branches/
supabase/.temp/
.vercel
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ next-env.d.ts
node_modules/
supabase/.branches/
supabase/.temp/
supabase/templates/
26 changes: 4 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# llog

> The ultimate platform for behavior consultants.
## Development Setup

Install [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git),
[Node](https://nodejs.org/en/download), [bun](https://bun.sh/docs/installation) and
[Docker](https://docs.docker.com/engine/install), then:
[Node](https://nodejs.org/en/download), [bun](https://bun.sh/docs/installation)
and [Docker](https://docs.docker.com/engine/install), then:

```shell
git clone [email protected]:xvvvyz/llog.git
Expand Down Expand Up @@ -47,27 +45,11 @@ bun db:diff -- migration-description
- Update email templates
- Update url config
- Add custom SMTP server
- Enable realtime
- Enable realtime (notifications)
- Remove GraphQL api
- Github environment secrets:
- NEXT_PUBLIC_SUPABASE_ANON_KEY
- NEXT_PUBLIC_SUPABASE_PRO
- NEXT_PUBLIC_SUPABASE_URL
- SUPABASE_DB_PASSWORD
- SUPABASE_PROJECT_ID

### Email Templates

<!-- prettier-ignore -->
```html
Hello,<br><br>Here is the link: <a href="{{ .ConfirmationURL }}">reset your password</a>.<br><br>If you did not make this request, ignore this email.<br><br>Best,<br>The llog team<style>div{padding:0!important}#made-with-supabase{display:none!important}</style>
```

<!-- prettier-ignore -->
```html
Hello,<br><br>Please <a href="{{ .ConfirmationURL }}">confirm your email address</a>.<br><br>If you did not sign up for llog, ignore this email.<br><br>Best,<br>The llog team<style>div{padding:0!important}#made-with-supabase{display:none!important}</style>
```

<!-- prettier-ignore -->
```html
Hello,<br><br>Please <a href="{{ .ConfirmationURL }}">confirm your new email address</a>.<br><br>Best,<br>The llog team<style>div{padding:0!important}#made-with-supabase{display:none!important}</style>
```
22 changes: 22 additions & 0 deletions app/(pages)/(private)/@modals/account/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import AccountForm from '@/_components/account-form';
import PageModal from '@/_components/page-modal';
import PageModalHeader from '@/_components/page-modal-header';
import getCurrentUserFromSession from '@/_queries/get-current-user-from-session';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

export const metadata = { title: formatTitle('Account') };

const Page = async () => {
const user = await getCurrentUserFromSession();
if (!user) notFound();

return (
<PageModal temporary_forcePath="/account">
<PageModalHeader title="Account settings" />
<AccountForm user={user} />
</PageModal>
);
};

export default Page;
3 changes: 3 additions & 0 deletions app/(pages)/(private)/@modals/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const Default = () => null;

export default Default;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BackButton from '@/_components/back-button';
import Breadcrumbs from '@/_components/breadcrumbs';
import InputForm from '@/_components/input-form';
import getInput, { GetInputData } from '@/_server/get-input';
import listSubjectsByTeamId from '@/_server/list-subjects-by-team-id';
import PageModal from '@/_components/page-modal';
import PageModalHeader from '@/_components/page-modal-header';
import getInput from '@/_queries/get-input';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

Expand All @@ -17,24 +17,19 @@ export const generateMetadata = async ({ params: { inputId } }: PageProps) => {
return { title: formatTitle(['Inputs', input?.label]) };
};

export const revalidate = 0;

const Page = async ({ params: { inputId } }: PageProps) => {
const [{ data: input }, { data: subjects }] = await Promise.all([
getInput(inputId),
listSubjectsByTeamId(),
]);

if (!input) notFound();
if (!input || !subjects) notFound();

return (
<>
<div className="my-16 flex h-8 items-center justify-between gap-8 px-4">
<BackButton href="/inputs" />
<Breadcrumbs items={[['Inputs', '/inputs'], [input.label]]} />
</div>
<InputForm input={input as GetInputData} subjects={subjects} />
</>
<PageModal temporary_forcePath={`/inputs/${inputId}`}>
<PageModalHeader title={input.label} />
<InputForm input={input} subjects={subjects} />
</PageModal>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import InputForm from '@/_components/input-form';
import PageModal from '@/_components/page-modal';
import PageModalHeader from '@/_components/page-modal-header';
import getInput from '@/_queries/get-input';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
inputId: string;
};
}

export const metadata = { title: formatTitle(['Inputs', 'Create']) };

const Page = async ({ params: { inputId } }: PageProps) => {
const [{ data: subjects }, { data: input }] = await Promise.all([
listSubjectsByTeamId(),
getInput(inputId),
]);

if (!input || !subjects) notFound();

return (
<PageModal temporary_forcePath={`/inputs/create/from-input/${inputId}`}>
<PageModalHeader title="Create input" />
<InputForm input={input} isDuplicate subjects={subjects} />
</PageModal>
);
};

export default Page;
23 changes: 23 additions & 0 deletions app/(pages)/(private)/@modals/inputs/create/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import InputForm from '@/_components/input-form';
import PageModal from '@/_components/page-modal';
import PageModalHeader from '@/_components/page-modal-header';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

export const metadata = { title: formatTitle(['Inputs', 'Create']) };

const Page = async () => {
const { data: subjects } = await listSubjectsByTeamId();

if (!subjects) notFound();

return (
<PageModal temporary_forcePath={`/inputs/create`}>
<PageModalHeader title="Create input" />
<InputForm subjects={subjects} />
</PageModal>
);
};

export default Page;
18 changes: 18 additions & 0 deletions app/(pages)/(private)/@modals/notifications/archive/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import NotificationsPage from '@/_components/notifications-page';
import listNotifications from '@/_queries/list-notifications';
import formatTitle from '@/_utilities/format-title';

export const metadata = { title: formatTitle('Notifications archive') };

const Page = async () => {
const { data: notifications } = await listNotifications({ archived: true });

return (
<NotificationsPage
notifications={notifications}
temporary_forcePath="/notifications/archive"
/>
);
};

export default Page;
18 changes: 18 additions & 0 deletions app/(pages)/(private)/@modals/notifications/inbox/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import NotificationsPage from '@/_components/notifications-page';
import listNotifications from '@/_queries/list-notifications';
import formatTitle from '@/_utilities/format-title';

export const metadata = { title: formatTitle('Notifications inbox') };

const Page = async () => {
const { data: notifications } = await listNotifications();

return (
<NotificationsPage
notifications={notifications}
temporary_forcePath="/notifications/inbox"
/>
);
};

export default Page;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BackButton from '@/_components/back-button';
import Breadcrumbs from '@/_components/breadcrumbs';
import PageModal from '@/_components/page-modal';
import PageModalHeader from '@/_components/page-modal-header';
import SubjectForm from '@/_components/subject-form';
import getSubject from '@/_server/get-subject';
import getSubject from '@/_queries/get-subject';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

Expand All @@ -18,22 +18,15 @@ export const generateMetadata = async ({
return { title: formatTitle([subject?.name, 'Edit']) };
};

export const revalidate = 0;

const Page = async ({ params: { subjectId } }: PageProps) => {
const { data: subject } = await getSubject(subjectId);
if (!subject) notFound();

return (
<>
<div className="my-16 flex h-8 items-center justify-between gap-8 px-4">
<BackButton href="/subjects" />
<Breadcrumbs
items={[[subject.name, `/subjects/${subjectId}`], ['Edit']]}
/>
</div>
<PageModal temporary_forcePath={`/subjects/${subjectId}/edit`}>
<PageModalHeader title="Edit subject" />
<SubjectForm subject={subject} />
</>
</PageModal>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import EventTypeForm from '@/_components/event-type-form';
import PageModal from '@/_components/page-modal';
import PageModalHeader from '@/_components/page-modal-header';
import getEventTypeWithInputs from '@/_queries/get-event-type-with-inputs';
import getSubject from '@/_queries/get-subject';
import listInputsBySubjectId from '@/_queries/list-inputs-by-subject-id';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import listTemplatesWithData from '@/_queries/list-templates-with-data';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
eventTypeId: string;
subjectId: string;
};
}

export const generateMetadata = async ({
params: { eventTypeId, subjectId },
}: PageProps) => {
const [{ data: subject }, { data: eventType }] = await Promise.all([
getSubject(subjectId),
getEventTypeWithInputs(eventTypeId),
]);

return { title: formatTitle([subject?.name, eventType?.name, 'Edit']) };
};

const Page = async ({ params: { eventTypeId, subjectId } }: PageProps) => {
const [
{ data: subject },
{ data: eventType },
{ data: availableInputs },
{ data: availableTemplates },
{ data: subjects },
] = await Promise.all([
getSubject(subjectId),
getEventTypeWithInputs(eventTypeId),
listInputsBySubjectId(subjectId),
listTemplatesWithData(),
listSubjectsByTeamId(),
]);

if (
!subject ||
!eventType ||
!availableInputs ||
!availableTemplates ||
!subjects
) {
notFound();
}

return (
<PageModal
temporary_forcePath={`/subjects/${subjectId}/event-types/${eventTypeId}/edit`}
>
<PageModalHeader title={eventType.name as string} />
<EventTypeForm
availableInputs={availableInputs}
availableTemplates={availableTemplates}
eventType={eventType}
subjects={subjects}
subjectId={subjectId}
/>
</PageModal>
);
};

export default Page;
Loading

0 comments on commit 56c9f0d

Please sign in to comment.