diff --git a/backend/internal/service/handler/lineItem/handle_recommendation.go b/backend/internal/service/handler/lineItem/handle_recommendation.go index f7cb07f8..4f2b81ba 100644 --- a/backend/internal/service/handler/lineItem/handle_recommendation.go +++ b/backend/internal/service/handler/lineItem/handle_recommendation.go @@ -14,8 +14,6 @@ func (h *Handler) HandleRecommendation(c *fiber.Ctx) error { return errs.BadRequest("Invalid line item ID") } - fmt.Println("ID:", id) - accept := c.Query("accept") == "true" lineItem, err := h.lineItemRepository.HandleRecommendation(c.Context(), id, accept) diff --git a/backend/internal/service/handler/lineItem/post_line_items.go b/backend/internal/service/handler/lineItem/post_line_items.go index 18c6557d..a438ce4a 100644 --- a/backend/internal/service/handler/lineItem/post_line_items.go +++ b/backend/internal/service/handler/lineItem/post_line_items.go @@ -3,6 +3,7 @@ package lineItem import ( "arenius/internal/errs" "arenius/internal/models" + "context" "fmt" "time" @@ -59,5 +60,19 @@ func (h *Handler) PostLineItem(c *fiber.Ctx) error { } } + companyId, err := uuid.Parse(req.CompanyID) + if err != nil { + fmt.Println("Error parsing company ID for auto reconciliation:", err) + } else { + ctx := c.UserContext() + + go func(ctx context.Context, companyId uuid.UUID) { + _, autoReconcileErr := h.lineItemRepository.AutoReconcileLineItems(ctx, companyId) + if autoReconcileErr != nil { + fmt.Println("Async auto-reconciliation error:", autoReconcileErr) + } + }(ctx, companyId) + } + return c.Status(fiber.StatusCreated).JSON(createdItem) } diff --git a/backend/internal/service/handler/xero/sync_company_transactions.go b/backend/internal/service/handler/xero/sync_company_transactions.go index 34de785c..e81544aa 100644 --- a/backend/internal/service/handler/xero/sync_company_transactions.go +++ b/backend/internal/service/handler/xero/sync_company_transactions.go @@ -39,8 +39,6 @@ func (h *Handler) syncCompanyTransactions(ctx *fiber.Ctx, company models.Tenant) } accessToken := newToken.AccessToken - fmt.Println("new token", newToken) - fmt.Println("access", accessToken) e := h.UserRepository.SetUserCredentials(ctx.Context(), *company.UserID, company.ID, newToken.RefreshToken, *company.XeroTenantID) if e != nil { fmt.Println("error updating user credentials", e) diff --git a/backend/internal/storage/postgres/schema/line_item.go b/backend/internal/storage/postgres/schema/line_item.go index ba1443a9..719793ea 100644 --- a/backend/internal/storage/postgres/schema/line_item.go +++ b/backend/internal/storage/postgres/schema/line_item.go @@ -423,6 +423,7 @@ func (r *LineItemRepository) GetLineItemsByIds(ctx context.Context, lineItemIDs } func (r *LineItemRepository) AutoReconcileLineItems(ctx context.Context, companyId uuid.UUID) ([]models.LineItem, error) { + const unreconciledTransactionsQuery = ` SELECT id, description FROM line_item diff --git a/frontend/src/app/(main)/contacts/page.tsx b/frontend/src/app/(main)/contacts/page.tsx index 011783d0..72aab027 100644 --- a/frontend/src/app/(main)/contacts/page.tsx +++ b/frontend/src/app/(main)/contacts/page.tsx @@ -1,7 +1,6 @@ "use client"; -import { useEffect } from "react"; -import Link from "next/link"; +import { useEffect, useState } from "react"; import Image from "next/image"; import { Search } from "lucide-react"; @@ -11,6 +10,8 @@ import ExportContactsButton from "@/components/contacts/ExportContacts"; import ContactTable from "@/components/contacts/ContactTable"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; +import LoadingSpinner from "@/components/ui/loading-spinner"; +import Link from "next/link"; export default function Contacts() { return ( @@ -25,6 +26,8 @@ function ContactsContent() { const { searchTerm, setSearchTerm, debouncedTerm } = useDebouncedSearch( filters.search_term ); + const [isNavigating, setIsNavigating] = useState(false); + useEffect(() => { setFilters((prevFilters) => ({ @@ -35,6 +38,14 @@ function ContactsContent() { return (
+ {isNavigating && ( +
+
+ +
+
+ )} +

Contacts

@@ -47,8 +58,16 @@ function ContactsContent() { />
- -