Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions src/app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<aos-footer />
}

<aos-workspace-manage-modal />
<aos-profile-modal />
@if (wm.isManageModalOpen()) {
<aos-workspace-manage-modal />
}
@if (profileModalService.isOpen()) {
<aos-profile-modal />
}
</div>
4 changes: 4 additions & 0 deletions src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { provideIcons } from "@ng-icons/core";
import { lucideMenu } from "@ng-icons/lucide";
import { filter, map } from "rxjs";
import { ProfileModal } from "./features/profile/profile-modal";
import { ProfileModalService } from "./features/profile/services/profile-modal.service";
import { WorkspaceManageModal } from "./features/workspaces/components/workspace-manage-modal/workspace-manage-modal";
import { WorkspaceManagement } from "./features/workspaces/services/workspace-management";
import { Footer } from "./layout/footer/footer";
import { Navbar } from "./layout/navbar/navbar";

Expand All @@ -25,6 +27,8 @@ import { Navbar } from "./layout/navbar/navbar";
})
export class App {
private readonly router = inject(Router);
readonly wm = inject(WorkspaceManagement);
readonly profileModalService = inject(ProfileModalService);

private readonly currentUrl = toSignal(
this.router.events.pipe(
Expand Down
39 changes: 39 additions & 0 deletions src/app/core/api/models/invoice.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type InvoiceStatus = "DRAFT" | "SENT" | "PAID" | "VOID" | "OVERDUE";

export interface InvoiceRequest {
clientId: string;
status: InvoiceStatus;
}

export interface InvoiceResponse {
Expand All @@ -12,3 +13,41 @@ export interface InvoiceResponse {
createdAt: string;
updatedAt: string;
}

export interface InvoiceStatusMeta {
label: string;
badgeClass: string;
dotClass: string;
}

export const INVOICE_STATUS_META: Record<InvoiceStatus, InvoiceStatusMeta> = {
DRAFT: {
label: "Draft",
badgeClass: "bg-soft-stone text-body-muted border-hairline",
dotClass: "bg-muted",
},
SENT: {
label: "Sent",
badgeClass:
"bg-sky-50 text-sky-700 border-sky-200 dark:bg-sky-950/40 dark:text-sky-400 dark:border-sky-800",
dotClass: "bg-sky-500",
},
PAID: {
label: "Paid",
badgeClass:
"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-400 dark:border-emerald-800",
dotClass: "bg-emerald-500",
},
OVERDUE: {
label: "Overdue",
badgeClass:
"bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950/40 dark:text-amber-400 dark:border-amber-800",
dotClass: "bg-amber-500",
},
VOID: {
label: "Void",
badgeClass:
"bg-rose-50 text-rose-700 border-rose-200 dark:bg-rose-950/40 dark:text-rose-400 dark:border-rose-800",
dotClass: "bg-rose-500",
},
};
71 changes: 70 additions & 1 deletion src/app/core/api/services/invoice/invoice-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe("InvoiceApi", () => {
});

it("should create invoice via POST", () => {
const payload: InvoiceRequest = { clientId: "c-1" };
const payload: InvoiceRequest = { clientId: "c-1", status: "DRAFT" };
const mockResponse: InvoiceResponse = {
id: "inv-1",
clientId: "c-1",
Expand All @@ -124,6 +124,75 @@ describe("InvoiceApi", () => {
req.flush(mockResponse);
});

it("should get invoice by id via GET", () => {
const mockResponse: InvoiceResponse = {
id: "inv-1",
clientId: "c-1",
totalAmount: 3750.0,
status: "SENT",
createdAt: "2026-01-01T00:00:00Z",
updatedAt: "2026-01-01T00:00:00Z",
};

service.getInvoiceById("inv-1").subscribe(res => {
expect(res).toEqual(mockResponse);
});

const req = httpTesting.expectOne("https://api.example.com/api/v1/invoices/inv-1");
expect(req.request.method).toBe("GET");
req.flush(mockResponse);
});

it("should get invoices by client id via GET", () => {
const mockResponses: InvoiceResponse[] = [
{
id: "inv-1",
clientId: "c-1",
totalAmount: 3750.0,
status: "PAID",
createdAt: "2026-01-01T00:00:00Z",
updatedAt: "2026-01-01T00:00:00Z",
},
];

service.getInvoicesByClientId("c-1").subscribe(res => {
expect(res).toEqual(mockResponses);
});

const req = httpTesting.expectOne("https://api.example.com/api/v1/invoices/client/c-1");
expect(req.request.method).toBe("GET");
req.flush(mockResponses);
});

it("should update invoice via PUT", () => {
const payload: InvoiceRequest = { clientId: "c-1", status: "PAID" };
const mockResponse: InvoiceResponse = {
id: "inv-1",
clientId: "c-1",
totalAmount: 3750.0,
status: "PAID",
createdAt: "2026-01-01T00:00:00Z",
updatedAt: "2026-01-02T00:00:00Z",
};

service.updateInvoice("inv-1", payload).subscribe(res => {
expect(res).toEqual(mockResponse);
});

const req = httpTesting.expectOne("https://api.example.com/api/v1/invoices/inv-1");
expect(req.request.method).toBe("PUT");
expect(req.request.body).toEqual(payload);
req.flush(mockResponse);
});

it("should delete invoice via DELETE", () => {
service.deleteInvoice("inv-1").subscribe();

const req = httpTesting.expectOne("https://api.example.com/api/v1/invoices/inv-1");
expect(req.request.method).toBe("DELETE");
req.flush(null);
});

it("should stream invoice PDF via GET", () => {
const mockBlob = new Blob(["%PDF-1.4..."], { type: "application/pdf" });

Expand Down
16 changes: 16 additions & 0 deletions src/app/core/api/services/invoice/invoice-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ export class InvoiceApi {
return this.http.post<InvoiceResponse>(this.baseUrl, req);
}

getInvoiceById(id: string): Observable<InvoiceResponse> {
return this.http.get<InvoiceResponse>(`${this.baseUrl}/${id}`);
}

getInvoicesByClientId(clientId: string): Observable<InvoiceResponse[]> {
return this.http.get<InvoiceResponse[]>(`${this.baseUrl}/client/${clientId}`);
}

updateInvoice(id: string, req: InvoiceRequest): Observable<InvoiceResponse> {
return this.http.put<InvoiceResponse>(`${this.baseUrl}/${id}`, req);
}

deleteInvoice(id: string): Observable<void> {
return this.http.delete<void>(`${this.baseUrl}/${id}`);
}

downloadInvoicePdf(id: string): Observable<Blob> {
return this.http.get(`${this.baseUrl}/${id}/pdf`, {
responseType: "blob",
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/how-it-works/how-it-works.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ <h5 class="mt-1 text-xs font-semibold text-white">Multi-tenant workspace modal</
>
<div class="flex items-center gap-1.5">
<aos-icons name="lucideTimer" class="size-3.5 animate-spin" />
<span>03:14:22</span>
<span>{{ formattedTimer() }}</span>
</div>
<span class="text-brand-green-light text-[10px] font-medium">Live</span>
</div>
Expand Down
39 changes: 39 additions & 0 deletions src/app/features/how-it-works/how-it-works.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { provideRouter } from "@angular/router";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { HowItWorks } from "./how-it-works";

describe("HowItWorks", () => {
let component: HowItWorks;
let fixture: ComponentFixture<HowItWorks>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HowItWorks],
providers: [provideRouter([])],
}).compileComponents();

fixture = TestBed.createComponent(HowItWorks);
component = fixture.componentInstance;
await fixture.whenStable();
});

it("should create", () => {
expect(component).toBeTruthy();
});

it("should initialize preview timer to 03:14:22 and format correctly", () => {
expect(component.formattedTimer()).toBe("03:14:22");
});

it("should increment preview timer when updated", () => {
component.timerSeconds.update(s => s + 1);
expect(component.formattedTimer()).toBe("03:14:23");
});

it("should clear timer interval on destruction", () => {
const clearIntervalSpy = vi.spyOn(globalThis, "clearInterval");
fixture.destroy();
expect(clearIntervalSpy).toHaveBeenCalled();
});
});
27 changes: 25 additions & 2 deletions src/app/features/how-it-works/how-it-works.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from "@angular/core";
import { Component, computed, OnDestroy, OnInit, signal } from "@angular/core";
import { Button } from "../../shared/components/button/button";
import { Icons } from "../../shared/components/icons/icons";
import { provideIcons } from "@ng-icons/core";
Expand Down Expand Up @@ -49,4 +49,27 @@ import { simpleGithub } from "@ng-icons/simple-icons";
templateUrl: "./how-it-works.html",
styleUrl: "./how-it-works.css",
})
export class HowItWorks {}
export class HowItWorks implements OnInit, OnDestroy {
private timerIntervalId?: ReturnType<typeof setInterval>;
readonly timerSeconds = signal<number>(3 * 3600 + 14 * 60 + 22);

readonly formattedTimer = computed(() => {
const total = this.timerSeconds();
const h = String(Math.floor(total / 3600)).padStart(2, "0");
const m = String(Math.floor((total % 3600) / 60)).padStart(2, "0");
const s = String(total % 60).padStart(2, "0");
return `${h}:${m}:${s}`;
});

ngOnInit(): void {
this.timerIntervalId = setInterval(() => {
this.timerSeconds.update(s => s + 1);
}, 1000);
}

ngOnDestroy(): void {
if (this.timerIntervalId) {
clearInterval(this.timerIntervalId);
}
}
}
Loading
Loading