Skip to content

Commit

Permalink
refactor: extract date format
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 13, 2022
1 parent 58ed826 commit 7190316
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Component, Host, h, Prop} from '@stencil/core';
import PadLeft from "../utils/PadLeft";
import DateFormat from "../utils/DateFormat";

@Component({
tag: 'entry-card',
Expand All @@ -23,10 +24,6 @@ export class EntryCard {

}

formatDate(_date: string) {

}

render() {
return (
<Host>
Expand All @@ -44,7 +41,7 @@ export class EntryCard {
</ion-card-header>
<ion-card-content>
{this.item.description && <p>{this.item.description}</p>}
<ion-badge slot="start">{this.formatDate(this.item.created_date)}</ion-badge>
<ion-badge slot="start">{DateFormat(this.item.created_date)}</ion-badge>
</ion-card-content>
</ion-card>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Component, Element, Event, EventEmitter, h, Prop, State} from '@stencil/core';
import {MeiliSearch} from "meilisearch";
import dayjs from "dayjs";

// only for: IDEA jump
// @ts-ignore
// import {IonSearchbar} from "@ionic/core";
import {createTransflow, init_wasm, parseAction} from "./quake-core-wrapper";
import PadLeft from "../utils/PadLeft";
import DateFormat from "../utils/DateFormat";

export interface ActionDefine {
entry: String,
Expand Down Expand Up @@ -181,10 +181,6 @@ export class QuakeDashboard {
})
}

formatDate(str) {
return dayjs(str * 1000).format('YYYY-MM-DD');
}

async selectType(_e: Event, info: EntryInfo) {
this.resetInput();
this.selectedEntry = info;
Expand Down Expand Up @@ -436,7 +432,7 @@ export class QuakeDashboard {
</ion-card-header>
<ion-card-content>
{item.description && <p>{item.description}</p>}
<ion-badge slot="start">{this.formatDate(item.created_date)}</ion-badge>
<ion-badge slot="start">{DateFormat(item.created_date)}</ion-badge>
</ion-card-content>
</ion-card>
)}
Expand Down Expand Up @@ -471,7 +467,7 @@ export class QuakeDashboard {
</ion-card-header>
<ion-card-content>
{item.description && <p>{item.description}</p>}
<ion-badge slot="start">{this.formatDate(item.created_date)}</ion-badge>
<ion-badge slot="start">{DateFormat(item.created_date)}</ion-badge>
</ion-card-content>
</ion-card>
</div>;
Expand Down
7 changes: 7 additions & 0 deletions quake_webapp/dashboard/src/components/utils/DateFormat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import dayjs from "dayjs";

function format(str) {
return dayjs(str * 1000).format('YYYY-MM-DD');
}

export default format;

0 comments on commit 7190316

Please sign in to comment.