Skip to content

Commit

Permalink
🦋 Allow admin to set a QR-code-less order on their be-BOP #1621
Browse files Browse the repository at this point in the history
  • Loading branch information
ithiame committed Dec 4, 2024
1 parent b11a8ef commit 9ce1b33
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 4 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);
}
.credit-card-svg-fill {
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'][],
hideCbQrCode: false,
overwriteCbSvgColor: 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,
overwriteCbSvgColor: runtimeConfig.overwriteCbSvgColor,
hideCbQrCode: runtimeConfig.hideCbQrCode
};
}

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 }),
hideCbQrCode: z.boolean({ coerce: true }),
overwriteCbSvgColor: z.boolean({ coerce: true })
})
.parse({
...Object.fromEntries(formData),
Expand Down
18 changes: 18 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,24 @@
/>
</label>
{/if}
<h2 class="text-2xl">Order</h2>
<label class="checkbox-label">
<input type="checkbox" name="hideCbQrCode" class="form-checkbox" checked={data.hideCbQrCode} />
Don't display order URL qr code on order paid with credit card
</label>
<label class="checkbox-label">
<input
type="checkbox"
name="overwriteCbSvgColor"
class="form-checkbox"
checked={data.overwriteCbSvgColor}
/>
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)
})
}),
overwriteCbSvgColor: runtimeConfig.overwriteCbSvgColor,
hideCbQrCode: runtimeConfig.hideCbQrCode
};
}

Expand Down
4 changes: 3 additions & 1 deletion src/routes/(app)/order/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@
>
<span>{t('order.paymentLink')}</span>
{#if payment.processor === 'sumup'}
<IconSumupWide class="h-12" />
<IconSumupWide
class="h-12 {data.overwriteCbSvgColor ? 'credit-card-svg-fill' : ''} "
/>
{:else if payment.processor === 'stripe'}
<IconStripe class="h-12" />
{:else if payment.processor === 'paypal'}
Expand Down

0 comments on commit 9ce1b33

Please sign in to comment.