Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ backend/app/api/static/public/*
backend/api

docs/.vitepress/cache/
/.data/
.data/

# Playwright
frontend/test-results/
Expand Down
2 changes: 0 additions & 2 deletions frontend/components/global/DetailsSection/DetailsSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,4 @@
overflow-wrap: break-word;
}
}


</style>
4 changes: 3 additions & 1 deletion frontend/composables/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { CurrenciesCurrency } from "~/lib/api/types/data-contracts";

export function validDate(dt: Date | string | null | undefined): boolean {
if (!dt) {
return false;
Expand Down Expand Up @@ -42,7 +44,7 @@ function clampDecimals(currency: string, decimals: number): number {
}

// Type guard to validate currency response shape with strict validation
function isValidCurrencyItem(item: any): item is { code: string; decimals: number } {
function isValidCurrencyItem(item: CurrenciesCurrency): boolean {
if (
typeof item !== "object" ||
item === null ||
Expand Down
15 changes: 2 additions & 13 deletions frontend/lib/datelib/datelib.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { describe, expect, test } from "vitest";
import { factorRange, format, parse, zeroTime } from "./datelib";

describe("format", () => {
test("should format a date as a string", () => {
const date = new Date(2020, 1, 1);
expect(format(date)).toBe("2020-02-01");
});

test("should return the string if a string is passed in", () => {
expect(format("2020-02-01")).toBe("2020-02-01");
});
});
import { factorRange, parse, zeroTime } from "./datelib";

describe("zeroTime", () => {
test("should zero out the time", () => {
const date = new Date(2020, 1, 1, 12, 30, 30);
const date = new Date(Date.UTC(2020, 1, 1, 12, 30, 30));
const zeroed = zeroTime(date);
expect(zeroed.getHours()).toBe(0);
expect(zeroed.getMinutes()).toBe(0);
Expand Down
16 changes: 3 additions & 13 deletions frontend/lib/datelib/datelib.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import { addDays } from "date-fns";

/*
* Formats a date as a string
* */
export function format(date: Date | string): string {
if (typeof date === "string") {
return date;
}
return date.toISOString().split("T")[0]!;
}

export function zeroTime(date: Date): Date {
return new Date(
new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - date.getTimezoneOffset() * 60000
);
const result = new Date(date.getTime());
result.setHours(0, 0, 0, 0);
return result;
}

export function factorRange(offset: number = 7): [Date, Date] {
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint:fix": "eslint --ext \".ts,.js,.vue\" --ignore-pattern \"components/ui\" . --fix",
"lint:ci": "eslint --ext \".ts,.js,.vue\" --ignore-pattern \"components/ui\" . --max-warnings 1",
"typecheck": "pnpm nuxi typecheck --noEmit",
"test:ci": "TEST_SHUTDOWN_API_SERVER=true vitest --run --config ./test/vitest.config.ts",
"test:ci": "TEST_SHUTDOWN_API_SERVER=true vitest --run --config ./test/vitest.config.ts --no-file-parallelism",
"test:local": "TEST_SHUTDOWN_API_SERVER=false && vitest --run --config ./test/vitest.config.ts",
"test:watch": " TEST_SHUTDOWN_API_SERVER=false vitest --config ./test/vitest.config.ts"
},
Expand Down
Loading