Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🦋 Allow admin to set a QR-code-less order on their be-BOP #1621 #1624

Merged
merged 7 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -181,6 +181,8 @@ const baseConfig = {
],
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
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 @@ -35,7 +35,9 @@ export async function load(event) {
copyOrderEmailsToAdmin: runtimeConfig.copyOrderEmailsToAdmin,
disableLanguageSelector: runtimeConfig.disableLanguageSelector,
defaultOnLocation: runtimeConfig.defaultOnLocation,
cartPreviewInteractive: runtimeConfig.cartPreviewInteractive
cartPreviewInteractive: runtimeConfig.cartPreviewInteractive,
overwriteCreditCardSvgColor: runtimeConfig.overwriteCreditCardSvgColor,
hideCreditCardQrCode: runtimeConfig.hideCreditCardQrCode
};
}

Expand Down Expand Up @@ -90,7 +92,9 @@ export const actions = {
cartMaxSeparateItems: z.number({ coerce: true }).int().default(0),
disableLanguageSelector: z.boolean({ coerce: true }),
contactModes: z.string().array(),
cartPreviewInteractive: z.boolean({ coerce: true })
cartPreviewInteractive: 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 @@ -218,6 +218,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
8 changes: 6 additions & 2 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 @@ -294,7 +298,7 @@
/></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
Loading