diff --git a/.drone.yaml b/.drone.yaml index fbe1edd..f4dc8e3 100644 --- a/.drone.yaml +++ b/.drone.yaml @@ -13,6 +13,8 @@ steps: environment: TOKEN: from_secret: registry_token + VITE_FOOTER_NOTE_1: "LNVPS is a trading name of Apex Strata Ltd, a company registered in Ireland." + VITE_FOOTER_NOTE_2: "Comany Number: 702423, Address: Suite 10628, 26/27 Upper Pembroke Street, Dublin 2, D02 X361, Ireland" commands: - dockerd & - docker login -u registry -p $TOKEN registry.v0l.io diff --git a/.env b/.env index 225fca9..049dc5e 100644 --- a/.env +++ b/.env @@ -1 +1,3 @@ -VITE_API_URL="https://api.lnvps.net" \ No newline at end of file +VITE_API_URL="https://api.lnvps.net" +VITE_FOOTER_NOTE_1="" +VITE_FOOTER_NOTE_2="" \ No newline at end of file diff --git a/src/components/cost.tsx b/src/components/cost.tsx index 640685f..884aeae 100644 --- a/src/components/cost.tsx +++ b/src/components/cost.tsx @@ -1,41 +1,57 @@ +import useLogin from "../hooks/login"; + interface Price { currency: string; amount: number; } -type Cost = Price & { interval_type?: string; other_price?: Array }; +type Cost = Price & { interval_type?: string }; -export default function CostLabel({ - cost, - converted, -}: { - cost: Cost; - converted?: boolean; -}) { - function intervalName(n: string) { - switch (n) { - case "day": - return "Day"; - case "month": - return "Month"; - case "year": - return "Year"; +export default function CostLabel({ cost }: { cost: Cost & { other_price?: Array } }) { + const login = useLogin(); + + if (cost.currency === login?.currency) { + return + } else { + const converted_price = cost.other_price?.find((p) => p.currency === login?.currency); + if (converted_price) { + return
+ + +
+ } else { + return } } +} +function intervalName(n: string) { + switch (n) { + case "day": + return "Day"; + case "month": + return "Month"; + case "year": + return "Year"; + } +} + +export function CostAmount({ cost, converted, className }: { cost: Cost, converted: boolean, className?: string }) { + const formatter = new Intl.NumberFormat('en-US', { + style: 'currency', + currency: cost.currency, + trailingZeroDisplay: 'stripIfInteger' + }); return ( -
+
{converted && "~"} {cost.currency !== "BTC" - ? cost.amount.toFixed(2) - : Math.floor(cost.amount * 1e8).toLocaleString()}{" "} - {cost.currency === "BTC" ? "sats" : cost.currency} + ? formatter.format(cost.amount) + : Math.floor(cost.amount * 1e8).toLocaleString()} + {cost.currency === "BTC" && " sats"} {cost.interval_type && <>/{intervalName(cost.interval_type)}} - {cost.other_price && - cost.other_price.map((a) => ( -
- -
- ))}
); -} +} \ No newline at end of file diff --git a/src/components/modal.tsx b/src/components/modal.tsx index 3614e8c..2d7cc2e 100644 --- a/src/components/modal.tsx +++ b/src/components/modal.tsx @@ -51,7 +51,7 @@ export default function Modal(props: ModalProps) { className={ props.bodyClassName ?? classNames( - "relative bg-neutral-700 p-8 transition max-xl:rounded-t-3xl xl:rounded-3xl max-xl:mt-auto xl:my-auto max-lg:w-full", + "relative bg-neutral-700 p-8 transition max-xl:rounded-t-3xl lg:rounded-3xl max-xl:mt-auto lg:my-auto max-lg:w-full", { "max-xl:-translate-y-[calc(100vh-100dvh)]": props.ready ?? true, "max-xl:translate-y-[50vh]": !(props.ready ?? true), diff --git a/src/components/vps-card.tsx b/src/components/vps-card.tsx index 8a844e9..9c7f22e 100644 --- a/src/components/vps-card.tsx +++ b/src/components/vps-card.tsx @@ -5,10 +5,12 @@ import VpsPayButton from "./pay-button"; export default function VpsCard({ spec }: { spec: VmTemplate }) { return ( -
-

{spec.name}

+
+
{spec.name}
    -
  • CPU: {spec.cpu}vCPU
  • +
  • + CPU: {spec.cpu}vCPU +
  • RAM:
  • @@ -17,7 +19,7 @@ export default function VpsCard({ spec }: { spec: VmTemplate }) {
  • Location: {spec.region?.name}
-

{spec.cost_plan && }

+
{spec.cost_plan && }
); diff --git a/src/hooks/login.tsx b/src/hooks/login.tsx index fa05410..9fee2ff 100644 --- a/src/hooks/login.tsx +++ b/src/hooks/login.tsx @@ -1,5 +1,5 @@ import { useContext, useMemo, useSyncExternalStore } from "react"; -import { LoginState } from "../login"; +import { LoginSession, LoginState } from "../login"; import { SnortContext } from "@snort/system-react"; import { LNVpsApi } from "../api"; import { ApiUrl } from "../const"; @@ -14,12 +14,14 @@ export default function useLogin() { () => session ? { - type: session.type, - publicKey: session.publicKey, - system, - api: new LNVpsApi(ApiUrl, LoginState.getSigner()), - logout: () => LoginState.logout(), - } + type: session.type, + publicKey: session.publicKey, + system, + currency: session.currency, + api: new LNVpsApi(ApiUrl, LoginState.getSigner()), + update: (fx: (ses: LoginSession) => void) => LoginState.updateSession(fx), + logout: () => LoginState.logout(), + } : undefined, [session, system], ); diff --git a/src/login.ts b/src/login.ts index 7687d90..c8eb294 100644 --- a/src/login.ts +++ b/src/login.ts @@ -11,6 +11,7 @@ export interface LoginSession { publicKey: string; privateKey?: string; bunker?: string; + currency: string; } class LoginStore extends ExternalStore { #session?: LoginSession; @@ -42,6 +43,7 @@ class LoginStore extends ExternalStore { this.#session = { type: type ?? "nip7", publicKey: pubkey, + currency: "EUR" }; this.#save(); } @@ -52,6 +54,7 @@ class LoginStore extends ExternalStore { type: "nsec", publicKey: s.getPubKey(), privateKey: key, + currency: "EUR" }; this.#save(); } @@ -62,6 +65,7 @@ class LoginStore extends ExternalStore { publicKey: remotePubkey, privateKey: localKey, bunker: url, + currency: "EUR" }; this.#save(); } @@ -99,6 +103,13 @@ class LoginStore extends ExternalStore { throw "Signer not setup!"; } + updateSession(fx: (s: LoginSession) => void) { + if (this.#session) { + fx(this.#session); + this.#save(); + } + } + #save() { if (this.#session) { window.localStorage.setItem("session", JSON.stringify(this.#session)); diff --git a/src/pages/home.tsx b/src/pages/home.tsx index 0cd6fd0..9d9862a 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -7,8 +7,10 @@ import { VpsCustomOrder } from "../components/vps-custom"; import { LatestNews } from "../components/latest-news"; import { FilterButton } from "../components/button-filter"; import { dedupe } from "@snort/shared"; +import useLogin from "../hooks/login"; export default function HomePage() { + const login = useLogin(); const [offers, setOffers] = useState(); const [region, setRegion] = useState>([]); @@ -66,7 +68,7 @@ export default function HomePage() { All VPS come with 1x IPv4 and 1x IPv6 address and unmetered traffic, all prices are excluding taxes. -
+
PGP {" | "} @@ -91,12 +93,19 @@ export default function HomePage() { Speedtest
-
- LNVPS is a trading name of Apex Strata Ltd, a company registered in - Ireland. -
- Comany Number: 702423, Address: Suite 10628, 26/27 Upper Pembroke - Street, Dublin 2, D02 X361, Ireland + {import.meta.env.VITE_FOOTER_NOTE_1 &&
+ {import.meta.env.VITE_FOOTER_NOTE_1} +
} + {import.meta.env.VITE_FOOTER_NOTE_2 &&
+ {import.meta.env.VITE_FOOTER_NOTE_2} +
} +
+ Currency: + {" "} +