Skip to content

Commit

Permalink
Merge pull request #449 from significa/significa/proposal-changes
Browse files Browse the repository at this point in the history
feat: add version covers and remove rounding in proposal duration
  • Loading branch information
nunopolonia authored Feb 13, 2025
2 parents c68cd4b + f073ca5 commit b517d88
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
12 changes: 10 additions & 2 deletions src/components/proposals/proposal-hero.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import { t } from '$lib/i18n';
import { getImageAttributes } from '$lib/utils/cms';
import { formatDate } from '$lib/utils/dates';
import type { ProposalStoryblok } from '$types/bloks';
import type { AssetStoryblok, ProposalStoryblok } from '$types/bloks';
import clsx from 'clsx';
export let proposal: ProposalStoryblok;
export let date: string | undefined;
export let cover: AssetStoryblok | undefined;
</script>

<div
Expand Down Expand Up @@ -52,7 +53,14 @@
{/if}
</div>

{#if proposal.cover.filename}
{#if cover}
{@const { alt, src, width, height } = getImageAttributes(cover, {
size: [1440, 0]
})}
<div class="mt-12 md:col-span-2">
<img class="rounded-md bg-background-offset" {src} {alt} {width} {height} />
</div>
{:else if proposal.cover.filename}
{@const { alt, src, width, height } = getImageAttributes(proposal.cover, {
size: [1440, 0]
})}
Expand Down
26 changes: 12 additions & 14 deletions src/components/proposals/proposal-package-reply.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { Button } from '@significa/svelte-ui';
import { t } from '$lib/i18n';
import { page } from '$app/stores';
import { t } from '$lib/i18n';
import { formatter } from '$lib/utils/currency';
import type {
ProposalDeliverableStoryblok,
Expand All @@ -10,6 +9,7 @@
ProposalPackageTeamEntryStoryblok,
ProposalTeamEntryStoryblok
} from '$types/bloks';
import { Button } from '@significa/svelte-ui';
import clsx from 'clsx';
import Popover from './popover.svelte';
Expand All @@ -32,18 +32,16 @@
$: totalManpower = deliverables.reduce((acc, resource) => (acc = acc + +resource.manpower), 0);
$: totalMonths = Math.ceil(
deliverables
.reduce(
(acc: ProposalDeliverableTeamEntryStoryblok[], current) => [...acc, ...current.team],
[]
)
.reduce(
(max: number, current) =>
+current.duration + +current.offset > max ? +current.duration + +current.offset : max,
0
)
);
$: totalMonths = deliverables
.reduce(
(acc: ProposalDeliverableTeamEntryStoryblok[], current) => [...acc, ...current.team],
[]
)
.reduce(
(max: number, current) =>
+current.duration + +current.offset > max ? +current.duration + +current.offset : max,
0
);
$: totalValue = monthlyTotal * totalMonths - (monthlyTotal * totalMonths * discount) / 100;
</script>
Expand Down
19 changes: 10 additions & 9 deletions src/components/proposals/proposal-page.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<script lang="ts">
import clsx from 'clsx';
import type { ProposalStoryblok } from '$types/bloks';
import RichText from '$components/rich-text.svelte';
import { slugify } from '$lib/utils/paths';
import { createPackageTimelineData, createRateTimelineData } from '$lib/utils/proposals';
import RichText from '$components/rich-text.svelte';
import type { ProposalStoryblok } from '$types/bloks';
import clsx from 'clsx';
import ProposalDeliverables from './proposal-deliverables.svelte';
import ProposalEstimates from './proposal-estimates.svelte';
import ProposalHero from './proposal-hero.svelte';
import ProposalNavigation from './proposal-navigation.svelte';
import ProposalDeliverables from './proposal-deliverables.svelte';
import ProposalPackageReply from './proposal-package-reply.svelte';
import ProposalPackage from './proposal-package.svelte';
import ProposalRateReply from './proposal-rate-reply.svelte';
import ProposalScope from './proposal-scope.svelte';
import ProposalTeam from './proposal-team.svelte';
import ProposalEstimates from './proposal-estimates.svelte';
import ProposalPackage from './proposal-package.svelte';
import ProposalTimeline from './proposal-timeline.svelte';
import ProposalPackageReply from './proposal-package-reply.svelte';
import ProposalRateReply from './proposal-rate-reply.svelte';
export let proposal: ProposalStoryblok;
let versions = proposal?.versions || [];
let version = versions.length > 0 ? versions[0].version_name : '';
$: content = versions.find((v) => v.version_name === version);
$: console.log(content);
$: type = content?.component === 'proposal-version-package' ? 'package' : 'rate';
$: sections = (content?.body || []).map((section) => section.title || '').filter(Boolean);
Expand All @@ -37,7 +38,7 @@
bind:version
/>

<ProposalHero {proposal} date={content?.date} />
<ProposalHero {proposal} date={content?.date} cover={content?.cover} />

{#each content?.body || [] as section}
<section id={slugify(section.title)} class="my-10 md:my-14 lg:my-20">
Expand Down

0 comments on commit b517d88

Please sign in to comment.