mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
Change name from oragnisation to organisation
This commit is contained in:
@@ -72,20 +72,20 @@ type Organisation = Partial<Prisma.OrganisationCreateArgs["data"]>;
|
||||
type Group = Partial<Prisma.GroupCreateArgs["data"]>;
|
||||
|
||||
export async function handleCreateByName(
|
||||
create: { type: "oragnisation"; data: Organisation },
|
||||
create: { type: "organisation"; data: Organisation },
|
||||
link: { type: "event"; id: string },
|
||||
req: Request<any>,
|
||||
res: Response
|
||||
): Promise<unknown>;
|
||||
export async function handleCreateByName(
|
||||
create: { type: "group"; data: Group },
|
||||
link: { type: "oragnisation"; id: string },
|
||||
link: { type: "organisation"; id: string },
|
||||
req: Request<any>,
|
||||
res: Response
|
||||
): Promise<unknown>;
|
||||
export async function handleCreateByName(
|
||||
create: { type: "oragnisation" | "group"; data: Organisation | Group },
|
||||
link: { type: "event" | "oragnisation"; id: string },
|
||||
create: { type: "organisation" | "group"; data: Organisation | Group },
|
||||
link: { type: "event" | "organisation"; id: string },
|
||||
req: Request<any>,
|
||||
res: Response
|
||||
) {
|
||||
|
||||
@@ -7,12 +7,12 @@ import { generateError, genericError, handleCreateByName } from "./common";
|
||||
const basicGroup = {
|
||||
pid: true,
|
||||
name: true,
|
||||
oragnisation: { select: { pid: true, name: true } },
|
||||
organisation: { select: { pid: true, name: true } },
|
||||
} as const;
|
||||
|
||||
export const _getAllGroups = async (res: Response, organisationId: string | undefined) => {
|
||||
const groups = await prisma.group.findMany({
|
||||
where: { oragnisation: { pid: organisationId } },
|
||||
where: { organisation: { pid: organisationId } },
|
||||
select: basicGroup,
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
||||
const group: {
|
||||
pid: string;
|
||||
name: string;
|
||||
oragnisation: { pid: string; name: string };
|
||||
organisation: { pid: string; name: string };
|
||||
admins?: { pid: string; name: string }[];
|
||||
participants?: { pid: string }[];
|
||||
} | null = await prisma.group.findUnique({
|
||||
@@ -60,7 +60,7 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
||||
? {
|
||||
pid: true,
|
||||
name: true,
|
||||
oragnisation: { select: { pid: true, name: true } },
|
||||
organisation: { select: { pid: true, name: true } },
|
||||
admins: { select: { pid: true, name: true } },
|
||||
participants: { select: { pid: true } },
|
||||
}
|
||||
@@ -77,8 +77,8 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
||||
group: {
|
||||
...group,
|
||||
organisation: {
|
||||
...group.oragnisation,
|
||||
_links: [{ rel: "self", type: "GET", href: `/api/organisation/${group.oragnisation.pid}` }],
|
||||
...group.organisation,
|
||||
_links: [{ rel: "self", type: "GET", href: `/api/organisation/${group.organisation.pid}` }],
|
||||
},
|
||||
...(req.auth?.isAuthenticated
|
||||
? {
|
||||
@@ -109,7 +109,7 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
||||
export const createGroup = async (req: Request<{ organisationPid: string }, {}, { name?: string }>, res: Response) => {
|
||||
return handleCreateByName(
|
||||
{ type: "group", data: { name: req.body.name, level: 1 } },
|
||||
{ type: "oragnisation", id: req.params.organisationPid },
|
||||
{ type: "organisation", id: req.params.organisationPid },
|
||||
req,
|
||||
res
|
||||
);
|
||||
|
||||
@@ -125,7 +125,7 @@ export const createOrganisation = async (
|
||||
res: Response
|
||||
) => {
|
||||
return handleCreateByName(
|
||||
{ type: "oragnisation", data: { name: req.body.name } },
|
||||
{ type: "organisation", data: { name: req.body.name } },
|
||||
{ type: "event", id: req.params.eventPid },
|
||||
req,
|
||||
res
|
||||
|
||||
Reference in New Issue
Block a user