Skip to content

Commit

Permalink
Merge Staging to Main (#228)
Browse files Browse the repository at this point in the history
* perf: skip loading state for button submission

* test: random comment

* test: random comment

* test: adding sentry inp

* test: adding sentry inp

* feat: add template for pull requests

* fix: revise template

Signed-off-by: Christine Belzie <[email protected]>

* fix: added public environment variable

* fix: add loader to subscribe button

* docs: add a note about where commits should go

* add Return

* feat: added logic to use safeparse instead of parse

* feat: add aria-label to input

Signed-off-by: Christine <[email protected]>

* fix: change aria-label

Signed-off-by: Christine <[email protected]>

* feat: add alt text for footer icons

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* feat: add back in the navbar

* feat: add back never miss a deal section

* feat: add in separator with proper spacings

* fix: updated footer typescript type for alt property

* fix: return string error from subscribe

* chore: update meta description to current website header

* docs: updated contributing.md

* refactor: split admin dashboard, manage deals, and manage subs to their own pages

* docs: add BryanF1nes as a contributor for doc (#87)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: James Q Quick <[email protected]>

* docs: updated and re-structured pull_request_template (#86)

* docs: updated and re-structured pull_request_template

* docs: updated comments per last PR request

* feat: migrating queries to prisma

* feat: migrate db query code to Prisma

* feat: prisma update remove reference to xata_id

* fix: add in office equipment category and refactor adding plural (s) to only certain categories

* fix: add ts-expect-error for Subscriber.tsx.  Temp fix until we can identify type issue

* refactor: create layout and associated pages for /dashboard

* refactor: remove props in Dashboard component as they are handeled by other components

* refactor: rename components/dashboard/Dashboard to AdminNav and update affected files

* style: add hover styles to SubscriberList for ease of use

* chore: fix typo in Deal.tsx component export and remove import no longer needed in Deal.tsx

* fix: add prisma generate to build command

* Update README.md (#93)

* docs(readme): added link to contribution guide

* change px values to default tailwind values

* docs: included a link to the figma file (#99)

* Update Hero.tsx

* fix: removed unnecessary use client

* #74 Feat multistep add deal form (#107)

* feat: initial commit for the new multi-step form

* fix: category select placeholder and value size

* fix: temp functions for draganddrop image and category select

* feat: added step navigation and localStorage updates for step-1 "Product Info"

* refactor: added input, textarea, and select focus ring offsets to teal

* fix: margin-top of step navigation

* style: added custom svg background for dropzone border that adjusts when screen size changes

* feat: initial schema design for deal images

* feat: updated prisma schema with link to image table

* feat: made the relation of deal to image one-to-one

* feat: get return upload URL

* feat: working image fetch after upload using url

* feat: continued dev of multistep form and cleaned up context provider

* fix: add default of undefined for coupon percent

* fix: dropdown select

* fix: category select values not holding on form page reload

* fix: not reset category on page load

* fix: category select form

* feat: share a deal form with all routes and data.  Does not include validate at review

* feat: multiform submits to database after review

* fix: missing schema update

* fix: public image url return!

* refactor: updated newDealSchema with union type

* feat: upload image function for review

* feat: mobile styling for add a deal

* fix: subscriber type being pulled from xata and not prisma

* fix: reference database url from environment variable in xata.ts

* fix: clean up responsive design

* fix: changed image upload to post instead of put and removed logs

* fix: more responsive styles

* fix: more responsive styles

* fix: remove unused imports

* fix: removed cron job and will add in with future feature PR

---------

Co-authored-by: jamesqquick <[email protected]>

* Feat: add t3 env (#108)

* feat: added t3_env

* feat: added t3_env

* feat: Generated Xata Config and Types During Build (#110)

* feat: added t3_env

* feat: added t3_env

* feat: remove xata files from git

* feat: remove xata files from git

* feat: added xata-init script

* docs: added documentation for db setup in readme

* docs: added documentation for db setup in readme

* fix: removed dotenv-cli

* Add .nvmrc to help with local dev (#104)

Allows contributors to more easily get their local environment setup and runnig quickly.

Currently this will recommend/setup the latest LTS version of node. We could change to pin to specific version if that's preferred and then manually update when wanted/needed.

Co-authored-by: James Q Quick <[email protected]>

* fix: separate link button from text in subscription email (#109)

* docs: added figma file link

* fix: wrap separate link button from text

---------

Co-authored-by: Bryan <[email protected]>
Co-authored-by: James Q Quick <[email protected]>

* Chore: Correct Confirmation Email (#112)

* docs: added figma file link

* fix: wrap separate link button from text

* fix: reorder components in confimation email

---------

Co-authored-by: Bryan <[email protected]>
Co-authored-by: FatumaA <[email protected]>

* fix: added codegen package

* Fix broken build (#113)

Updated build command to call Xata codegen.

* Docs xata onboarding (#114)

* docs: improve onboarding docs in readme for database setup

* docs: improve onboarding docs in readme for database setup

* Added image of Xata dashboard

* docs: db onboarding

* Feat update card design (#126)

* feat: redesign of category options (#128)

* feat: Add Default Image for Deals (#134)

* feat: add default image for deals

* Feat: dynamic category routes (#131)

dynamic category routes

* Feature: remove redirect to preferences page (#139)

* chore: removed unused imports

* feat(#124): removed redirect to preferences page

* feat: deal route, design, and deal preview component

* feat: display featured deals on home page

* feat: updated search design and organized search components (#143)

* feat: updated search design and organized search components

* fix: removed duplicate records from testing

* fix: removed overflow hidden from search results

* style: added styles for currently selected category

* Merge Dev To Staging (#145)

- featured deals
- deals by category
- deal form
- base admin functionality

* fix: handle error for too large file upload (#146)

* Handle Image Upload Error (#147)

Handle image upload erorr

* style: standard display for all deals and category dael pages

* Fix: no unique constraint coverImageId (#154)

* chore: removed console logs

* Fix: Remove ID From Subscriber (#155)

* fix: remove subscriber id (#156)

* fix: remove id from subscriber

* fix: remove reference to subscriber id in lieu of xata_id

* fix: convert description field to text (#158)

* Merge Dev to Staging (#159)

- add styles for selected category
- convert description to text field

* feat: create SearchedDeal component (#157)

* feat: create SearchedDeal component

* chore: remove logs

---------

Co-authored-by: jamesqquick <[email protected]>

* fix: removed prisma ids in lieu of xata_id

* feat: created deal image component (#161)

* Fix search record id (#162)

* chore: changed default px to px-2 (#167)

* Feat image outlines (#166)

* Add plausible analytics (#169)

* feat: two separate start and end dates (#171)

- two inputs
- loading indicator for loading local data

* Fix: move sign in and sign up inside admin (#170)

* fix(admin-directory): moved clerk provider, changed admin directory

moved clerk provider to admin/dashboard layout only, changed (admin) to admin and moved auth pages

* fix(admin-directory): moved clerk wrapper around and am fixing links/redirects

currently cannot get to dashboard as an admin

BREAKING CHANGE:

* fix(/admin-route): update /dashboard route in .env.example, env.ts, and middleware.ts

---------

Co-authored-by: jamesqquick <[email protected]>

* feat: small design tweaks (#172)

* fix: prisma schema to support null end date (#173)

* Merge Dev To Staging (#174)

* perf: skip loading state for button submission

* test: random comment

* test: random comment

* test: adding sentry inp

* test: adding sentry inp

* feat: add template for pull requests

* fix: revise template

Signed-off-by: Christine Belzie <[email protected]>

* fix: added public environment variable

* fix: add loader to subscribe button

* docs: add a note about where commits should go

* add Return

* feat: added logic to use safeparse instead of parse

* feat: add aria-label to input

Signed-off-by: Christine <[email protected]>

* fix: change aria-label

Signed-off-by: Christine <[email protected]>

* feat: add alt text for footer icons

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* feat: add back in the navbar

* feat: add back never miss a deal section

* feat: add in separator with proper spacings

* fix: updated footer typescript type for alt property

* fix: return string error from subscribe

* chore: update meta description to current website header

* docs: updated contributing.md

* refactor: split admin dashboard, manage deals, and manage subs to their own pages

* docs: add BryanF1nes as a contributor for doc (#87)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: James Q Quick <[email protected]>

* docs: updated and re-structured pull_request_template (#86)

* docs: updated and re-structured pull_request_template

* docs: updated comments per last PR request

* feat: migrating queries to prisma

* feat: migrate db query code to Prisma

* feat: prisma update remove reference to xata_id

* fix: add in office equipment category and refactor adding plural (s) to only certain categories

* fix: add ts-expect-error for Subscriber.tsx.  Temp fix until we can identify type issue

* refactor: create layout and associated pages for /dashboard

* refactor: remove props in Dashboard component as they are handeled by other components

* refactor: rename components/dashboard/Dashboard to AdminNav and update affected files

* style: add hover styles to SubscriberList for ease of use

* chore: fix typo in Deal.tsx component export and remove import no longer needed in Deal.tsx

* fix: add prisma generate to build command

* docs: added contributing doc and pr template

* Update README.md (#93)

* docs(readme): added link to contribution guide

* change px values to default tailwind values

* docs: included a link to the figma file (#99)

* Update Hero.tsx

* fix: removed unnecessary use client

* #74 Feat multistep add deal form (#107)

* feat: initial commit for the new multi-step form

* fix: category select placeholder and value size

* fix: temp functions for draganddrop image and category select

* feat: added step navigation and localStorage updates for step-1 "Product Info"

* refactor: added input, textarea, and select focus ring offsets to teal

* fix: margin-top of step navigation

* style: added custom svg background for dropzone border that adjusts when screen size changes

* feat: initial schema design for deal images

* feat: updated prisma schema with link to image table

* feat: made the relation of deal to image one-to-one

* feat: get return upload URL

* feat: working image fetch after upload using url

* feat: continued dev of multistep form and cleaned up context provider

* fix: add default of undefined for coupon percent

* fix: dropdown select

* fix: category select values not holding on form page reload

* fix: not reset category on page load

* fix: category select form

* feat: share a deal form with all routes and data.  Does not include validate at review

* feat: multiform submits to database after review

* fix: missing schema update

* fix: public image url return!

* refactor: updated newDealSchema with union type

* feat: upload image function for review

* feat: mobile styling for add a deal

* fix: subscriber type being pulled from xata and not prisma

* fix: reference database url from environment variable in xata.ts

* fix: clean up responsive design

* fix: changed image upload to post instead of put and removed logs

* fix: more responsive styles

* fix: more responsive styles

* fix: remove unused imports

* fix: removed cron job and will add in with future feature PR

---------

Co-authored-by: jamesqquick <[email protected]>

* Feat: add t3 env (#108)

* feat: added t3_env

* feat: added t3_env

* feat: Generated Xata Config and Types During Build (#110)

* feat: added t3_env

* feat: added t3_env

* feat: remove xata files from git

* feat: remove xata files from git

* feat: added xata-init script

* docs: added documentation for db setup in readme

* docs: added documentation for db setup in readme

* fix: removed dotenv-cli

* Add .nvmrc to help with local dev (#104)

Allows contributors to more easily get their local environment setup and runnig quickly.

Currently this will recommend/setup the latest LTS version of node. We could change to pin to specific version if that's preferred and then manually update when wanted/needed.

Co-authored-by: James Q Quick <[email protected]>

* fix: separate link button from text in subscription email (#109)

* docs: added figma file link

* fix: wrap separate link button from text

---------

Co-authored-by: Bryan <[email protected]>
Co-authored-by: James Q Quick <[email protected]>

* Chore: Correct Confirmation Email (#112)

* docs: added figma file link

* fix: wrap separate link button from text

* fix: reorder components in confimation email

---------

Co-authored-by: Bryan <[email protected]>
Co-authored-by: FatumaA <[email protected]>

* fix: added codegen package

* Fix broken build (#113)

Updated build command to call Xata codegen.

* Docs xata onboarding (#114)

* docs: improve onboarding docs in readme for database setup

* docs: improve onboarding docs in readme for database setup

* Added image of Xata dashboard

* docs: db onboarding

* Feat update card design (#126)

* feat: redesign of category options (#128)

* feat: Add Default Image for Deals (#134)

* feat: add default image for deals

* Feat: dynamic category routes (#131)

dynamic category routes

* Feature: remove redirect to preferences page (#139)

* chore: removed unused imports

* feat(#124): removed redirect to preferences page

* feat: deal route, design, and deal preview component

* feat: display featured deals on home page

* feat: updated search design and organized search components (#143)

* feat: updated search design and organized search components

* fix: removed duplicate records from testing

* fix: removed overflow hidden from search results

* style: added styles for currently selected category

* fix: handle error for too large file upload (#146)

* style: standard display for all deals and category dael pages

* Fix: no unique constraint coverImageId (#154)

* chore: removed console logs

* Fix: Remove ID From Subscriber (#155)

* fix: remove subscriber id (#156)

* fix: remove id from subscriber

* fix: remove reference to subscriber id in lieu of xata_id

* fix: convert description field to text (#158)

* feat: create SearchedDeal component (#157)

* feat: create SearchedDeal component

* chore: remove logs

---------

Co-authored-by: jamesqquick <[email protected]>

* fix: removed prisma ids in lieu of xata_id

* feat: created deal image component (#161)

* Fix search record id (#162)

* chore: changed default px to px-2 (#167)

* Feat image outlines (#166)

* Add plausible analytics (#169)

* feat: two separate start and end dates (#171)

- two inputs
- loading indicator for loading local data

* Fix: move sign in and sign up inside admin (#170)

* fix(admin-directory): moved clerk provider, changed admin directory

moved clerk provider to admin/dashboard layout only, changed (admin) to admin and moved auth pages

* fix(admin-directory): moved clerk wrapper around and am fixing links/redirects

currently cannot get to dashboard as an admin

BREAKING CHANGE:

* fix(/admin-route): update /dashboard route in .env.example, env.ts, and middleware.ts

---------

Co-authored-by: jamesqquick <[email protected]>

* feat: small design tweaks (#172)

* fix: prisma schema to support null end date (#173)

---------

Signed-off-by: Christine Belzie <[email protected]>
Signed-off-by: Christine <[email protected]>
Co-authored-by: Christine Belzie <[email protected]>
Co-authored-by: Christine Belzie <[email protected]>
Co-authored-by: klae32 <[email protected]>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Chris Nowicki <[email protected]>
Co-authored-by: Ryan Furrer <[email protected]>
Co-authored-by: Bryan <[email protected]>
Co-authored-by: Bryan Fines <[email protected]>
Co-authored-by: wipdev-tech <[email protected]>
Co-authored-by: Ellie <[email protected]>
Co-authored-by: Mark Huggins <[email protected]>
Co-authored-by: Fatuma Abdullahi <[email protected]>
Co-authored-by: Michael Moore <[email protected]>

* chore: remove logs

* feat: design tweaks

* fix: update prisma schema for coupon percent to not have a default (#176)

* Dev to Staging (#178)

* chore: removed log

* fix(UI/UX): fixed several UX issues for MVP 1 (#184)

* fix(DevGiveaways): added space between "We're" and "giving"

* fix(NeverMissADeal.tsx): added class `mb-16` for margin bottom in the `sm` breakpoint

* fix(NeverMissADeal.tsx): make component more responsive

chaged css to manipulate widths on containing div, text span, and subscriberform container

* fix(DealPreview.tsx): add css to allow whitespace and line breaks in deal desc

* docs: updated environment variable example file with defaults

* fix: add revalidate to deals pages (#185)

* Merge Dev to Staging

* docs: docs to fix image column generated by prisma

* Update README.md

* docs: docs to fix image column generated by prisma

* fix: accessibility of icons and add footer landmark (#192)

* fix: add aria labels for icon buttons and links

* fix: add aria label to search button

* fix: change div to footer landmark

* feat: add 16 x 9 image ratio requirement to form (#193)

* feat: added a revalidate endpoint and env variable for  validation secret

* feat: revalidate_path_admin_options

* fix: don't revalidate deals route on delete

* feat: add og image to deals pages

* docs: make getting started instructions clearer (#206)

* docs: make instructions clearer

* feat: add link to Discord community

---------

Co-authored-by: Christine Belzie <[email protected]>

* Bug dont show outdated deals (#204)

* fix: added a filter to queries to only get deals that are not expired

* refactor: got rid of unused import statement

* fix: removed unused queries and added expired check to additional queries

---------

Co-authored-by: jamesqquick <[email protected]>

* feat: added disclaimer route and page with placeholder for text (#205)

* feat: added disclaimer route and page with placeholder for text

* chore: added text for disclaimer page

---------

Co-authored-by: jamesqquick <[email protected]>

* fix: updated the button color to be brighter (#211)

Co-authored-by: James Q Quick <[email protected]>

* fix: add main landmark to pages (#210)

* feat: added contributor rocks link on readme (#214)

* docs: clarify environment variables in example env file and readme (#216)

* docs: moved setup to its own file and referenced it from readme and contributing file

* Merge Dev to Staging (#217)

* fix: update prisma schema for coupon percent to not have a default (#176)

* fix(UI/UX): fixed several UX issues for MVP 1 (#184)

* fix(DevGiveaways): added space between "We're" and "giving"

* fix(NeverMissADeal.tsx): added class `mb-16` for margin bottom in the `sm` breakpoint

* fix(NeverMissADeal.tsx): make component more responsive

chaged css to manipulate widths on containing div, text span, and subscriberform container

* fix(DealPreview.tsx): add css to allow whitespace and line breaks in deal desc

* docs: updated environment variable example file with defaults

* fix: add revalidate to deals pages (#185)

* docs: docs to fix image column generated by prisma

* Update README.md

* fix: accessibility of icons and add footer landmark (#192)

* fix: add aria labels for icon buttons and links

* fix: add aria label to search button

* fix: change div to footer landmark

* feat: add 16 x 9 image ratio requirement to form (#193)

* feat: added a revalidate endpoint and env variable for  validation secret

* feat: revalidate_path_admin_options

* fix: don't revalidate deals route on delete

* feat: add og image to deals pages

* docs: make getting started instructions clearer (#206)

* docs: make instructions clearer

* feat: add link to Discord community

---------

Co-authored-by: Christine Belzie <[email protected]>

* Bug dont show outdated deals (#204)

* fix: added a filter to queries to only get deals that are not expired

* refactor: got rid of unused import statement

* fix: removed unused queries and added expired check to additional queries

---------

Co-authored-by: jamesqquick <[email protected]>

* feat: added disclaimer route and page with placeholder for text (#205)

* feat: added disclaimer route and page with placeholder for text

* chore: added text for disclaimer page

---------

Co-authored-by: jamesqquick <[email protected]>

* fix: updated the button color to be brighter (#211)

Co-authored-by: James Q Quick <[email protected]>

* fix: add main landmark to pages (#210)

* feat: added contributor rocks link on readme (#214)

* docs: clarify environment variables in example env file and readme (#216)

* docs: moved setup to its own file and referenced it from readme and contributing file

---------

Co-authored-by: Ryan Furrer <[email protected]>
Co-authored-by: Emma Dawson <[email protected]>
Co-authored-by: Chris Nowicki <[email protected]>
Co-authored-by: Christine Belzie <[email protected]>
Co-authored-by: klae32 <[email protected]>

* fix: merge conflicts

* fix: extra validation on link submission

* feat: deal form validation - page submission, real-time input, final submit validation and redirect

* Bug no link validation (#220)

Add link validation on url input using zod

* Bug filter unapproved deals in search (#219)

- add filter to search to remove unapproved deals

* feat: added edit deal page

* fix: update semantics of combobox (#225)

* feat: added pending deals list and edit deal pages

* feat: simplified edit deal form submission and standardized on action return type

* Merge Dev to Staging (#227)

* fix: update prisma schema for coupon percent to not have a default (#176)

* fix(UI/UX): fixed several UX issues for MVP 1 (#184)

* fix(DevGiveaways): added space between "We're" and "giving"

* fix(NeverMissADeal.tsx): added class `mb-16` for margin bottom in the `sm` breakpoint

* fix(NeverMissADeal.tsx): make component more responsive

chaged css to manipulate widths on containing div, text span, and subscriberform container

* fix(DealPreview.tsx): add css to allow whitespace and line breaks in deal desc

* docs: updated environment variable example file with defaults

* fix: add revalidate to deals pages (#185)

* docs: docs to fix image column generated by prisma

* Update README.md

* fix: accessibility of icons and add footer landmark (#192)

* fix: add aria labels for icon buttons and links

* fix: add aria label to search button

* fix: change div to footer landmark

* feat: add 16 x 9 image ratio requirement to form (#193)

* feat: added a revalidate endpoint and env variable for  validation secret

* feat: revalidate_path_admin_options

* fix: don't revalidate deals route on delete

* feat: add og image to deals pages

* docs: make getting started instructions clearer (#206)

* docs: make instructions clearer

* feat: add link to Discord community

---------

Co-authored-by: Christine Belzie <[email protected]>

* Bug dont show outdated deals (#204)

* fix: added a filter to queries to only get deals that are not expired

* refactor: got rid of unused import statement

* fix: removed unused queries and added expired check to additional queries

---------

Co-authored-by: jamesqquick <[email protected]>

* feat: added disclaimer route and page with placeholder for text (#205)

* feat: added disclaimer route and page with placeholder for text

* chore: added text for disclaimer page

---------

Co-authored-by: jamesqquick <[email protected]>

* fix: updated the button color to be brighter (#211)

Co-authored-by: James Q Quick <[email protected]>

* fix: add main landmark to pages (#210)

* feat: added contributor rocks link on readme (#214)

* docs: clarify environment variables in example env file and readme (#216)

* docs: moved setup to its own file and referenced it from readme and contributing file

* fix: extra validation on link submission

* feat: deal form validation - page submission, real-time input, final submit validation and redirect

* Bug no link validation (#220)

Add link validation on url input using zod

* Bug filter unapproved deals in search (#219)

- add filter to search to remove unapproved deals

* feat: added edit deal page

* fix: update semantics of combobox (#225)

* feat: added pending deals list and edit deal pages

* feat: simplified edit deal form submission and standardized on action return type

---------

Co-authored-by: Ryan Furrer <[email protected]>
Co-authored-by: Emma Dawson <[email protected]>
Co-authored-by: Chris Nowicki <[email protected]>
Co-authored-by: Christine Belzie <[email protected]>
Co-authored-by: klae32 <[email protected]>

* feat: added description field to input

* chore: pulled from dev

---------

Signed-off-by: Christine Belzie <[email protected]>
Signed-off-by: Christine <[email protected]>
Co-authored-by: Christine Belzie <[email protected]>
Co-authored-by: Christine Belzie <[email protected]>
Co-authored-by: klae32 <[email protected]>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Chris Nowicki <[email protected]>
Co-authored-by: Ryan Furrer <[email protected]>
Co-authored-by: Bryan <[email protected]>
Co-authored-by: Bryan Fines <[email protected]>
Co-authored-by: wipdev-tech <[email protected]>
Co-authored-by: Ellie <[email protected]>
Co-authored-by: Mark Huggins <[email protected]>
Co-authored-by: Fatuma Abdullahi <[email protected]>
Co-authored-by: Michael Moore <[email protected]>
Co-authored-by: Emma Dawson <[email protected]>
  • Loading branch information
15 people authored Jul 12, 2024
1 parent c4aba34 commit f5c5da0
Show file tree
Hide file tree
Showing 41 changed files with 1,498 additions and 625 deletions.
12 changes: 0 additions & 12 deletions src/actions/deals.ts

This file was deleted.

14 changes: 14 additions & 0 deletions src/app/admin/dashboard/PendingDeals.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import AdminDealsList from '@/components/dashboard/AdminDealsList'
import { getAllPendingDeals } from '@/lib/queries'

export default async function PendingDeals() {
const deals = await getAllPendingDeals()

return (
<>
{deals.length > 0 ?
<AdminDealsList deals={deals} />
: <p>No pending deals</p>}
</>
)
}
79 changes: 79 additions & 0 deletions src/app/admin/dashboard/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use server'
import { updateDealSchema } from '@/app/deals/add/schemas'
import { approveDeal, deleteDeal, updateDeal } from '@/lib/queries'
import { isAdminUser } from '@/utils/auth'
import { auth } from '@clerk/nextjs'
import { Deal } from '@prisma/client'
import { revalidatePath } from 'next/cache'
import { redirect } from 'next/navigation'

export type ReturnValue<T> = {
data?: T
successMessage?: string
error?: string
}

export const updateDealAction = async (
deal: Deal
): Promise<ReturnValue<undefined>> => {
const { userId } = auth().protect()
const isAdmin = await isAdminUser(userId)
if (!isAdmin) {
return redirect('/')
}

const validated = updateDealSchema.safeParse(deal)

if (validated.success) {
try {
await updateDeal(deal)
return { error: undefined, successMessage: 'Updated successfully' }
} catch (error) {
console.error(error)
return {
error: 'There was an error updating the deal',
}
}
} else {
console.log(validated.error.issues)
return {
error: 'Please verify all inputs and try again.',
}
}
}

export const approveDealAction = async (
id: string
): Promise<ReturnValue<undefined>> => {
const { userId } = auth().protect()
const isAdmin = await isAdminUser(userId)
if (!isAdmin) {
return redirect('/')
}
try {
await approveDeal(id)
revalidatePath('/deals')
return { successMessage: 'Approved successfully' }
} catch (error) {
console.error(error)
return { error: 'There was an error approving the deal' }
}
}

export const rejectDealAction = async (
id: string
): Promise<ReturnValue<undefined>> => {
const { userId } = auth().protect()
const isAdmin = await isAdminUser(userId)
if (!isAdmin) {
return redirect('/')
}
try {
await deleteDeal(id)
revalidatePath('/admin/dashboard')
return { successMessage: 'Rejected successfully' }
} catch (error) {
console.error(error)
return { error: 'There was an error rejecting the deal' }
}
}
72 changes: 72 additions & 0 deletions src/app/admin/dashboard/deals/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { notFound } from 'next/navigation'
import { getDealByIdAsAdmin } from '@/lib/queries'
import { Metadata, ResolvingMetadata } from 'next'
import EditDealForm from '@/components/dashboard/EditDealForm'
import RejectDealButton from '@/components/dashboard/RejectDealButton'
import ApproveDealButton from '@/components/dashboard/ApproveDealButton'
import { Delete } from 'lucide-react'
import DeleteDealButton from '@/components/dashboard/DeleteDealButton'

export const revalidate = 120

type Props = {
params: { id: string }
searchParams: { [key: string]: string | string[] | undefined }
}

export async function generateMetadata(
{ params, searchParams }: Props,
parent: ResolvingMetadata
): Promise<Metadata> {
// read route params
const id = params.id

// fetch data
const deal = await getDealByIdAsAdmin(params.id)

if (!deal) {
return {
title: 'Deal not found',
}
}

return {
title: deal?.name,
description: deal?.description,
openGraph: {
images: [deal?.coverImageURL || '/logo-wide.png'],
},
}
}

export default async function EditDealPage({
params: { id },
}: {
params: { id: string }
}) {
if (!id) {
notFound()
}
const deal = await getDealByIdAsAdmin(id)
if (!deal) {
notFound()
}

return (
<main>
<section className="mx-auto space-y-12 px-4 pb-10">
<div className="flex items-center justify-between">
<h1 className="text-center text-5xl text-white">Edit Deal</h1>
{!deal.approved && (
<div className="flex justify-end gap-x-4 py-4">
<RejectDealButton id={id} />
<ApproveDealButton id={id} />
</div>
)}
{deal.approved && <DeleteDealButton id={id} />}
</div>
<EditDealForm deal={deal} />
</section>
</main>
)
}
15 changes: 0 additions & 15 deletions src/app/admin/dashboard/deals/page.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions src/app/admin/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export default async function Home({
}

return (
<main className="mx-auto space-y-12 px-4 pb-10">
<div className="mx-auto space-y-12 px-4 pb-10">
<section className="mx-auto grid gap-8 space-y-12 px-4 pb-10 lg:grid-cols-3 lg:space-y-0">
<div className="mx-auto lg:col-span-1">
<AdminNav />
</div>
<div className="mx-auto lg:col-span-2">{children}</div>
<main className=" lg:col-span-2">{children}</main>
</section>
</main>
</div>
)
}
11 changes: 10 additions & 1 deletion src/app/admin/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
export default async function Dashboard() {}
import PendingDeals from './PendingDeals'

export default async function Deals() {
return (
<section className="mx-auto space-y-12 px-4 pb-10">
<h1 className="text-center text-5xl text-white">Manage Deals</h1>
<PendingDeals />
</section>
)
}
37 changes: 0 additions & 37 deletions src/app/api/deals/approve/route.ts

This file was deleted.

37 changes: 0 additions & 37 deletions src/app/api/deals/reject/route.ts

This file was deleted.

4 changes: 4 additions & 0 deletions src/app/api/deals/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export async function GET(request: NextRequest) {
//TODO: how do we handle this now that we have Prisma?
const { records } = await xataClient.db.Deal.search(query, {
target: ['name', 'description'],
filter: {
approved: true,
//TODO: add filter for endDate
},
})

//TODO: fix this hack based on weird data from search api
Expand Down
4 changes: 2 additions & 2 deletions src/app/deals/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export default async function DealPage({ params }: { params: { id: string } }) {
<div className="pb-10">
<DealPreview
name={deal.name}
url={deal.link}
couponCode={deal.coupon}
link={deal.link}
coupon={deal.coupon}
couponPercent={deal.couponPercent}
coverImageURL={deal.coverImageURL}
startDate={deal.startDate}
Expand Down
Loading

0 comments on commit f5c5da0

Please sign in to comment.