Skip to content

Commit

Permalink
Clarify types
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley committed Sep 18, 2023
1 parent f16922d commit 35540aa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion web/app/components/document/sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@

<div class="flex flex-col items-start space-y-2">
<Document::Sidebar::SectionHeader @title="Created" />
<p>{{or @document.created "Unknown"}}</p>
<p>{{or (parse-date @document.created) "Unknown"}}</p>
</div>

<div class="flex flex-col items-start space-y-2">
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/row-results.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{{#each @docs as |doc|}}
<Doc::Row
@avatar="{{get doc.ownerPhotos 0}}"
@createdDate={{doc.created}}
@createdDate="{{parse-date doc.created}}"
@docID="{{doc.objectID}}"
@docNumber="{{doc.docNumber}}"
@docType="{{doc.docType}}"
Expand Down
7 changes: 2 additions & 5 deletions web/app/helpers/parse-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ export interface ParseDateHelperSignature {
Args: {
Positional: [
time: string | number | Date | undefined,
monthFormat: undefined | "short" | "long"
monthFormat?: "short" | "long"
];
Return: Date | undefined;
};
}

const parseDateHelper = helper<ParseDateHelperSignature>(
([time, monthFormat = "short"]: [
string | number | Date | undefined,
undefined | "short" | "long"
]) => {
([time, monthFormat = "short"]) => {
return parseDate(time, monthFormat);
}
);
Expand Down
21 changes: 19 additions & 2 deletions web/app/types/document.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,26 @@ export interface HermesDocument {

status: string;
product?: string;
created: string; // E.g., "Aug 16, 2023"

/**
* A human-readable date string, e.g., "Aug 16, 2028".
* Mutated in the layout by the `parse-date` helper to place
* the date before the month.
*/
created: string;

/**
* A timestamp in seconds. Used for sorting.
*/
createdTime: number;
modifiedTime?: number; // Not available on drafts fetched as Hits from backend

/**
* A timestamp in seconds. Used Translated by the `time-ago` helper
* into a human-readable string, e.g., "2 days ago."
* Not available on drafts fetched as Hits from backend.
*/
modifiedTime?: number;

docNumber: string;
docType: string;
title: string;
Expand Down

0 comments on commit 35540aa

Please sign in to comment.