added Model Box and Item

added Box function for admin
This commit is contained in:
2026-03-09 10:04:38 +07:00
parent 4f2f5b5694
commit c2981ed7d8
35 changed files with 1284 additions and 241 deletions

View File

@@ -11,6 +11,7 @@ import {
baseHouse,
houseCreateBESchema,
houseEditBESchema,
houseForSelectSchema,
houseListSchema,
invitationCreateBESchema,
removeMemberSchema,
@@ -115,6 +116,39 @@ export const getCurrentUserHouses = createServerFn({ method: 'GET' })
}
});
export const getHouseForSelect = createServerFn({ method: 'GET' })
.middleware([authMiddleware])
.inputValidator(houseForSelectSchema)
.handler(async ({ data }) => {
try {
const result = await prisma.house.findMany({
where: {
OR: [
{
name: {
contains: data.keyword,
mode: 'insensitive',
},
},
],
},
select: {
id: true,
name: true,
color: true,
},
orderBy: { createdAt: 'desc' },
take: 5,
});
return result;
} catch (error) {
console.error(error);
const { message, code } = parseError(error);
throw { message, code };
}
});
export const createHouse = createServerFn({ method: 'POST' })
.middleware([authMiddleware])
.inputValidator(houseCreateBESchema)