Don't handle undefined in smart-date-format

We will handle that from the outside
This commit is contained in:
Michael Klein 2022-10-10 15:08:52 +02:00
parent 7600cb2e31
commit e8db58c56b
2 changed files with 49 additions and 46 deletions

View File

@ -54,52 +54,65 @@
<div
class="hds-typography-body-200 hds-font-weight-semibold mb-2 text-hds-foreground-primary"
>Latest heartbeat</div>
{{#let (smart-date-format item.heartbeat) as |smartDate|}}
<div class="flex items-center"><FlightIcon
@name="activity"
class="mr-0.5 text-hds-foreground-faint fill-current"
/>
{{#if smartDate.isNearDate}}
<span
{{tooltip smartDate.friendly}}
>{{smartDate.relative}}</span>
{{else}}
<span>{{smartDate.friendly}}</span>
{{/if}}
</div>
{{/let}}
<div class="flex items-center">
{{#if item.heartbeat}}
{{#let (smart-date-format item.heartbeat) as |smartDate|}}
<FlightIcon
@name="activity"
class="mr-0.5 text-hds-foreground-faint fill-current"
/>
{{#if smartDate.isNearDate}}
<span
{{tooltip smartDate.friendly}}
>{{smartDate.relative}}</span>
{{else}}
<span>{{smartDate.friendly}}</span>
{{/if}}
{{/let}}
{{else}}
<span>None yet</span>
{{/if}}
</div>
</div>
<div class="shrink-0">
<div
class="hds-typography-body-200 hds-font-weight-semibold mb-2 text-hds-foregrouny-primary"
>Latest receipt</div>
{{#let (smart-date-format item.receipt) as |smartDate|}}
<div class="flex items-center">
{{#if smartDate.isNearDate}}
<span
{{tooltip smartDate.friendly}}
>{{smartDate.relative}}</span>
{{else}}
<span>{{smartDate.friendly}}</span>
{{/if}}
</div>
{{/let}}
<div class="flex items-center">
{{#if item.receipt}}
{{#let (smart-date-format item.receipt) as |smartDate|}}
{{#if smartDate.isNearDate}}
<span
{{tooltip smartDate.friendly}}
>{{smartDate.relative}}</span>
{{else}}
<span>{{smartDate.friendly}}</span>
{{/if}}
{{/let}}
{{else}}
<span>None yet</span>
{{/if}}
</div>
</div>
<div class="shrink-0">
<div
class="hds-typography-body-200 hds-font-weight-semibold mb-2 text-hds-foreground-primary"
>Latest send</div>
{{#let (smart-date-format item.lastSend) as |smartDate|}}
<div class="flex items-center">
{{#if smartDate.isNearDate}}
<span
{{tooltip smartDate.friendly}}
>{{smartDate.relative}}</span>
{{else}}
<span>{{smartDate.friendly}}</span>
{{/if}}
</div>
{{/let}}
<div class="flex items-center">
{{#if item.lastSend}}
{{#let (smart-date-format item.lastSend) as |smartDate|}}
{{#if smartDate.isNearDate}}
<span
{{tooltip smartDate.friendly}}
>{{smartDate.relative}}</span>
{{else}}
<span>{{smartDate.friendly}}</span>
{{/if}}
{{/let}}
{{else}}
<span>None yet</span>
{{/if}}
</div>
</div>
</div>

View File

@ -21,16 +21,6 @@ export default class SmartDateFormat extends Helper {
@service intl;
compute([value], hash) {
const fallback = hash.fallback || 'None yet';
if (!value) {
return {
isNearDate: false,
relative: fallback,
friendly: fallback,
};
}
return {
isNearDate: isNearDate(value),
relative: `${this.temporal.format(value)} ago`,