-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add quotes page #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
d5f928a
feat: create quotes pages and quotes table in database
michaelbrusegard a97f93e
feat: add quote validation
michaelbrusegard fe1ddb3
feat: add api router for quotes
michaelbrusegard a2ef8df
fix: forgot to export quotesrouter and add to the main router
michaelbrusegard b28893e
feat: add frontend for quotes
michaelbrusegard a127efa
Merge branch 'dev' into quotes
ZeroWave022 6998cce
feat: Add quotes to header
ZeroWave022 175ba1f
fix: Update old code
ZeroWave022 ca420a4
feat: Add internal quotes, various other UI fixes
ZeroWave022 a526324
feat: Add ComboboxField
ZeroWave022 b259c3a
feat: Select user with Combobox, add quote in both locales
ZeroWave022 f9b5131
feat: Add updating and deleting quotes
ZeroWave022 84e69ae
feat: Add loading to quotes pages
ZeroWave022 8a21f2d
chore: Add metadata generation to quotes pages
ZeroWave022 8390d07
fix: Allow all members to create quotes
ZeroWave022 178d5dd
fix: "Heard by" translation
ZeroWave022 d522ef1
fix: Process quote id more thoroughly
ZeroWave022 107bfda
refactor: Rename get to fetch in quote router
ZeroWave022 cc3e6a6
fix: Extra check for perms only for internal quotes
ZeroWave022 787ee20
chore: Remove unused schema
ZeroWave022 ce25531
refactor: Rename quote relations
ZeroWave022 6cb9343
Merge branch 'dev' into quotes
ZeroWave022 a4f82df
feat: Move quote translations to own table
ZeroWave022 5a1fd4c
feat: Accept more props for Combobox and ComboboxField
ZeroWave022 d30382e
feat: Improve user search when creating quotes
ZeroWave022 9cda471
feat: Add pagination to quotes
ZeroWave022 33b063f
refactor: Provide initial quote user instead of fetching on client
ZeroWave022 c97888b
fix: Use correct initialts in QuoteCard
ZeroWave022 2974628
fix: Show more users when searching in QuoteForm
ZeroWave022 ee7d24d
Merge branch 'dev' into quotes
ZeroWave022 a631e75
chore: Add DB migration for quotes
ZeroWave022 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
src/app/[locale]/(default)/quotes/[quoteId]/edit/loading.tsx
This file contains hidden or 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,25 @@ | ||
| import { ArrowLeftIcon } from 'lucide-react'; | ||
| import { getTranslations } from 'next-intl/server'; | ||
| import { QuoteFormSkeleton } from '@/components/quotes/QuoteFormSkeleton'; | ||
| import { Link } from '@/components/ui/Link'; | ||
|
|
||
| export default async function NewQuoteLoading() { | ||
| const t = await getTranslations('quotes'); | ||
| const tUpdate = await getTranslations('quotes.update'); | ||
|
|
||
| return ( | ||
| <> | ||
| <Link | ||
| className='flex w-fit items-center gap-2' | ||
| href='/quotes' | ||
| variant='ghost' | ||
| size='default' | ||
| > | ||
| <ArrowLeftIcon /> | ||
| <span>{t('backToQuotes')}</span> | ||
| </Link> | ||
| <h1 className='text-center'>{tUpdate('title')}</h1> | ||
| <QuoteFormSkeleton /> | ||
| </> | ||
| ); | ||
| } |
This file contains hidden or 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,70 @@ | ||
| import { ArrowLeftIcon } from 'lucide-react'; | ||
| import { notFound } from 'next/navigation'; | ||
| import { type Locale, type Messages, NextIntlClientProvider } from 'next-intl'; | ||
| import { | ||
| getMessages, | ||
| getTranslations, | ||
| setRequestLocale, | ||
| } from 'next-intl/server'; | ||
| import { QuoteForm } from '@/components/quotes/QuoteForm'; | ||
| import { Link } from '@/components/ui/Link'; | ||
| import { api } from '@/lib/api/server'; | ||
|
|
||
| export async function generateMetadata() { | ||
| const t = await getTranslations('quotes.update'); | ||
|
|
||
| return { | ||
| title: t('title'), | ||
| }; | ||
| } | ||
|
|
||
| export default async function NewQuotePage({ | ||
| params, | ||
| }: { | ||
| params: Promise<{ locale: Locale; quoteId: string }>; | ||
| }) { | ||
| const { locale, quoteId } = await params; | ||
| setRequestLocale(locale); | ||
|
|
||
| const { user } = await api.auth.state(); | ||
| const t = await getTranslations('quotes'); | ||
| const tUpdate = await getTranslations('quotes.update'); | ||
|
|
||
| if (Number.isNaN(quoteId)) return notFound(); | ||
|
|
||
| const quote = await api.quotes.getQuote(Number(quoteId)); | ||
ZeroWave022 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (!quote) return notFound(); | ||
|
|
||
| if ( | ||
| !user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g)) && | ||
| quote.saidBy.id !== user?.id && | ||
| quote.heardBy.id !== user?.id | ||
| ) { | ||
| // TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable | ||
| throw new Error(tUpdate('unauthorized')); | ||
| } | ||
|
|
||
| const { quotes, ui } = await getMessages(); | ||
| const users = await api.users.fetchAllUsers(); | ||
|
|
||
| return ( | ||
| <> | ||
| <Link | ||
| className='flex w-fit items-center gap-2' | ||
| href='/quotes' | ||
| variant='ghost' | ||
| size='default' | ||
| > | ||
| <ArrowLeftIcon /> | ||
| <span>{t('backToQuotes')}</span> | ||
| </Link> | ||
| <h1 className='text-center'>{tUpdate('title')}</h1> | ||
| <NextIntlClientProvider | ||
| messages={{ quotes, ui } as Pick<Messages, 'quotes' | 'ui'>} | ||
| > | ||
| <QuoteForm users={users} quote={quote} /> | ||
| </NextIntlClientProvider> | ||
| </> | ||
| ); | ||
| } | ||
This file contains hidden or 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,25 @@ | ||
| import { ArrowLeftIcon } from 'lucide-react'; | ||
| import { getTranslations } from 'next-intl/server'; | ||
| import { QuoteFormSkeleton } from '@/components/quotes/QuoteFormSkeleton'; | ||
| import { Link } from '@/components/ui/Link'; | ||
|
|
||
| export default async function NewQuotePage() { | ||
| const t = await getTranslations('quotes'); | ||
| const tNew = await getTranslations('quotes.new'); | ||
|
|
||
| return ( | ||
| <> | ||
| <Link | ||
| className='flex w-fit items-center gap-2' | ||
| href='/quotes' | ||
| variant='ghost' | ||
| size='default' | ||
| > | ||
| <ArrowLeftIcon /> | ||
| <span>{t('backToQuotes')}</span> | ||
| </Link> | ||
| <h1 className='text-center'>{tNew('title')}</h1> | ||
| <QuoteFormSkeleton /> | ||
| </> | ||
| ); | ||
| } |
This file contains hidden or 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,61 @@ | ||
| import { ArrowLeftIcon } from 'lucide-react'; | ||
| import { type Locale, type Messages, NextIntlClientProvider } from 'next-intl'; | ||
| import { | ||
| getMessages, | ||
| getTranslations, | ||
| setRequestLocale, | ||
| } from 'next-intl/server'; | ||
| import { QuoteForm } from '@/components/quotes/QuoteForm'; | ||
| import { Link } from '@/components/ui/Link'; | ||
| import { api } from '@/lib/api/server'; | ||
|
|
||
| export async function generateMetadata() { | ||
| const t = await getTranslations('quotes.new'); | ||
|
|
||
| return { | ||
| title: t('title'), | ||
| }; | ||
| } | ||
|
|
||
| export default async function NewQuotePage({ | ||
| params, | ||
| }: { | ||
| params: Promise<{ locale: Locale }>; | ||
| }) { | ||
| const { locale } = await params; | ||
| setRequestLocale(locale); | ||
|
|
||
| const { user } = await api.auth.state(); | ||
| const t = await getTranslations('quotes'); | ||
| const tNew = await getTranslations('quotes.new'); | ||
|
|
||
| if ( | ||
| !user?.groups.some((g) => ['labops', 'leadership', 'admin'].includes(g)) | ||
ZeroWave022 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) { | ||
| // TODO: Actually return a HTTP 401 Unauthorized reponse whenever `unauthorized.tsx` is stable | ||
| throw new Error(tNew('unauthorized')); | ||
| } | ||
|
|
||
| const { quotes, ui } = await getMessages(); | ||
| const users = await api.users.fetchAllUsers(); | ||
|
|
||
| return ( | ||
| <> | ||
| <Link | ||
| className='flex w-fit items-center gap-2' | ||
| href='/quotes' | ||
| variant='ghost' | ||
| size='default' | ||
| > | ||
| <ArrowLeftIcon /> | ||
| <span>{t('backToQuotes')}</span> | ||
| </Link> | ||
| <h1 className='text-center'>{tNew('title')}</h1> | ||
| <NextIntlClientProvider | ||
| messages={{ quotes, ui } as Pick<Messages, 'quotes' | 'ui'>} | ||
| > | ||
| <QuoteForm users={users} /> | ||
| </NextIntlClientProvider> | ||
| </> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.