Skip to content

Commit

Permalink
feat: Improved the calculation page, added recommandations for ingred…
Browse files Browse the repository at this point in the history
…ients, made prices optional (#163)

* Changed calculation layout

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* Added showSales option to hide the sales columns

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* Added full bottle column at the shopping list

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* Changed calculation layout

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* Added showSales option to hide the sales columns

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* Added full bottle column at the shopping list

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* chore: Format project

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* chore: Project settings

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* feat: Added (incorrect) algorithm to calculate the recommended ingredients to fit to one ingredient

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* fix: Fixed algorithm, added modal to adjust the planned amounts

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* Added migration

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

* feat: Fixed calculation of recommended ingredients

Signed-off-by: Johannes Groß <mail@gross-johannes.de>

---------

Signed-off-by: Johannes Groß <mail@gross-johannes.de>
  • Loading branch information
jo-gross authored Feb 23, 2024
1 parent 6638820 commit 78194eb
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "CocktailCalculation"
ADD COLUMN "showSalesStuff" BOOLEAN NOT NULL DEFAULT true;
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export default withHttpMethods({
[HTTPMethod.PUT]: withWorkspacePermission([Role.USER], async (req: NextApiRequest, res: NextApiResponse, user, workspace) => {
const calculationId = req.query.calculationId as string | undefined;
if (!calculationId) return res.status(400).json({ message: 'No calculationId id' });

const { name, calculationItems } = req.body;
const { name, calculationItems, showSalesStuff } = req.body;
const input: CocktailCalculationUpdateInput = {
id: calculationId,
name: name,
showSalesStuff: showSalesStuff,
updatedByUser: {
connect: {
id: user.id,
Expand Down
3 changes: 2 additions & 1 deletion pages/api/workspaces/[workspaceId]/calculations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ export default withHttpMethods({
return res.json({ data: cocktailCalculations });
}),
[HTTPMethod.POST]: withWorkspacePermission([Role.USER], async (req: NextApiRequest, res: NextApiResponse, user, workspace) => {
const { name, calculationItems } = req.body;
const { name, calculationItems, showSalesStuff } = req.body;
const input: CocktailCalculationCreateInput = {
name: name,
showSalesStuff: showSalesStuff,
cocktailCalculationItems: {
create: calculationItems.map((item: any) => ({
plannedAmount: item.plannedAmount,
Expand Down
398 changes: 309 additions & 89 deletions pages/workspaces/[workspaceId]/manage/calculations/[id].tsx

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions pages/workspaces/[workspaceId]/manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export default function ManagePage() {
)
}
actions={[
<div key={'profile'} className="dropdown dropdown-end rounded-xl border border-none border-base-200 md:border-solid">
<label tabIndex={0} className="btn btn-ghost">
<div key={'profile'} className="dropdown dropdown-end">
<label tabIndex={0} className="btn btn-outline">
<>
{userContext.user?.image ? (
<div className="avatar">
Expand All @@ -49,7 +49,7 @@ export default function ManagePage() {
</div>
) : (
<div className="avatar placeholder">
<div className="bg-neutral-focus w-8 rounded-full text-neutral-content">
<div className="rounded-full border bg-neutral p-2 text-neutral-content">
<span className="text-xs">
{userContext.user?.name
?.split(' ')
Expand All @@ -65,9 +65,10 @@ export default function ManagePage() {
<ul tabIndex={0} className="menu dropdown-content menu-sm z-[1] mt-2 w-52 gap-2 rounded-box border border-base-200 bg-base-100 p-2 shadow">
<div className={'pt-1 text-center text-lg font-bold md:hidden'}>{userContext.user?.name}</div>
<div className={'divider-sm md:hidden'}></div>
<li className={'btn btn-outline btn-sm'}>
<Link href={'/'}>Workspaces</Link>
</li>
<Link href={'/'} className={'btn btn-outline btn-sm'}>
Workspaces
</Link>

<div className={'divider-sm'}></div>
<button
className={'btn btn-outline btn-error btn-sm'}
Expand Down
2 changes: 2 additions & 0 deletions schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ model CocktailCalculation {
id String @id @default(cuid())
name String
showSalesStuff Boolean @default(true)
workspaceId String
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
updatedByUserId String
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8649,11 +8649,11 @@ __metadata:

"typescript@patch:typescript@5.3.3#~builtin<compat/typescript>":
version: 5.3.3
resolution: "typescript@patch:typescript@npm%3A5.3.3#~builtin<compat/typescript>::version=5.3.3&hash=e012d7"
resolution: "typescript@patch:typescript@npm%3A5.3.3#~builtin<compat/typescript>::version=5.3.3&hash=1f5320"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 4e604a9e107ce0c23b16a2f8d79d0531d4d8fe9ebbb7a8c395c66998c39892f0e0a071ef0b0d4e66420a8ec2b8d6cfd9cdb29ba24f25b37cba072e9282376df9
checksum: f61375590b3162599f0f0d5b8737877ac0a7bc52761dbb585d67e7b8753a3a4c42d9a554c4cc929f591ffcf3a2b0602f65ae3ce74714fd5652623a816862b610
languageName: node
linkType: hard

Expand Down

0 comments on commit 78194eb

Please sign in to comment.