Skip to content

Commit

Permalink
chore: update prisma schema and package scripts to support dev and ma…
Browse files Browse the repository at this point in the history
…nagement env variables
  • Loading branch information
nikolvs committed Feb 15, 2024
1 parent 8082478 commit 607ea7f
Show file tree
Hide file tree
Showing 12 changed files with 378 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="file:./sqlite.db"
DATABASE_URL="file:./local.db"

# App variables
NEXT_PUBLIC_APP_TITLE=Geração 666 | Diretoria
Expand Down
1 change: 1 addition & 0 deletions .env.management
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL="file:./production.db"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ yarn-error.log*
next-env.d.ts

# sqlite
/prisma/local.db
*-journal
6 changes: 3 additions & 3 deletions app/api/genre/route.tsx → app/api/tag/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import prisma from '@/app/lib/prisma'

export async function GET() {
try {
const genres = await prisma.genre.findMany()
return Response.json(genres)
const tags = await prisma.tag.findMany()
return Response.json(tags)
} catch (err) {
// TODO: Handle error correctly
console.log('Error while retrieving genres:', err)
console.log('Error while retrieving tags:', err)
} finally {
await prisma.$disconnect()
}
Expand Down
14 changes: 7 additions & 7 deletions app/artist/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useForm } from "react-hook-form";
import { Artist, artistSchema } from "../artist.schema";
import { resolver } from '@/app/lib/yup'
import useAxios from "@/app/lib/axios";
import { Genre } from "@prisma/client";
import { Tag } from "@prisma/client";
import ReactCrop, { Crop, PercentCrop } from 'react-image-crop'
import "react-image-crop/dist/ReactCrop.css";
import { useRef, useState } from "react";
Expand All @@ -28,7 +28,7 @@ export default function ArtistCreatePage() {
} = context

const imgRef = useRef<HTMLImageElement>(null)
const [{ data: genres = [], loading }] = useAxios('/api/genre')
const [{ data: tags = [], loading }] = useAxios('/api/tag')
const { result: coverDataUrl } = useFileReader(watch('cover') as File)

const [cropWidth, cropHeight] = [400, 400]
Expand Down Expand Up @@ -133,12 +133,12 @@ export default function ArtistCreatePage() {
<FormInput label="País de origem" name="origin" />

<FormAutocomplete
name="genres"
label="Gêneros musicais"
name="tags"
label="Tags"
items={
genres.map((genre: Genre) => ({
label: genre.name,
value: genre.name
tags.map((tag: Tag) => ({
label: tag.name,
value: tag.name
}))
}
disabled={loading}
Expand Down
196 changes: 187 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 607ea7f

Please sign in to comment.