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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions backend/internal/service/handler/lineItem/post_line_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package lineItem
import (
"arenius/internal/errs"
"arenius/internal/models"
"context"
"fmt"
"time"

Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions backend/internal/storage/postgres/schema/line_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 24 additions & 5 deletions frontend/src/app/(main)/contacts/page.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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 (
Expand All @@ -25,6 +26,8 @@ function ContactsContent() {
const { searchTerm, setSearchTerm, debouncedTerm } = useDebouncedSearch(
filters.search_term
);
const [isNavigating, setIsNavigating] = useState(false);


useEffect(() => {
setFilters((prevFilters) => ({
Expand All @@ -35,6 +38,14 @@ function ContactsContent() {

return (
<div className={styles.container}>
{isNavigating && (
<div className="fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center z-50">
<div className="rounded-full p-6">
<LoadingSpinner size={60} className="text-white" />
</div>
</div>
)}

<div className="flex items-center mb-4">
<p className={styles.pageTitle}>Contacts</p>
<div className="relative w-80 justify-start mb-4 ml-6">
Expand All @@ -47,16 +58,24 @@ function ContactsContent() {
/>
</div>
<div className="flex space-x-4 mb-4 ml-auto">
<Link href="/contacts/new" className="mr-4">
<Button size="lg" className="font-semibold space-x-2">
<Link
href="/contacts/new"
className="mr-4"
onClick={() => setIsNavigating(true)}
>
<Button
size="lg"
className="font-semibold space-x-2"
disabled={isNavigating}
>
<Image
src="/plus_1.svg"
alt=""
width={13}
height={13}
className="mr-1"
/>
<span>Add Contact</span>
<span>{isNavigating ? "Loading..." : "Add Contact"}</span>
</Button>
</Link>
<ExportContactsButton />
Expand Down
Loading