Skip to content

Commit

Permalink
Merge branch 'main' into optional-bebop-logo-on-qr
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirodem authored Dec 6, 2024
2 parents 235e58b + d422955 commit 22d52ff
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
--tagWidget-cta-color: #ffffff;
--tagWidget-color: #000000;
--tagWidget-hyperlink-color: #2271b1;
--order-creditCard-svg-color: #2271b1;
}

@layer base {
Expand Down Expand Up @@ -298,6 +299,9 @@
--tw-prose-bold: inherit;
--tw-prose-links: var(--body-hyperlink-color);
}
.order-creditCard-svg {
color: var(--order-creditCard-svg-color);
}
}

@layer utilities {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/server/runtime-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ const baseConfig = {
removeBebopLogoPOS: false,
contactModes: ['email', 'nostr'],
posTouchTag: [] as Tag['_id'][],
hideCreditCardQrCode: false,
overwriteCreditCardSvgColor: false,
hideCmsZonesOnMobile: false,
copyOrderEmailsToAdmin: true,
usersDarkDefaultTheme: false,
Expand Down
5 changes: 5 additions & 0 deletions src/lib/server/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ export const themeValidator = z.object({
cancel: z.object({ backgroundColor }),
delete: z.object({ backgroundColor })
})
}),
order: z.object({
creditCard: z.object({
svg: z.object({ color })
})
})
});

Expand Down
10 changes: 2 additions & 8 deletions src/lib/types/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,6 @@ export function bitcoinPaymentQrCodeString(
.replaceAll(',', '')}`;
}

export function lightningPaymentQrCodeString(
paymentAddress: string,
paymentAmount: number,
paymentCurrency: Currency
) {
return `lightning:${paymentAddress}?amount=${toBitcoins(paymentAmount, paymentCurrency)
.toLocaleString('en-US', { maximumFractionDigits: 8 })
.replaceAll(',', '')}`;
export function lightningPaymentQrCodeString(paymentAddress: string) {
return `lightning:${paymentAddress}`;
}
9 changes: 9 additions & 0 deletions src/lib/types/Theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ export const themeFormStructure = {
name: 'action.delete.backgroundColor'
}
]
},
order: {
label: 'Order',
elements: [
{
label: 'Credit card svg fill color',
name: 'creditCard.svg.color'
}
]
}
} satisfies {
[key in keyof Omit<ThemeData, 'name'>]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export async function load(event) {
defaultOnLocation: runtimeConfig.defaultOnLocation,
cartPreviewInteractive: runtimeConfig.cartPreviewInteractive,
removeBebopLogoPOS: runtimeConfig.removeBebopLogoPOS
overwriteCreditCardSvgColor: runtimeConfig.overwriteCreditCardSvgColor,
hideCreditCardQrCode: runtimeConfig.hideCreditCardQrCode
};
}

Expand Down Expand Up @@ -93,6 +95,8 @@ export const actions = {
contactModes: z.string().array(),
cartPreviewInteractive: z.boolean({ coerce: true }),
removeBebopLogoPOS: z.boolean({ coerce: true })
hideCreditCardQrCode: z.boolean({ coerce: true }),
overwriteCreditCardSvgColor: z.boolean({ coerce: true })
})
.parse({
...Object.fromEntries(formData),
Expand Down
23 changes: 23 additions & 0 deletions src/routes/(app)/admin[[hash=admin_hash]]/config/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,29 @@
/>
</label>
{/if}
<h2 class="text-2xl">Order</h2>
<label class="checkbox-label">
<input
type="checkbox"
name="hideCreditCardQrCode"
class="form-checkbox"
checked={data.hideCreditCardQrCode}
/>
Don't display order URL qr code on order paid with credit card
</label>
<label class="checkbox-label">
<input
type="checkbox"
name="overwriteCreditCardSvgColor"
class="form-checkbox"
checked={data.overwriteCreditCardSvgColor}
/>
Overwrite credit card payment processor SVG color with custom color
</label>
<p>
Target color can be changed in <a href="/admin/theme" class="underline">theme</a>("Order" then
"Credit card svg fill color" in theme)
</p>
<h2 class="text-2xl">VAT</h2>

<label class="checkbox-label">
Expand Down
5 changes: 4 additions & 1 deletion src/routes/(app)/order/[id]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getPublicS3DownloadLink } from '$lib/server/s3.js';
import { uniqBy } from '$lib/utils/uniqBy.js';
import { paymentMethods } from '$lib/server/payment-methods.js';
import { cmsFromContent } from '$lib/server/cms.js';
import { runtimeConfig } from '$lib/server/runtime-config.js';

export async function load({ params, depends, locals }) {
depends(UrlDependency.Order);
Expand Down Expand Up @@ -75,7 +76,9 @@ export async function load({ params, depends, locals }) {
...(cmsOrderBottom && {
cmsOrderBottom,
cmsOrderBottomData: cmsFromContent({ content: cmsOrderBottom.content }, locals)
})
}),
overwriteCreditCardSvgColor: runtimeConfig.overwriteCreditCardSvgColor,
hideCreditCardQrCode: runtimeConfig.hideCreditCardQrCode
};
}

Expand Down
16 changes: 7 additions & 9 deletions src/routes/(app)/order/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@
>
<span>{t('order.paymentLink')}</span>
{#if payment.processor === 'sumup'}
<IconSumupWide class="h-12" />
<IconSumupWide
class="h-12 {data.overwriteCreditCardSvgColor
? 'order-creditCard-svg'
: ''} "
/>
{:else if payment.processor === 'stripe'}
<IconStripe class="h-12" />
{:else if payment.processor === 'paypal'}
Expand Down Expand Up @@ -280,21 +284,15 @@

{#if payment.status === 'pending'}
{#if payment.method === 'lightning'}
<a
href={lightningPaymentQrCodeString(
payment.address ?? '',
payment.price.amount,
payment.price.currency
)}
>
<a href={lightningPaymentQrCodeString(payment.address ?? '')}>
<img
src="{$page.url.pathname}/payment/{payment.id}/qrcode"
class="w-96 h-96"
alt="QR code"
/></a
>
{/if}
{#if payment.method === 'card'}
{#if payment.method === 'card' && !data.hideCreditCardQrCode}
<img
src="{$page.url.pathname}/payment/{payment.id}/qrcode"
class="w-96 h-96"
Expand Down

0 comments on commit 22d52ff

Please sign in to comment.