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"]>;
|
type Group = Partial<Prisma.GroupCreateArgs["data"]>;
|
||||||
|
|
||||||
export async function handleCreateByName(
|
export async function handleCreateByName(
|
||||||
create: { type: "oragnisation"; data: Organisation },
|
create: { type: "organisation"; data: Organisation },
|
||||||
link: { type: "event"; id: string },
|
link: { type: "event"; id: string },
|
||||||
req: Request<any>,
|
req: Request<any>,
|
||||||
res: Response
|
res: Response
|
||||||
): Promise<unknown>;
|
): Promise<unknown>;
|
||||||
export async function handleCreateByName(
|
export async function handleCreateByName(
|
||||||
create: { type: "group"; data: Group },
|
create: { type: "group"; data: Group },
|
||||||
link: { type: "oragnisation"; id: string },
|
link: { type: "organisation"; id: string },
|
||||||
req: Request<any>,
|
req: Request<any>,
|
||||||
res: Response
|
res: Response
|
||||||
): Promise<unknown>;
|
): Promise<unknown>;
|
||||||
export async function handleCreateByName(
|
export async function handleCreateByName(
|
||||||
create: { type: "oragnisation" | "group"; data: Organisation | Group },
|
create: { type: "organisation" | "group"; data: Organisation | Group },
|
||||||
link: { type: "event" | "oragnisation"; id: string },
|
link: { type: "event" | "organisation"; id: string },
|
||||||
req: Request<any>,
|
req: Request<any>,
|
||||||
res: Response
|
res: Response
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import { generateError, genericError, handleCreateByName } from "./common";
|
|||||||
const basicGroup = {
|
const basicGroup = {
|
||||||
pid: true,
|
pid: true,
|
||||||
name: true,
|
name: true,
|
||||||
oragnisation: { select: { pid: true, name: true } },
|
organisation: { select: { pid: true, name: true } },
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const _getAllGroups = async (res: Response, organisationId: string | undefined) => {
|
export const _getAllGroups = async (res: Response, organisationId: string | undefined) => {
|
||||||
const groups = await prisma.group.findMany({
|
const groups = await prisma.group.findMany({
|
||||||
where: { oragnisation: { pid: organisationId } },
|
where: { organisation: { pid: organisationId } },
|
||||||
select: basicGroup,
|
select: basicGroup,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
|||||||
const group: {
|
const group: {
|
||||||
pid: string;
|
pid: string;
|
||||||
name: string;
|
name: string;
|
||||||
oragnisation: { pid: string; name: string };
|
organisation: { pid: string; name: string };
|
||||||
admins?: { pid: string; name: string }[];
|
admins?: { pid: string; name: string }[];
|
||||||
participants?: { pid: string }[];
|
participants?: { pid: string }[];
|
||||||
} | null = await prisma.group.findUnique({
|
} | null = await prisma.group.findUnique({
|
||||||
@@ -60,7 +60,7 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
|||||||
? {
|
? {
|
||||||
pid: true,
|
pid: true,
|
||||||
name: true,
|
name: true,
|
||||||
oragnisation: { select: { pid: true, name: true } },
|
organisation: { select: { pid: true, name: true } },
|
||||||
admins: { select: { pid: true, name: true } },
|
admins: { select: { pid: true, name: true } },
|
||||||
participants: { select: { pid: true } },
|
participants: { select: { pid: true } },
|
||||||
}
|
}
|
||||||
@@ -77,8 +77,8 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
|||||||
group: {
|
group: {
|
||||||
...group,
|
...group,
|
||||||
organisation: {
|
organisation: {
|
||||||
...group.oragnisation,
|
...group.organisation,
|
||||||
_links: [{ rel: "self", type: "GET", href: `/api/organisation/${group.oragnisation.pid}` }],
|
_links: [{ rel: "self", type: "GET", href: `/api/organisation/${group.organisation.pid}` }],
|
||||||
},
|
},
|
||||||
...(req.auth?.isAuthenticated
|
...(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) => {
|
export const createGroup = async (req: Request<{ organisationPid: string }, {}, { name?: string }>, res: Response) => {
|
||||||
return handleCreateByName(
|
return handleCreateByName(
|
||||||
{ type: "group", data: { name: req.body.name, level: 1 } },
|
{ type: "group", data: { name: req.body.name, level: 1 } },
|
||||||
{ type: "oragnisation", id: req.params.organisationPid },
|
{ type: "organisation", id: req.params.organisationPid },
|
||||||
req,
|
req,
|
||||||
res
|
res
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ export const createOrganisation = async (
|
|||||||
res: Response
|
res: Response
|
||||||
) => {
|
) => {
|
||||||
return handleCreateByName(
|
return handleCreateByName(
|
||||||
{ type: "oragnisation", data: { name: req.body.name } },
|
{ type: "organisation", data: { name: req.body.name } },
|
||||||
{ type: "event", id: req.params.eventPid },
|
{ type: "event", id: req.params.eventPid },
|
||||||
req,
|
req,
|
||||||
res
|
res
|
||||||
|
|||||||
Reference in New Issue
Block a user