Skip to content

Commit

Permalink
disclaimer page
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-whitaker committed Dec 14, 2024
1 parent 840ce3f commit c0a9a03
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/app/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NEXT_PUBLIC_WWW_URL=/
NEXT_PUBLIC_WWW_URL=
NEXT_PUBLIC_DEV_TOOLS=true
31 changes: 21 additions & 10 deletions packages/app/src/actions/_updateShopping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {Currencies, Units} from "@brewdocs.beer/core";
import {groupBy} from "lodash";
import Hop from "@/model/hop";
import {parseNumberString} from "@/utils/math";
import Grain from "@/model/grain";

export default function _updateShopping(batch: Batch): Batch {
(batch as Batch).shopping = [
{
name: "Hops",
// Hops are summed by varietal
items: ((): ShoppingListItem[] => {
const groups: Record<string, Hop[]> = groupBy(batch.hops, "name");
return Object.keys(groups).map(hopName => {
Expand All @@ -31,15 +31,26 @@ export default function _updateShopping(batch: Batch): Batch {
},
{
name: "Grain",
items: batch.grains.map(({ name, weight: scalar }) => ({
name,
scalar,
purchased: false,
cost: {
value: "$0.00",
currency: Currencies.DOLLAR
}
}))
items: (() => {
const groups: Record<string, Grain[]> = groupBy(batch.grains, "name");
return Object.keys(groups).map(grainName => {
const unit = parseNumberString(groups[grainName][0].weight.value)[1];
const weight = groups[grainName].reduce((m, v) => m + parseNumberString(v.weight.value)[0], 0.0);

return {
name: grainName,
purchased: false,
cost: {
value: "$0.00",
currency: Currencies.DOLLAR
},
scalar: {
value: `${weight}${unit}`,
unit: Units.PERCENT
}
}
})
})(),
},
{
name: "Yeast",
Expand Down
1 change: 0 additions & 1 deletion packages/app/src/actions/createBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default async function createBatch(recipe: Recipe, inputs: CreateBatchSta
status: Statuses.PREP,
recipeId: recipe.id,

// Clone the "guts" of the recipes
hops: cloneDeep(recipe.hops),
grains: cloneDeep(recipe.grains),
yeast: cloneDeep(recipe.yeast),
Expand Down
5 changes: 3 additions & 2 deletions packages/app/src/app/disclaimer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
export default function DisclaimerPage() {
return (
<div className="max-w-md p-5">
<h1 className="font-bold mb-2">Disclaimer</h1>
<p>BrewDocs is currently in an early prototyping phase, and thus is not considered stable.</p>
<h1 className="font-bold mb-2 text-2xl">Disclaimer</h1>
<p>BrewDocs is currently in an early prototyping phase, and thus is not considered stable. It is mostly deployed for demo purposes.</p>
<div className="divider divider-secondary"></div>
<p>If you run into issues with, you can add <code className="bg-gray-200 whitespace-nowrap">?purge=true</code> to the URL to clear your db and cache.</p>
</div>
);
}
1 change: 1 addition & 0 deletions packages/app/src/data/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {WWW_URL} from "@/utils/env";

const nav: [string, string?][] = [
["About", `${WWW_URL}/about`],
["Disclaimer", "/disclaimer"],
["------------------------------"],
// ["Dashboard", "/"],
["Batches", "/batches"],
Expand Down
4 changes: 1 addition & 3 deletions packages/kb/src/importResource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export type Resources = "hops"|"grains"|"yeasts"|"recipes";

async function importResource<T>(resource: Resources): Promise<T[]|null> {
async function importResource<T>(resource: "hops"|"grains"|"yeasts"|"recipes"): Promise<T[]|null> {
try {
switch (resource) {
case "recipes":
Expand Down

0 comments on commit c0a9a03

Please sign in to comment.