-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f813fe
commit f6fdcfc
Showing
9 changed files
with
51 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
'use server' | ||
import { Licenses } from "@/services/licenses" | ||
import { Action } from "../Action" | ||
import { Action } from '@/actions/Action' | ||
import { Licenses } from '@/services/licenses' | ||
|
||
export const createLicenseAction = Action(Licenses.create) | ||
export const createLicenseAction = Action(Licenses.create) |
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
'use server' | ||
import { Licenses } from "@/services/licenses" | ||
import { ActionNoData } from "../Action" | ||
import { ActionNoData } from '@/actions/Action' | ||
import { Licenses } from '@/services/licenses' | ||
|
||
export const destroyLicenseAction = ActionNoData(Licenses.destroy) | ||
export const destroyLicenseAction = ActionNoData(Licenses.destroy) |
This file contains 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use server' | ||
|
||
import { Licenses } from "@/services/licenses" | ||
import { Action } from "@/actions/Action" | ||
import { Licenses } from '@/services/licenses' | ||
import { Action } from '@/actions/Action' | ||
|
||
export const updateLicenseAction = Action(Licenses.update) | ||
export const updateLicenseAction = Action(Licenses.update) |
This file contains 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 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 |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import 'server-only' | ||
import { ServiceMethodHandler } from "@/services/ServiceMethodHandler" | ||
import { createLicenseValidation } from './validation' | ||
import { ServiceMethodHandler } from '@/services/ServiceMethodHandler' | ||
|
||
export const create = ServiceMethodHandler({ | ||
withData: true, | ||
validation: createLicenseValidation, | ||
handler: async (prisma, _, data) => { | ||
return await prisma.license.create({ | ||
data, | ||
}) | ||
}, | ||
}) | ||
handler: async (prisma, _, data) => await prisma.license.create({ | ||
data, | ||
}), | ||
}) |
This file contains 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 |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import 'server-only' | ||
import { ServiceMethodHandler } from '../ServiceMethodHandler' | ||
import { ServerError } from '../error' | ||
import { ServiceMethodHandler } from '@/services/ServiceMethodHandler' | ||
import { ServerError } from '@/services/error' | ||
|
||
export const destroy = ServiceMethodHandler({ | ||
withData: false, | ||
handler: async (prisma, params: { id: number }) => { | ||
const { name: licenseName } = await prisma.license.findUniqueOrThrow({ | ||
where: { id: params.id }, | ||
const { name: licenseName } = await prisma.license.findUniqueOrThrow({ | ||
where: { id: params.id }, | ||
select: { name: true } | ||
}) | ||
|
||
const imagesOfLicense = await prisma.image.findMany({ | ||
where: { | ||
licenseName: licenseName | ||
}, | ||
take: 1 | ||
const imagesOfLicense = await prisma.image.findMany({ | ||
where: { | ||
licenseName | ||
}, | ||
take: 1 | ||
}) | ||
if (imagesOfLicense.length > 0) { | ||
throw new ServerError( | ||
'UNPERMITTED CASCADE', | ||
'UNPERMITTED CASCADE', | ||
'Lisensen har bilder tilknyttet - slett bildene først eller endre lisensen på bildene' | ||
) | ||
} | ||
|
||
await prisma.license.delete({ where: { id: params.id } }) | ||
} | ||
}) | ||
}) |
This file contains 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 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 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