From 83bd4394fc26add2193604e99246bccd19499390 Mon Sep 17 00:00:00 2001 From: AmirReza Jamali Date: Tue, 9 Sep 2025 13:32:58 +0330 Subject: [PATCH] Fixed build issues --- DockerFile | 6 +- src/app/customers/edit/[id]/page.tsx | 29 +++++++- .../form-layout/_components/contact-form.tsx | 8 +- .../form-layout/_components/sign-in-form.tsx | 4 +- .../form-layout/_components/sign-up-form.tsx | 4 +- .../settings/_components/personal-info.tsx | 4 +- src/app/pages/settings/page.tsx | 21 +++--- src/components/Auth/SigninWithPassword.tsx | 74 +++++++++++-------- .../Layouts/header/user-info/index.tsx | 9 ++- src/components/Layouts/sidebar/index.tsx | 2 +- src/components/Tables/companies/index.tsx | 9 ++- src/components/Tables/customers/index.tsx | 8 +- src/components/Tables/tenders/index.tsx | 10 ++- .../Tables/tenders/useTenderListPresenter.ts | 11 ++- src/contexts/User.ctx.tsx | 6 +- src/hooks/queries/useCustomerQueries.ts | 8 ++ src/lib/api/services/customers-service.ts | 4 + src/lib/api/types/Tenders.ts | 2 +- 18 files changed, 139 insertions(+), 80 deletions(-) diff --git a/DockerFile b/DockerFile index c31644e..f1afc53 100644 --- a/DockerFile +++ b/DockerFile @@ -1,11 +1,11 @@ -FROM node:20.16.0 AS builder +FROM node:22.19.0 AS builder WORKDIR /app # RUN apk add --no-cache libc6-compat COPY package*.json ./ -RUN npm install +RUN npm i COPY . . @@ -14,7 +14,7 @@ RUN npm run build #--- -FROM node:20.16.0 AS runner +FROM node:22.19.0 AS runner WORKDIR /app diff --git a/src/app/customers/edit/[id]/page.tsx b/src/app/customers/edit/[id]/page.tsx index e2d4ca7..ac7396d 100644 --- a/src/app/customers/edit/[id]/page.tsx +++ b/src/app/customers/edit/[id]/page.tsx @@ -1,7 +1,30 @@ -import { ShadowBox } from "@/src/components"; +"use client"; -const EditCustomer = () => { - return Edit customer; +import { use } from "react"; +import { + useCustomersInfiniteQuery, + useGetCustomersDetails, +} from "../../../../hooks/queries/useCustomerQueries"; +import Breadcrumb from "@/components/Breadcrumbs/Breadcrumb"; +import CreateCustomer from "@/components/forms/customers/CreateCustomer"; +import Loading from "@/app/loading"; + +const EditCustomer = ({ params }: { params: Promise<{ id: string }> }) => { + const { id } = use(params); + const { isLoading, data, isError } = useGetCustomersDetails(id); + const breadcrumbItems = [ + { name: "Dashboard", href: "/" }, + { name: "Customers", href: "/customers" }, + { name: "Edit Customer", href: `/customers/edit/${id}` }, + ]; + if (isLoading) return ; + if (isError) return
Error
; + return ( + <> + + + + ); }; export default EditCustomer; diff --git a/src/app/forms/form-layout/_components/contact-form.tsx b/src/app/forms/form-layout/_components/contact-form.tsx index a6fc7bc..710eeb8 100644 --- a/src/app/forms/form-layout/_components/contact-form.tsx +++ b/src/app/forms/form-layout/_components/contact-form.tsx @@ -8,7 +8,7 @@ export function ContactForm() {
- + /> */}
- - + */} diff --git a/src/components/Layouts/header/user-info/index.tsx b/src/components/Layouts/header/user-info/index.tsx index 4532670..b9df9df 100644 --- a/src/components/Layouts/header/user-info/index.tsx +++ b/src/components/Layouts/header/user-info/index.tsx @@ -11,10 +11,11 @@ import Image from "next/image"; import Link from "next/link"; import { useState } from "react"; import { LogOutIcon, SettingsIcon, UserIcon } from "./icons"; +import { useUser } from "@/contexts"; export function UserInfo() { const [isOpen, setIsOpen] = useState(false); - + const { logout } = useUser(); const USER = { name: "John Smith", email: "johnson@nextadmin.com", @@ -106,7 +107,11 @@ export function UserInfo() {
diff --git a/src/components/Tables/tenders/useTenderListPresenter.ts b/src/components/Tables/tenders/useTenderListPresenter.ts index 6fb492e..2d87022 100644 --- a/src/components/Tables/tenders/useTenderListPresenter.ts +++ b/src/components/Tables/tenders/useTenderListPresenter.ts @@ -49,11 +49,11 @@ const useTenderListPresenter = () => { const handleFilterChange = (e: React.ChangeEvent) => { setSearch(e.target.value); }; - const onConfirmDelete = () => { - if (currentTender) { - deleteTender(currentTender.id); - } - }; + // const onConfirmDelete = () => { + // if (currentTender) { + // deleteTender(currentTender.id); + // } + // }; const allTenders = data?.pages.flatMap((page) => page.data.tenders) ?? []; return { @@ -61,7 +61,6 @@ const useTenderListPresenter = () => { setCurrentTender, search, handleFilterChange, - onConfirmDelete, allTenders, error, isPending, diff --git a/src/contexts/User.ctx.tsx b/src/contexts/User.ctx.tsx index ec26138..92b93c7 100644 --- a/src/contexts/User.ctx.tsx +++ b/src/contexts/User.ctx.tsx @@ -1,4 +1,3 @@ -// src/contexts/UserContext.tsx "use client"; import React, { @@ -15,6 +14,7 @@ import Cookies from "js-cookie"; import { z } from "zod"; import { UserSchema, ILoginResponse } from "../lib/api/types"; import { COOKIE_KEYS } from "../lib/shared/cookies"; +import { useRouter } from "next/navigation"; type User = z.infer; @@ -37,7 +37,7 @@ export const UserProvider: React.FC = ({ children }) => { const [user, setUser] = useState(null); const [accessToken, setAccessToken] = useState(null); const [isLoading, setIsLoading] = useState(true); - + const router = useRouter(); useEffect(() => { try { const tokenFromCookie = Cookies.get(COOKIE_KEYS.access_token); @@ -88,7 +88,7 @@ export const UserProvider: React.FC = ({ children }) => { setAuthState, logout, }), - [user, accessToken, isLoading, setAuthState, logout] + [user, accessToken, isLoading, setAuthState, logout], ); return {children}; diff --git a/src/hooks/queries/useCustomerQueries.ts b/src/hooks/queries/useCustomerQueries.ts index ac48569..921739d 100644 --- a/src/hooks/queries/useCustomerQueries.ts +++ b/src/hooks/queries/useCustomerQueries.ts @@ -27,6 +27,7 @@ export const useCustomersInfiniteQuery = (params?: Record) => { initialPageParam: 0, getNextPageParam: (lastPage) => { + if (!lastPage.meta) return; const { offset, limit, total } = lastPage.meta; const nextOffset = offset + limit; @@ -42,6 +43,13 @@ export const useGetAllCustomers = () => { queryFn: () => customersService.getCustomers(), }); }; +export const useGetCustomersDetails = (id: string) => { + const queryKey = useMemo(() => ["GET ALL CUSTOMERS", id], [id]); + return useQuery({ + queryKey, + queryFn: () => customersService.customerDetails(id), + }); +}; export const useAssignCompany = (id: string, successCallback?: () => void) => { const queryClient = useQueryClient(); const mutationKey = useMemo( diff --git a/src/lib/api/services/customers-service.ts b/src/lib/api/services/customers-service.ts index ebf9947..fea73b7 100644 --- a/src/lib/api/services/customers-service.ts +++ b/src/lib/api/services/customers-service.ts @@ -49,6 +49,10 @@ export const customersService = { throw error; } }, + customerDetails: async (id: string) => { + const response = await api.get(API_ENDPOINTS.CUSTOMERS.DETAILS(id)); + return response.data; + }, assignCompanyToCustomer: async ({ credentials, id, diff --git a/src/lib/api/types/Tenders.ts b/src/lib/api/types/Tenders.ts index aeaed4f..49caa8e 100644 --- a/src/lib/api/types/Tenders.ts +++ b/src/lib/api/types/Tenders.ts @@ -24,6 +24,6 @@ const TenderSchema = z.object({ title: z.string(), }); export const TendersResponse = z.object({ - companies: z.array(TenderSchema).or(z.null()), + tenders: z.array(TenderSchema).or(z.null()), }); export type TTenderResponse = z.infer;