2026-04-29 23:05:27 +12:00
|
|
|
<script lang="ts">
|
2026-05-08 23:07:01 +12:00
|
|
|
import { api } from '$lib/api';
|
|
|
|
|
import MixCalculatorPrintDocument from '$lib/components/MixCalculatorPrintDocument.svelte';
|
2026-04-29 23:05:27 +12:00
|
|
|
import type { MixCalculatorSession } from '$lib/types';
|
|
|
|
|
|
|
|
|
|
let { session }: { session: MixCalculatorSession } = $props();
|
|
|
|
|
|
|
|
|
|
const printableTitle = $derived(
|
|
|
|
|
`MixCalculator_${session.client_name}_${session.product_name}_${session.mix_date}_${session.session_number}`.replace(/[^\w.-]+/g, '_')
|
|
|
|
|
);
|
2026-05-08 23:07:01 +12:00
|
|
|
|
|
|
|
|
async function downloadPdf() {
|
|
|
|
|
const blob = await api.mixCalculatorSessionPdf(session.id);
|
|
|
|
|
const url = URL.createObjectURL(blob);
|
|
|
|
|
const anchor = document.createElement('a');
|
|
|
|
|
anchor.href = url;
|
|
|
|
|
anchor.download = `${printableTitle}.pdf`;
|
|
|
|
|
document.body.appendChild(anchor);
|
|
|
|
|
anchor.click();
|
|
|
|
|
anchor.remove();
|
|
|
|
|
URL.revokeObjectURL(url);
|
|
|
|
|
}
|
2026-04-29 23:05:27 +12:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<svelte:head>
|
|
|
|
|
<title>{printableTitle}</title>
|
|
|
|
|
</svelte:head>
|
|
|
|
|
|
|
|
|
|
<section class="print-page">
|
|
|
|
|
<div class="print-toolbar">
|
|
|
|
|
<a class="secondary-button" href={`/mix-calculator/${session.id}`}>Back to session</a>
|
2026-05-08 23:07:01 +12:00
|
|
|
<button class="secondary-button" type="button" onclick={downloadPdf}>Download PDF</button>
|
2026-04-29 23:05:27 +12:00
|
|
|
<button class="primary-button" type="button" onclick={() => window.print()}>Print / Save PDF</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-05-08 23:07:01 +12:00
|
|
|
<MixCalculatorPrintDocument session={session} generatedAt={new Date().toISOString()} />
|
2026-04-29 23:05:27 +12:00
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.print-page {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 1rem;
|
2026-05-08 23:07:01 +12:00
|
|
|
justify-items: center;
|
|
|
|
|
padding: 1.5rem 1rem 2.5rem;
|
|
|
|
|
background:
|
|
|
|
|
linear-gradient(180deg, #eef4f0 0%, #e6eee9 100%);
|
2026-04-29 23:05:27 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.print-toolbar {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
gap: 0.75rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.primary-button,
|
|
|
|
|
.secondary-button {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
padding: 0.78rem 0.96rem;
|
|
|
|
|
border-radius: 0.9rem;
|
|
|
|
|
border: 1px solid var(--line-strong);
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.primary-button {
|
|
|
|
|
border: none;
|
2026-05-08 09:06:14 +12:00
|
|
|
background: var(--color-brand);
|
2026-04-29 23:05:27 +12:00
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.secondary-button {
|
|
|
|
|
background: #fff;
|
|
|
|
|
color: #304038;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 900px) {
|
2026-05-08 23:07:01 +12:00
|
|
|
.print-toolbar {
|
|
|
|
|
justify-content: stretch;
|
2026-04-29 23:05:27 +12:00
|
|
|
}
|
|
|
|
|
|
2026-05-08 23:07:01 +12:00
|
|
|
.print-toolbar > :global(*) {
|
|
|
|
|
flex: 1 1 auto;
|
2026-04-29 23:05:27 +12:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media print {
|
|
|
|
|
:global(body) {
|
|
|
|
|
background: #fff;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 23:07:01 +12:00
|
|
|
.print-page {
|
|
|
|
|
padding: 0;
|
|
|
|
|
background: #fff;
|
2026-04-29 23:05:27 +12:00
|
|
|
}
|
|
|
|
|
|
2026-05-08 23:07:01 +12:00
|
|
|
.print-toolbar {
|
|
|
|
|
display: none;
|
2026-04-29 23:05:27 +12:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|