35
loading...
This website collects cookies to deliver better user experience
npx create-remix@latest
useEffect
hook I could get them easily to not server render. export const loader: LoaderFunction = async () => {
const materials: MaterialPick[] = await db.material.findMany({
select: {
id: true,
name: true,
absorbtionLevels: true,
attributes: true,
absorberClass: true,
description: true,
physicalMaterial: {
select: {
name: true,
},
},
materialType: {
select: {
name: true,
},
},
},
orderBy: [
{
name: "asc",
},
],
});
return json(
materials.map(
(material) => {
const jsonData = material.absorbtionLevels as Prisma.JsonArray;
const attr = material.attributes as Prisma.JsonArray;
return {
...material,
absorbtionLevels: jsonData.map((a) => {
const obj = a as Prisma.JsonObject;
const absorbtion = obj["absorbtion"] as number;
const frequency = obj["frequency"] as Frequency;
return { absorbtion, frequency };
}),
attributes: attr,
};
}
)
);
};