Skip to content

Commit ece7312

Browse files
chore!: add deprecation notice
1 parent d9524b9 commit ece7312

File tree

31 files changed

+27
-2435
lines changed

31 files changed

+27
-2435
lines changed

src/app/(home)/page.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Link from "next/link";
22
import { BeanconquerorUsp } from "@/components/home/usp";
3+
import {Alert, AlertDescription, AlertTitle} from "@/components/ui/alert";
34

45
function WrappedLink() {
56
return (
@@ -18,6 +19,21 @@ function WrappedLink() {
1819
);
1920
}
2021

22+
function DBDeprecationNotice() {
23+
return (
24+
<Alert variant={"destructive"}>
25+
<AlertTitle>Database deprecation</AlertTitle>
26+
<AlertDescription>
27+
A change in the pricing strategy of the database provider increased the costs of hosting Beanstats by several
28+
hundreds of dollars, making it impossible to keep providing the database related functionalities of Beanstats free of charge.
29+
Therefor these functionalities had to be removed from Beanstats.
30+
31+
Contact me if you need an export of your data.
32+
</AlertDescription>
33+
</Alert>
34+
)
35+
}
36+
2137
export default function Home() {
2238
return (
2339
<div className={"flex flex-col items-center"}>
@@ -35,6 +51,7 @@ export default function Home() {
3551
Beanstats extends Beanconqueror and makes it easy to enter data,
3652
visualise data and share bean entries
3753
</p>
54+
<DBDeprecationNotice />
3855
<BeanconquerorUsp />
3956
</section>
4057
</div>

src/components/beanconqueror/share/view/shared-bean.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ const GeneralTabsContent = ({ decoded }: { decoded: BeanProto }) => (
5454
/>
5555
)}
5656
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */}
57-
<LabelledValue
58-
type={"rating"}
59-
label={"Roast range"}
60-
value={decoded.roastRange}
57+
<LabelledValue type={"rating"} label={"Roast range"} value={decoded.roastRange}
6158
/>
6259
<LabelledValue
6360
type={"string"}
@@ -86,10 +83,7 @@ const GeneralTabsContent = ({ decoded }: { decoded: BeanProto }) => (
8683
<CardContent>
8784
<div className={"grid grid-cols-1 md:grid-cols-2 gap-2"}>
8885
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */}
89-
<LabelledValue
90-
type={"number"}
91-
label={"Weight"}
92-
value={decoded.weight}
86+
<LabelledValue type={"number"} label={"Weight"} value={decoded.weight}
9387
/>
9488
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */}
9589
<LabelledValue type={"number"} label={"Cost"} value={decoded.cost} />

src/components/coffee/share.tsx

Lines changed: 6 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,19 @@
11
"use client";
22

33
import dynamic from "next/dynamic";
4-
import {
5-
Drawer,
6-
DrawerClose,
7-
DrawerContent,
8-
DrawerDescription,
9-
DrawerFooter,
10-
DrawerHeader,
11-
DrawerTitle,
12-
DrawerTrigger,
13-
} from "@/components/ui/drawer";
14-
import { Button, buttonVariants } from "@/components/ui/button";
15-
import { type SelectBean } from "@/lib/db/beans/get-bean-details";
16-
import { createUrlFromFormSchema } from "@/lib/beanconqueror/proto/proto-helpers";
17-
import { type beanInformationFormSchema } from "@/lib/beanconqueror/validations/bean-information-form-schema";
4+
5+
import { Button } from "@/components/ui/button";
186
import { useState } from "react";
19-
import { getBeankLink } from "@/lib/beanlink";
7+
import { getBeanLink } from "@/lib/beanlink";
208
import CopyContainer from "@/components/copy-container";
21-
import { useMediaQuery } from "@/lib/hooks";
22-
import {
23-
Dialog,
24-
DialogContent,
25-
DialogDescription,
26-
DialogHeader,
27-
DialogTitle,
28-
DialogTrigger,
29-
} from "@/components/ui/dialog";
30-
import { getShortShareLink } from "@/lib/share/actions";
9+
3110
import { useToast } from "@/components/ui/use-toast";
3211

3312
const QRCode = dynamic(
3413
() => import("@/components/qrcode-card").then((module) => module.QRCode),
3514
{ ssr: false },
3615
);
3716

38-
type BeanDetails = Awaited<SelectBean>;
39-
type Varieties = BeanDetails["varieties"];
40-
4117
/**
4218
* Maps the length value to a BeanMix value, where
4319
* 0 is unknown, 1 is single origin and 2 is a blend
@@ -51,55 +27,6 @@ function getBeanMix(
5127
return "SINGLE_ORIGIN";
5228
}
5329

54-
/**
55-
* Map varieties to bean information schema
56-
* @param varieties
57-
*/
58-
function getVarietyInformation(
59-
varieties: Varieties,
60-
): beanInformationFormSchema["varietyInformation"] {
61-
if (varieties.length === 0) {
62-
return undefined;
63-
}
64-
65-
return varieties.map((variety) => ({
66-
variety: variety.name ?? undefined,
67-
country: variety.country ?? undefined,
68-
region: variety.region ?? undefined,
69-
farm: variety.farm ?? undefined,
70-
farmer: variety.farmer ?? undefined,
71-
elevation: variety.elevation ?? undefined,
72-
processing: variety.processing ?? undefined,
73-
}));
74-
}
75-
76-
/**
77-
* Create bean information scheme from provided BeanDetails
78-
* @param bean
79-
*/
80-
function createBeanInformationSchema(
81-
bean: BeanDetails,
82-
): beanInformationFormSchema | null {
83-
if (bean === undefined) return null;
84-
85-
return {
86-
coffeeName: bean.name,
87-
roaster: bean.roaster.name,
88-
roastingDate: bean.roastDate ? new Date(bean.roastDate) : undefined,
89-
// beanRoastingType: NOT IMPLEMENTED
90-
// degreeOfRoast: NOT IMPLEMENTED
91-
// roast: NOT IMPLEMENTED
92-
beanMix: getBeanMix(bean.varieties.length),
93-
weight: bean.weight ?? undefined,
94-
cost: bean.price ?? undefined,
95-
// flavourProfile: // TODO: add this to the frontend
96-
// cuppingPoints: NOT IMPLEMENTED
97-
// decaffeinated: bean.isDecaf // TODO: add this too
98-
notes: bean.notes ?? undefined,
99-
varietyInformation: getVarietyInformation(bean.varieties),
100-
};
101-
}
102-
10330
/**
10431
* Represents a section where the Beanconqueror QR code can be rendered
10532
* @param url
@@ -111,8 +38,8 @@ function QRCodeSection({ url }: { url: string }) {
11138

11239
const onButtonClick = async () => {
11340
try {
114-
const beanlink = await getBeankLink(url);
115-
setShareUrl(beanlink);
41+
const beanlink = await getBeanLink(url);
42+
setShareUrl(beanlink.link);
11643
setShow(true);
11744
toast({
11845
title: "Success",
@@ -142,96 +69,3 @@ function QRCodeSection({ url }: { url: string }) {
14269
</>
14370
);
14471
}
145-
146-
/**
147-
* Container for all the share options
148-
* @param bean
149-
* @constructor
150-
*/
151-
function ShareContainer({ bean }: { bean: BeanDetails }) {
152-
const values = createBeanInformationSchema(bean);
153-
154-
if (!values) {
155-
return null;
156-
}
157-
158-
const shareUrl = createUrlFromFormSchema(values);
159-
const beanstatsText = bean.isPublic
160-
? "This coffee is set to public, so the url can be shared with others."
161-
: "To share this coffee via its url, you have to set it to 'public'.";
162-
163-
return (
164-
<div className={"divide-y space-y-4 max-w-xl"}>
165-
<section className={"space-y-2"}>
166-
<h3 className={"font-semibold mb-1"}>Share via Beanstats link</h3>
167-
<div className={"text-sm text-muted-foreground"}>{beanstatsText}</div>
168-
{bean.isPublic && (
169-
<CopyContainer
170-
value={window.location.toString()}
171-
displayValue={"Copy url"}
172-
/>
173-
)}
174-
</section>
175-
<section className={"space-y-2"}>
176-
<h3 className={"font-semibold mb-1"}>Share with Beanconqueror</h3>
177-
<QRCodeSection url={shareUrl} />
178-
</section>
179-
</div>
180-
);
181-
}
182-
183-
/**
184-
* Share component which renders a shareable link (if public) and the beanconqueror import QR Code
185-
* @param bean
186-
* @constructor
187-
*/
188-
export function ShareComponent({ bean }: { bean: BeanDetails }) {
189-
const [open, setOpen] = useState<boolean>(false);
190-
const isDesktop = useMediaQuery("(min-width: 768px)");
191-
192-
if (bean === null) {
193-
return null;
194-
}
195-
196-
if (isDesktop) {
197-
return (
198-
<Dialog open={open} onOpenChange={setOpen}>
199-
<DialogTrigger asChild>
200-
<Button variant={"outline"} size={"sm"}>
201-
Share
202-
</Button>
203-
</DialogTrigger>
204-
<DialogContent className={"sm:max-w-[425px]"}>
205-
<DialogHeader>
206-
<DialogTitle>Share</DialogTitle>
207-
<DialogDescription>Share this coffee.</DialogDescription>
208-
</DialogHeader>
209-
<ShareContainer bean={bean} />
210-
</DialogContent>
211-
</Dialog>
212-
);
213-
}
214-
215-
return (
216-
<Drawer open={open} onOpenChange={setOpen}>
217-
<DrawerTrigger
218-
className={buttonVariants({ variant: "outline", size: "sm" })}
219-
>
220-
Share
221-
</DrawerTrigger>
222-
<DrawerContent>
223-
<DrawerHeader className={"max-w-xl"}>
224-
<DrawerTitle>Share</DrawerTitle>
225-
<DrawerDescription>Share this coffee.</DrawerDescription>
226-
</DrawerHeader>
227-
<DrawerFooter className={"max-w-xl mx-auto"}>
228-
<ShareContainer bean={bean} />
229-
<DrawerClose className={"self-end"}>
230-
<Button variant="outline">Cancel</Button>
231-
</DrawerClose>
232-
</DrawerFooter>
233-
</DrawerContent>
234-
</Drawer>
235-
);
236-
}
237-

src/components/detail-pages/bean-detail.tsx

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)