Compare commits

..

No commits in common. "998284f3981779dd35820cfc90190be66f2bb822" and "b8df8a2bde30cc53d04e6c217e1ba2f62c4a342f" have entirely different histories.

15 changed files with 348 additions and 861 deletions

View File

@ -11,18 +11,6 @@
top: var(--sticky-top, 0px) !important; top: var(--sticky-top, 0px) !important;
z-index: 1025; z-index: 1025;
} }
.form-control-md {
min-height: calc(1.6em + 0.65rem + calc(var(--bs-border-width) * 2));
padding: 0.18rem 0.60rem;
font-size: 0.875rem; /* ~14px */
border-radius: var(--bs-border-radius);
}
.form-control-md::file-selector-button {
padding: 0.32rem 0.75rem;
margin: -0.32rem -0.75rem;
margin-inline-end: 0.75rem;
}
/* ===========================% Background_Colors %========================================================== */ /* ===========================% Background_Colors %========================================================== */

View File

@ -200,9 +200,7 @@ export const SelectProjectField = ({
isFullObject = false, isFullObject = false,
isMultiple = false, isMultiple = false,
isAllProject = false, isAllProject = false,
disabled, disabled
className,
errors,
}) => { }) => {
const [searchText, setSearchText] = useState(""); const [searchText, setSearchText] = useState("");
const debounce = useDebounce(searchText, 300); const debounce = useDebounce(searchText, 300);
@ -305,10 +303,7 @@ export const SelectProjectField = ({
</span> </span>
</button> </button>
{errors?.projectId && ( {/* DROPDOWN */}
<div className="danger-text">{errors.projectId.message}</div>
)}
{open && ( {open && (
<ul <ul
className="dropdown-menu w-100 shadow-sm show animate__fadeIn h-64 overflow-auto rounded" className="dropdown-menu w-100 shadow-sm show animate__fadeIn h-64 overflow-auto rounded"
@ -331,7 +326,6 @@ export const SelectProjectField = ({
placeholder="Search..." placeholder="Search..."
/> />
</div> </div>
<div className="overflow-auto px-1" style={{ maxHeight: "200px" }}>
{isLoading && ( {isLoading && (
<li className="dropdown-item text-muted text-center">Loading...</li> <li className="dropdown-item text-muted text-center">Loading...</li>
@ -364,7 +358,6 @@ export const SelectProjectField = ({
</li> </li>
); );
})} })}
</div>
</ul> </ul>
)} )}
</div> </div>
@ -373,7 +366,7 @@ export const SelectProjectField = ({
export const SelectFieldSearch = ({ export const SelectFieldSearch = ({
label = "Select", label = "Select",
placeholder = "Select", placeholder = "Select ",
required = false, required = false,
value = null, value = null,
onChange, onChange,
@ -384,7 +377,6 @@ export const SelectFieldSearch = ({
isMultiple = false, isMultiple = false,
hookParams, hookParams,
useFetchHook, useFetchHook,
errors = null,
}) => { }) => {
const [searchText, setSearchText] = useState(""); const [searchText, setSearchText] = useState("");
const debounce = useDebounce(searchText, 300); const debounce = useDebounce(searchText, 300);
@ -394,75 +386,108 @@ export const SelectFieldSearch = ({
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const dropdownRef = useRef(null); const dropdownRef = useRef(null);
const getDisplayName = (entity) => const getDisplayName = (entity) => {
entity ? `${entity[labelKey] || ""}`.trim() : ""; if (!entity) return "";
return `${entity[labelKey] || ""}`.trim();
};
/** ----------------------------- SELECTED OPTION ----------------------------- */ /** -----------------------------
* SELECTED OPTION (SINGLE)
* ----------------------------- */
let selectedSingle = null; let selectedSingle = null;
if (!isMultiple) { if (!isMultiple) {
if (isFullObject && value) selectedSingle = value; if (isFullObject && value) selectedSingle = value;
else if (!isFullObject && value) else if (!isFullObject && value)
selectedSingle = options.find((o) => o[valueKey] === value); selectedSingle = options.find((o) => o[valueKey] === value);
} }
/** -----------------------------
* SELECTED OPTION (MULTIPLE)
* ----------------------------- */
let selectedList = []; let selectedList = [];
if (isMultiple && Array.isArray(value)) { if (isMultiple && Array.isArray(value)) {
selectedList = isFullObject if (isFullObject) selectedList = value;
? value else {
: options.filter((opt) => value.includes(opt[valueKey])); selectedList = options.filter((opt) => value.includes(opt[valueKey]));
}
} }
/** Main button label */
const displayText = !isMultiple const displayText = !isMultiple
? getDisplayName(selectedSingle) || placeholder ? getDisplayName(selectedSingle) || placeholder
: selectedList.length : selectedList.length > 0
? selectedList.map((e) => getDisplayName(e)).join(", ") ? selectedList.map((e) => getDisplayName(e)).join(", ")
: placeholder; : placeholder;
/** ----------------------------- OUTSIDE CLICK ----------------------------- */ /** -----------------------------
* HANDLE OUTSIDE CLICK
* ----------------------------- */
useEffect(() => { useEffect(() => {
const handleClickOutside = (e) => { const handleClickOutside = (e) => {
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
setOpen(false); setOpen(false);
}
}; };
document.addEventListener("mousedown", handleClickOutside); document.addEventListener("mousedown", handleClickOutside);
return () => document.removeEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside);
}, []); }, []);
/** ----------------------------- MERGED OPTIONS ----------------------------- */ // MERGED OPTIONS TO ENSURE SELECTED VALUE APPEARS EVEN IF NOT IN SEARCH RESULT
const [mergedOptions, setMergedOptions] = useState(options); const [mergedOptions, setMergedOptions] = useState([]);
useEffect(() => { useEffect(() => {
let finalList = [...options]; let finalList = [...options];
if (!isMultiple && value && !isFullObject && typeof value === "object") { if (!isMultiple && value && !isFullObject) {
const exists = options.some((o) => o[valueKey] === value[valueKey]); // already selected option inside options?
if (!exists) finalList.unshift(value); const exists = options.some((o) => o[valueKey] === value);
// if selected item not found, try to get from props (value) as fallback
if (!exists && typeof value === "object") {
finalList.unshift(value);
}
} }
if (isMultiple && Array.isArray(value)) { if (isMultiple && Array.isArray(value)) {
value.forEach((val) => { value.forEach((val) => {
const id = isFullObject ? val[valueKey] : val; const id = isFullObject ? val[valueKey] : val;
const exists = options.some((o) => o[valueKey] === id); const exists = options.some((o) => o[valueKey] === id);
if (!exists && typeof val === "object") finalList.unshift(val);
if (!exists && typeof val === "object") {
finalList.unshift(val);
}
}); });
} }
// Only update if different to avoid infinite loop setMergedOptions(finalList);
const oldKeys = mergedOptions.map((o) => o[valueKey]).join(","); }, [options, value]);
const newKeys = finalList.map((o) => o[valueKey]).join(",");
if (oldKeys !== newKeys) setMergedOptions(finalList);
}, [options, value, isMultiple, isFullObject, valueKey, mergedOptions]);
/** ----------------------------- HANDLE SELECT ----------------------------- */ /** -----------------------------
* HANDLE SELECT
* ----------------------------- */
const handleSelect = (option) => { const handleSelect = (option) => {
if (!isMultiple) { if (!isMultiple) {
onChange(isFullObject ? option : option[valueKey]); // SINGLE SELECT
if (isFullObject) onChange(option);
else onChange(option[valueKey]);
} else { } else {
// MULTIPLE SELECT
let updated = [];
const exists = selectedList.some((e) => e[valueKey] === option[valueKey]); const exists = selectedList.some((e) => e[valueKey] === option[valueKey]);
const updated = exists
? selectedList.filter((e) => e[valueKey] !== option[valueKey]) if (exists) {
: [...selectedList, option]; // remove
onChange(isFullObject ? updated : updated.map((x) => x[valueKey])); updated = selectedList.filter((e) => e[valueKey] !== option[valueKey]);
} else {
// add
updated = [...selectedList, option];
}
if (isFullObject) onChange(updated);
else onChange(updated.map((x) => x[valueKey]));
} }
}; };
@ -474,9 +499,10 @@ export const SelectFieldSearch = ({
</Label> </Label>
)} )}
{/* MAIN BUTTON */}
<button <button
type="button" type="button"
className={`select2-icons form-select d-flex align-items-center justify-content-between ${ className={`select2-icons form-select d-flex align-items-center justify-content-between ${
open ? "show" : "" open ? "show" : ""
}`} }`}
disabled={disabled} disabled={disabled}
@ -487,17 +513,17 @@ export const SelectFieldSearch = ({
</span> </span>
</button> </button>
{errors && <div className="danger-text">{errors.message}</div>} {/* DROPDOWN */}
{open && ( {open && (
<ul <ul
className="dropdown-menu w-100 shadow-sm show animate__fadeIn h-64 overflow-auto rounded rounded-top-0 overflow-x-hidden" className="dropdown-menu w-100 shadow-sm show animate__fadeIn h-64 overflow-auto rounded overflow-x-hidden"
style={{ style={{
position: "absolute", position: "absolute",
top: "100%", top: "100%",
left: 0, left: 0,
zIndex: 1050, zIndex: 1050,
marginTop: "1px", marginTop: "2px",
borderRadius: "0.375rem",
overflow: "hidden", overflow: "hidden",
}} }}
> >
@ -511,40 +537,36 @@ export const SelectFieldSearch = ({
disabled={disabled} disabled={disabled}
/> />
</div> </div>
<div className="overflow-auto px-1" style={{ maxHeight: "200px" }}>
{isLoading && (
<li className="dropdown-item text-muted text-center">
Loading...
</li>
)}
{!isLoading && mergedOptions.length === 0 && (
<li className="dropdown-item text-muted text-center">
No results found
</li>
)}
{!isLoading && {isLoading && (
mergedOptions.map((option) => { <li className="dropdown-item text-muted text-center">Loading...</li>
const isActive = isMultiple )}
? selectedList.some((x) => x[valueKey] === option[valueKey])
: selectedSingle &&
selectedSingle[valueKey] === option[valueKey];
return ( {!isLoading && options.length === 0 && (
<li key={option[valueKey]}> <li className="dropdown-item text-muted text-center">
<button No results found
type="button" </li>
className={`dropdown-item rounded ${ )}
isActive ? "active" : ""
}`} {!isLoading &&
onClick={() => handleSelect(option)} options.map((option) => {
> const isActive = isMultiple
{getDisplayName(option)} ? selectedList.some((x) => x[valueKey] === option[valueKey])
</button> : selectedSingle &&
</li> selectedSingle[valueKey] === option[valueKey];
);
})} return (
</div> <li key={option[valueKey]}>
<button
type="button"
className={`dropdown-item ${isActive ? "active" : ""}`}
onClick={() => handleSelect(option)}
>
{getDisplayName(option)}
</button>
</li>
);
})}
</ul> </ul>
)} )}
</div> </div>

View File

@ -50,6 +50,7 @@ const InputSuggestions = ({
{filteredList.map((org) => ( {filteredList.map((org) => (
<li <li
key={org} key={org}
className="ropdown-item"
style={{ style={{
cursor: "pointer", cursor: "pointer",
padding: "5px 12px", padding: "5px 12px",

View File

@ -6,49 +6,47 @@ import {
PurchaseSchema, PurchaseSchema,
getStepFields, getStepFields,
} from "./PurchaseSchema"; } from "./PurchaseSchema";
import { defaultJobValue } from "../ServiceProject/ServiceProjectSchema";
import PurchasePartyDetails from "./PurchasePartyDetails"; import PurchasePartyDetails from "./PurchasePartyDetails";
import PurchaseTransportDetails from "./PurchaseTransportDetails";
import PurchasePaymentDetails from "./PurchasePaymentDetails";
import { useCreatePurchaseInvoice } from "../../hooks/usePurchase";
const ManagePurchase = ({ onClose }) => { const ManagePurchase = () => {
const [activeTab, setActiveTab] = useState(0); const [activeTab, setActiveTab] = useState(0);
const [completedTabs, setCompletedTabs] = useState([]); const [completedTabs, setCompletedTabs] = useState([]);
const stepsConfig = [ const newTenantConfig = [
{ {
name: "Party Details", name: "Contact Info",
icon: "bx bx-user bx-md", icon: "bx bx-user bx-md",
subtitle: "Supplier & project information", subtitle: "Provide Contact Details",
component: <PurchasePartyDetails />, component: <PurchasePartyDetails />,
}, },
{ {
name: "Invoice & Transport", name: "Organization",
icon: "bx bx-receipt bx-md", icon: "bx bx-buildings bx-md",
subtitle: "Invoice, eWay bill & transport info", subtitle: "Organization Details",
component: <PurchaseTransportDetails />, component: <div>Invoice & Transport Details</div>,
}, },
{ {
name: "Payment Details", name: "SubScription",
icon: "bx bx-credit-card bx-md", icon: "bx bx-star bx-md",
subtitle: "Amount, tax & due date", component: <div>Payment & Financials</div>,
component: <PurchasePaymentDetails />,
}, },
]; ];
const purchaseOrder = useAppForm({ const purchaseOrder = useAppForm({
resolver: zodResolver(PurchaseSchema), resolver: zodResolver(PurchaseSchema),
defaultValues: defaultPurchaseValue, defaultJobValue: defaultPurchaseValue,
mode: "onChange",
}); });
const getCurrentTrigger = () =>
activeTab === 2 ? subscriptionForm.trigger : tenantForm.trigger;
const handleNext = async () => { const handleNext = async () => {
const currentStepFields = getStepFields(activeTab); const currentStepFields = getStepFields(activeTab);
const valid = await purchaseOrder.trigger(currentStepFields); const trigger = getCurrentTrigger();
const valid = await trigger(currentStepFields);
if (valid) { if (valid) {
setCompletedTabs((prev) => [...new Set([...prev, activeTab])]); setCompletedTabs((prev) => [...new Set([...prev, activeTab])]);
setActiveTab((prev) => Math.min(prev + 1, stepsConfig.length - 1)); setActiveTab((prev) => Math.min(prev + 1, newTenantConfig.length - 1));
} }
}; };
@ -56,89 +54,59 @@ const ManagePurchase = ({ onClose }) => {
setActiveTab((prev) => Math.max(prev - 1, 0)); setActiveTab((prev) => Math.max(prev - 1, 0));
}; };
const { mutate: CreateInvoice, isPending } = useCreatePurchaseInvoice(() => { const onsubmit = (formData) => {};
onClose?.();
});
const onSubmit = (formData) => {
console.log("PURCHASE DATA:", formData);
let payload = formData;
CreateInvoice(payload);
};
return ( return (
<div <div
id="wizard-property-listing" id="wizard-property-listing"
className="bs-stepper horizontically mt-2 b-secondry px-1 py-1 shadow-none border-0" className="bs-stepper horizontically mt-2 b-secondry px-1 shadow-none border-0"
> >
{/* Header */} {/* <span className="fs-5">New Parchase</span> */}
<div className="bs-stepper-header text-start px-0 py-1"> <div className="bs-stepper-header text-start px-0">
{stepsConfig.map((step, index) => { {newTenantConfig
const isActive = activeTab === index; .filter((step) => step.name.toLowerCase() !== "congratulation")
const isCompleted = completedTabs.includes(index); .map((step, index) => {
const isActive = activeTab === index;
const isCompleted = completedTabs.includes(index);
return ( return (
<React.Fragment key={step.name}> <React.Fragment key={step.name}>
<div <div
className={`step ${isActive ? "active" : ""} ${ className={`step ${isActive ? "active" : ""} ${
isCompleted ? "crossed" : "" isCompleted ? "crossed" : ""
}`} }`}
> data-target={`#step-${index}`}
<button type="button" className="step-trigger"> >
<span className="bs-stepper-circle">
{isCompleted ? (
<i className="bx bx-check"></i>
) : (
<i className={step.icon}></i>
)}
</span>
<span className="bs-stepper-label">
<span className="bs-stepper-title">{step.name}</span>
<span className="bs-stepper-subtitle">{step.subtitle}</span>
</span>
</button>
</div>
{index < stepsConfig.length - 1 && (
<div className="line text-primary"></div>
)}
</React.Fragment>
);
})}
</div>
{/* Content */}
<div className="bs-stepper-content py-2">
<AppFormProvider {...purchaseOrder}>
<form onSubmit={purchaseOrder.handleSubmit(onSubmit)}>
{stepsConfig[activeTab].component}
<div className="d-flex justify-content-between mt-4">
<button
type="button"
className="btn btn-sm btn-outline-secondary"
onClick={handlePrev}
disabled={activeTab === 0}
>
Previous
</button>
<di>
{activeTab < stepsConfig.length - 1 ? (
<button <button
type="button" type="button"
className="btn btn-sm btn-primary" className={`step-trigger ${isActive ? "active" : ""}`}
onClick={handleNext} // onClick={() => setActiveTab(index)} // optional
> >
Next <i className="bx bx-sm bx-right-arrow"></i> <span className="bs-stepper-circle">
</button> {isCompleted ? (
) : ( <i className="bx bx-check"></i>
<button type="submit" className="btn btn-sm btn-primary"> ) : (
{isPending ? "Please Wait" : "SUbmit"} <i className={step.icon}></i>
)}
</span>
<span className="bs-stepper-label">
<span className="bs-stepper-title">{step.name}</span>
<span className="bs-stepper-subtitle">
{step.subtitle}
</span>
</span>
</button> </button>
</div>
{index < newTenantConfig.length - 1 && (
<div className="line text-primary"></div>
)} )}
</di> </React.Fragment>
</div> );
})}
</div>
<div className="bs-stepper-content py-2">
<AppFormProvider>
<form onSubmit={purchaseOrder.handleSubmit(onsubmit)}>
{newTenantConfig[activeTab].component}
</form> </form>
</AppFormProvider> </AppFormProvider>
</div> </div>

View File

@ -1,242 +1,31 @@
import React from "react"; import React from "react";
import { AppFormController, useAppFormContext } from "../../hooks/appHooks/useAppForm"; import { useAppFormContext } from "../../hooks/appHooks/useAppForm";
import Label from "../common/Label";
import DatePicker from "../common/DatePicker";
import {
SelectFieldSearch,
SelectProjectField,
} from "../common/Forms/SelectFieldServerSide";
import { useGlobaleOrganizations, useOrganization, useOrganizationsList } from "../../hooks/useOrganization";
import { ITEMS_PER_PAGE } from "../../utils/constants";
const PurchasePartyDetails = () => { const PurchasePartyDetails = ({ onNext }) => {
const { const {
register, register,
control, control,
setValue, trigger,
watch,
formState: { errors }, formState: { errors },
} = useAppFormContext(); } = useAppFormContext();
const handleNext = async () => {
return ( const valid = await trigger([
<div className="row g-2 text-start"> "title",
{/* Title */} "projectId",
<div className="col-12 col-md-6"> "organizationId",
<Label htmlFor="title" required> "supplier",
Title "billingAddress",
</Label> "shippingAddress",
"purchaseOrderNumber",
<input "purchaseOrderDate",
id="title" "porformaInvoiceNo",
type="text" ]);
className={`form-control form-control-md ${ if (valid) {
errors?.title ? "is-invalid" : "" onNext();
}`} }
{...register("title")} };
/> return <div className="row"></div>;
{errors?.title && (
<div className="danger-text">{errors.title.message}</div>
)}
</div>
{/* Project ID */}
<div className="col-12 col-md-6">
<SelectProjectField
className={`form-control form-control-md ${
errors?.projectId ? "is-invalid" : ""
}`}
label="Project"
required
placeholder="Select Project"
value={watch("projectId")}
onChange={(val) =>
setValue("projectId", val, {
shouldDirty: true,
shouldValidate: true,
})
}
errors={errors}
/>
</div>
{/* Organization */}
<div className="col-12 col-md-6">
{/* <input
id="organizationId"
type="text"
className={`form-control form-control-md `}
{...register("organizationId")}
/> */}
<AppFormController
name="organizationId"
control={control}
render={({ field }) => (
<SelectFieldSearch
label="Organization"
placeholder="Select Organization"
required
value={field.value}
onChange={field.onChange}
valueKey="id"
labelKey="name"
useFetchHook={useGlobaleOrganizations}
hookParams={[ITEMS_PER_PAGE,1]}
errors={errors?.organizationId}
/>
)}
/>
</div>
{/* Supplier */}
<div className="col-12 col-md-6">
<AppFormController
name="supplierId"
control={control}
render={({ field }) => (
<SelectFieldSearch
label="Supplier"
placeholder="Select Organization"
required
value={field.value}
onChange={field.onChange}
valueKey="id"
labelKey="name"
useFetchHook={useGlobaleOrganizations}
hookParams={[ITEMS_PER_PAGE,1]}
errors={errors?.organizationId}
/>
)}
/>
{errors?.supplierId && (
<div className="danger-text">{errors.supplierId.message}</div>
)}
</div>
{/* Billing Address */}
<div className="col-12 col-md-6">
<Label htmlFor="billingAddress">Billing Address</Label>
<textarea
id="billingAddress"
rows="2"
className={`form-control form-control-md `}
{...register("billingAddress")}
/>
{errors?.billingAddress && (
<div className="danger-text">{errors.billingAddress.message}</div>
)}
</div>
<div className="col-12 col-md-6">
<Label htmlFor="shippingAddress">Shipping Address</Label>
<textarea
id="shippingAddress"
rows="2"
className={`form-control form-control-md `}
{...register("shippingAddress")}
/>
{errors?.shippingAddress && (
<div className="danger-text">{errors.shippingAddress.message}</div>
)}
</div>
{/* Purchase Order Number */}
<div className="col-12 col-md-6">
<Label htmlFor="purchaseOrderNumber" required>
Purchase Order Number
</Label>
<input
id="purchaseOrderNumber"
type="text"
className={`form-control form-control-md `}
{...register("purchaseOrderNumber")}
/>
{errors?.purchaseOrderNumber && (
<div className="danger-text">
{errors.purchaseOrderNumber.message}
</div>
)}
</div>
{/* Purchase Order Date */}
<div className="col-12 col-md-6">
<Label htmlFor="purchaseOrderDate" required>
Purchase Order Date
</Label>
<DatePicker
control={control}
name="purchaseOrderDate"
className={` w-full ${
errors?.purchaseOrderDate ? "is-invalid" : ""
}`}
/>
{errors?.purchaseOrderDate && (
<div className="danger-text">{errors.purchaseOrderDate.message}</div>
)}
</div>
{/* Proforma Invoice */}
<div className="col-12 col-md-6">
<Label htmlFor="proformaInvoiceNumber">Proforma Invoice Number</Label>
<input
id="proformaInvoiceNumber"
type="text"
className={`form-control `}
{...register("proformaInvoiceNumber")}
/>
{errors?.proformaInvoiceNumber && (
<div className="danger-text">
{errors.proformaInvoiceNumber.message}
</div>
)}
</div>
<div className="col-12 col-md-6">
<Label htmlFor="proformaInvoiceAmountt">Proforma Amount</Label>
<input
id="proformaInvoiceAmount"
type="text"
className={`form-control `}
{...register("proformaInvoiceAmount")}
/>
{errors?.proformaInvoiceAmountt && (
<div className="danger-text">
{errors.proformaInvoiceAmount.message}
</div>
)}
</div>
<div className="col-12 col-md-6">
<Label htmlFor="proformaInvoiceDate">Proforma Date</Label>
<DatePicker
control={control}
name="proformaInvoiceDate"
className="w-full"
/>
{errors?.proformaInvoiceDate && (
<div className="danger-text">
{errors.proformaInvoiceDate.message}
</div>
)}
</div>
</div>
);
}; };
export default PurchasePartyDetails; export default PurchasePartyDetails;

View File

@ -1,145 +1,11 @@
import React, { useEffect } from "react"; import React from 'react'
import Label from "../common/Label";
import { useAppFormContext } from "../../hooks/appHooks/useAppForm";
import DatePicker from "../common/DatePicker";
import { useInvoiceAttachmentTypes } from "../../hooks/masterHook/useMaster";
const PurchasePaymentDetails = () => { const PurchasePaymentDetails = () => {
const { data, isLoading, error, isError } = useInvoiceAttachmentTypes();
console.log(data);
const {
register,
watch,
setValue,
control,
formState: { errors },
} = useAppFormContext();
const baseAmount = watch("baseAmount");
const taxAmount = watch("taxAmount");
useEffect(() => {
const base = parseFloat(baseAmount) || 0;
const tax = parseFloat(taxAmount) || 0;
if (base || tax) {
setValue("totalAmount", (base + tax).toFixed(2));
}
}, [baseAmount, taxAmount, setValue]);
return ( return (
<div className="row g-2 text-start"> <div>
<div className="col-12 col-md-4">
<Label htmlFor="baseAmount" required>
Base Amount
</Label>
<input
id="baseAmount"
type="number"
className="form-control form-control-md"
{...register("baseAmount")}
/>
{errors?.baseAmount && (
<div className="small danger-text mt-1">
{errors.baseAmount.message}
</div>
)}
</div>
<div className="col-12 col-md-4">
<Label htmlFor="taxAmount" required>
Tax Amount
</Label>
<input
id="taxAmount"
type="number"
className="form-control form-control-md"
{...register("taxAmount")}
/>
{errors?.taxAmount && (
<div className="small danger-text mt-1">
{errors.taxAmount.message}
</div>
)}
</div>
<div className="col-12 col-md-4">
<Label htmlFor="totalAmount" required>
Total Amount
</Label>
<input
id="totalAmount"
type="number"
className="form-control form-control-md"
{...register("totalAmount")}
readOnly
/>
{errors?.totalAmount && (
<div className="small danger-text mt-1">
{errors.totalAmount.message}
</div>
)}
</div>
<div className="col-12 col-md-6">
<Label htmlFor="transportCharges">Transport Charges</Label>
<input
id="transportCharges"
type="number"
className="form-control form-control-md"
{...register("transportCharges")}
/>
{errors?.transportCharges && (
<div className="small danger-text mt-1">
{errors.transportCharges.message}
</div>
)}
</div>
<div className="col-12 col-md-6">
<Label htmlFor="paymentDueDate">Payment Due Date</Label>
<DatePicker
name={"paymentDueDate"}
control={control}
className="w-full"
/>
{errors?.paymentDueDate && (
<div className="small danger-text mt-1">
{errors.paymentDueDate.message}
</div>
)}
</div>
<div className="col-12">
<Label htmlFor="description" required>
Description
</Label>
<textarea
id="description"
rows="3"
className="form-control form-control-md"
{...register("description")}
/>
{errors?.description && (
<div className="small danger-text mt-1">
{errors.description.message}
</div>
)}
</div>
</div> </div>
); )
}; }
export default PurchasePaymentDetails; export default PurchasePaymentDetails

View File

@ -1,5 +1,4 @@
import { z } from "zod"; import { z } from "zod";
import { normalizeAllowedContentTypes } from "../../utils/appUtils";
export const AttachmentSchema = (allowedContentType, maxSizeAllowedInMB) => { export const AttachmentSchema = (allowedContentType, maxSizeAllowedInMB) => {
const allowedTypes = normalizeAllowedContentTypes(allowedContentType); const allowedTypes = normalizeAllowedContentTypes(allowedContentType);
@ -7,10 +6,6 @@ export const AttachmentSchema = (allowedContentType, maxSizeAllowedInMB) => {
return z.object({ return z.object({
fileName: z.string().min(1, { message: "File name is required" }), fileName: z.string().min(1, { message: "File name is required" }),
base64Data: z.string().min(1, { message: "File data is required" }), base64Data: z.string().min(1, { message: "File data is required" }),
invoiceAttachmentTypeId: z
.string()
.min(1, { message: "File data is required" }),
contentType: z contentType: z
.string() .string()
.min(1, { message: "MIME type is required" }) .min(1, { message: "MIME type is required" })
@ -20,7 +15,6 @@ export const AttachmentSchema = (allowedContentType, maxSizeAllowedInMB) => {
message: `File type must be one of: ${allowedTypes.join(", ")}`, message: `File type must be one of: ${allowedTypes.join(", ")}`,
} }
), ),
fileSize: z fileSize: z
.number() .number()
.int() .int()
@ -29,7 +23,6 @@ export const AttachmentSchema = (allowedContentType, maxSizeAllowedInMB) => {
(maxSizeAllowedInMB ?? 25) * 1024 * 1024, (maxSizeAllowedInMB ?? 25) * 1024 * 1024,
`fileSize must be ≤ ${maxSizeAllowedInMB ?? 25}MB` `fileSize must be ≤ ${maxSizeAllowedInMB ?? 25}MB`
), ),
description: z.string().optional().default(""), description: z.string().optional().default(""),
isActive: z.boolean(), isActive: z.boolean(),
}); });
@ -41,32 +34,27 @@ export const PurchaseSchema = z.object({
organizationId: z.string().min(1, { message: "Organization is required" }), organizationId: z.string().min(1, { message: "Organization is required" }),
billingAddress: z.string().min(1, { message: "Address is required" }), billingAddress: z.string().min(1, { message: "Address is required" }),
shippingAddress: z.string().min(1, { message: "Address is required" }), shippingAddress: z.string().min(1, { message: "Address is required" }),
purchaseOrderNumber: z.string().nullable(), purchaseOrderNumber: z.string().nullable(),
purchaseOrderDate: z.coerce.date().nullable(), purchaseOrderDate: z.string().nullable(),
supplier: z.string().min(1, { message: "Supplier is required" }),
porformaInvoiceNo: z.string().nullable(),
// Supplier Details
supplierId: z.string().min(1, { message: "Supplier is required" }), invoiceNo: z.string().min(1, { message: "Invoice No is required" }),
invoiceDate: z.string().min(1, { message: "Date is required" }),
proformaInvoiceNumber: z.string().nullable(), ewayBillNo: z.string().min(1, { message: "E-Way Bill No is required" }),
proformaInvoiceDate: z.coerce.date().nullable(), ewayBillDate: z.string().min(1, { message: "E-Way Bill Date is required" }),
proformaInvoiceAmount: z.string().nullable(), irnNo: z.string().min(1, { message: "IRN is required" }),
ackDate: z.string().min(1, { message: "Date is required" }),
invoiceNumber: z.string().nullable(), ackNo: z.string().min(1, { message: "acknowledgement No is required" }),
invoiceDate: z.coerce.date().nullable(),
eWayBillNumber: z.string().nullable(),
eWayBillDate: z.coerce.date().nullable(),
invoiceReferenceNumber: z.string().nullable(),
acknowledgmentDate: z.coerce.date().nullable(),
acknowledgmentNumber: z.string().nullable(),
// Payment Detail
baseAmount: z.string().min(1, { message: "Base amount is required" }), baseAmount: z.string().min(1, { message: "Base amount is required" }),
taxAmount: z.string().min(1, { message: "Tax amount is required" }), taxAmount: z.string().min(1, { message: "Tax amount is required" }),
totalAmount: z.string().min(1, { message: "Total amount is required" }), totalAmount: z.string().min(1, { message: "Total amount is required" }),
paymentDueDate: z.coerce.date().nullable(), paymentDueDate: z.string().nullable(),
transportCharges: z.string().nullable(), TransportCharges: z.string().nullable(),
description: z.string().min(1, { message: "Description is required" }), description: z.string().min(1, { message: "description is required" }),
attachments: z.array(AttachmentSchema([], 25)).optional(),
}); });
// deliveryChallanNo: z // deliveryChallanNo: z
@ -76,36 +64,30 @@ export const PurchaseSchema = z.object({
// shippingAddress: z.string().min(1, { message: "Delevery Date is required" }), // shippingAddress: z.string().min(1, { message: "Delevery Date is required" }),
export const defaultPurchaseValue = { export const defaultPurchaseValue = {
title: "", title: null,
projectId: "", projectId: null,
organizationId: "", organizationId: null,
billingAddress: "", billingAddress: null,
shippingAddress: "", shippingAddress: null,
purchaseOrderNumber: null, purchaseOrderNumber: null,
purchaseOrderDate: null, purchaseOrderDate: null,
supplier: null,
porformaInvoiceNo: null,
supplierId: "", invoiceNo: null,
proformaInvoiceNumber: null,
proformaInvoiceDate: null,
proformaInvoiceAmount: null,
invoiceNumber: null,
invoiceDate: null, invoiceDate: null,
eWayBillNumber: null, ewayBillNo: null,
eWayBillDate: null, ewayBillDate: null,
invoiceReferenceNumber: null, irnNo: null,
acknowledgmentNumber: null, ackDate: null,
acknowledgmentDate: null, ackNo: null,
baseAmount: "", baseAmount: null,
taxAmount: "", taxAmount: null,
totalAmount: "", totalAmount: null,
paymentDueDate: null, paymentDueDate: null,
transportCharges: null, TransportCharges: null,
description: "", description: null,
attachments: [],
}; };
export const getStepFields = (stepIndex) => { export const getStepFields = (stepIndex) => {
@ -114,29 +96,28 @@ export const getStepFields = (stepIndex) => {
"title", "title",
"projectId", "projectId",
"organizationId", "organizationId",
"supplierId", "supplier",
"billingAddress", "billingAddress",
"shippingAddress", "shippingAddress",
"purchaseOrderNumber", "purchaseOrderNumber",
"purchaseOrderDate", "purchaseOrderDate",
"proformaInvoiceNumber", "porformaInvoiceNo",
"proformaInvoiceDate",
"proformaInvoiceAmount",
], ],
1: [ 1: [
"invoiceNumber", "invoiceNo",
"invoiceDate", "invoiceDate",
"eWayBillNumber", "ewayBillNo",
"eWayBillDate", "ewayBillDate",
"invoiceReferenceNumber", "irnNo",
"acknowledgmentNumber", "ackNo",
"acknowledgmentDate", "taxId",
"ackDate",
], ],
2: [ 2: [
"baseAmount", "baseAmount",
"taxAmount", "taxAmount",
"totalAmount", "totalAmount",
"transportCharges", "TransportCharges",
"paymentDueDate", "paymentDueDate",
"description", "description",
], ],

View File

@ -0,0 +1,11 @@
import React from 'react'
const PurchaseTansportDetails = () => {
return (
<div>
</div>
)
}
export default PurchaseTansportDetails

View File

@ -1,131 +0,0 @@
import React from "react";
import { useAppFormContext } from "../../hooks/appHooks/useAppForm";
import DatePicker from "../common/DatePicker";
import Label from "../common/Label";
const PurchaseTransportDetails = () => {
const {
register,control,
formState: { errors },
} = useAppFormContext();
return (
<div className="row g-2 text-start">
{/* Invoice Number */}
<div className="col-12 col-md-6">
<Label htmlFor="invoiceNumber" required>
Invoice Number
</Label>
<input
id="invoiceNumber"
type="text"
className="form-control form-control-md"
{...register("invoiceNumber")}
/>
{errors?.invoiceNumber && (
<div className="small text-danger mt-1">
{errors.invoiceNumber.message}
</div>
)}
</div>
{/* Invoice Date */}
<div className="col-12 col-md-6">
<Label htmlFor="invoiceDate">Invoice Date</Label>
<DatePicker control={control} name="invoiceDate" className="w-full"/>
{errors?.invoiceDate && (
<div className="small text-danger mt-1">
{errors.invoiceDate.message}
</div>
)}
</div>
{/* E-Way Bill Number */}
<div className="col-12 col-md-6">
<Label htmlFor="eWayBillNumber">E-Way Bill Number</Label>
<input
id="eWayBillNumber"
type="text"
className="form-control form-control-md"
{...register("eWayBillNumber")}
/>
{errors?.eWayBillNumber && (
<div className="small text-danger mt-1">
{errors.eWayBillNumber.message}
</div>
)}
</div>
{/* E-Way Bill Date */}
<div className="col-12 col-md-6">
<Label htmlFor="eWayBillDate">E-Way Bill Date</Label>
<DatePicker control={control} name="eWayBillDate" className="w-full"/>
{errors?.eWayBillDate && (
<div className="small text-danger mt-1">
{errors.eWayBillDate.message}
</div>
)}
</div>
{/* Invoice Reference Number */}
<div className="col-12 col-md-6">
<Label htmlFor="invoiceReferenceNumber">Invoice Reference Number</Label>
<input
id="invoiceReferenceNumber"
type="text"
className="form-control form-control-md"
{...register("invoiceReferenceNumber")}
/>
{errors?.invoiceReferenceNumber && (
<div className="small text-danger mt-1">
{errors.invoiceReferenceNumber.message}
</div>
)}
</div>
{/* Acknowledgment Number */}
<div className="col-12 col-md-6">
<Label htmlFor="acknowledgmentNumber">Acknowledgment Number</Label>
<input
id="acknowledgmentNumber"
type="text"
className="form-control form-control-md"
{...register("acknowledgmentNumber")}
/>
{errors?.acknowledgmentNumber && (
<div className="small text-danger mt-1">
{errors.acknowledgmentNumber.message}
</div>
)}
</div>
<div className="col-12 col-md-6">
<Label htmlFor="acknowledgmentDate">Acknowledgment Date</Label>
<DatePicker control={control} name="acknowledgmentDate" className="w-full"/>
{errors?.acknowledgmentDate && (
<div className="small text-danger mt-1">
{errors.acknowledgmentDate.message}
</div>
)}
</div>
</div>
);
};
export default PurchaseTransportDetails;

View File

@ -10,25 +10,16 @@ import {
} from "@tanstack/react-query"; } from "@tanstack/react-query";
import showToast from "../../services/toastService"; import showToast from "../../services/toastService";
export const useInvoiceAttachmentTypes = () => {
return useQuery({
queryKey: ["invoiceAttachmentType"],
queryFn: async () => {
const resp = await MasterRespository.getInvoiceAttachmentTypes();
return resp.data;
},
});
};
export const useRecurringStatus = () => { export const useRecurringStatus = ()=>{
return useQuery({ return useQuery({
queryKey: ["RecurringStatus"], queryKey:["RecurringStatus"],
queryFn: async () => { queryFn:async()=>{
const resp = await MasterRespository.getRecurringStatus(); const resp = await MasterRespository.getRecurringStatus();
return resp.data; return resp.data
}, }
}); })
}; }
export const useCurrencies = () => { export const useCurrencies = () => {
return useQuery({ return useQuery({
queryKey: ["currencies"], queryKey: ["currencies"],
@ -40,10 +31,10 @@ export const useCurrencies = () => {
}; };
export const usePaymentAjustmentHead = (isActive) => { export const usePaymentAjustmentHead = (isActive) => {
return useQuery({ return useQuery({
queryKey: ["paymentType", isActive], queryKey: ["paymentType",isActive],
queryFn: async () => queryFn: async () => await MasterRespository.getPaymentAdjustmentHead(isActive),
await MasterRespository.getPaymentAdjustmentHead(isActive),
}); });
}; };
@ -305,26 +296,26 @@ export const useOrganizationType = () => {
}); });
}; };
export const useJobStatus = (statusId, projectId) => { export const useJobStatus=(statusId,projectId)=>{
return useQuery({ return useQuery({
queryKey: ["Job_Staus", statusId, projectId], queryKey:["Job_Staus",statusId,projectId],
queryFn: async () => { queryFn:async()=>{
const resp = await MasterRespository.getJobStatus(statusId, projectId); const resp = await MasterRespository.getJobStatus(statusId,projectId);
return resp.data; return resp.data;
}, },
enabled: !!statusId && !!projectId, enabled:!!statusId && !!projectId
}); })
}; }
export const useTeamRole = () => { export const useTeamRole=()=>{
return useQuery({ return useQuery({
queryKey: ["Team_Role"], queryKey:["Team_Role"],
queryFn: async () => { queryFn:async()=>{
const resp = await MasterRespository.getTeamRole(); const resp = await MasterRespository.getTeamRole();
return resp.data; return resp.data;
}, }
}); })
}; }
//#region ==Get Masters== //#region ==Get Masters==
const fetchMasterData = async (masterType) => { const fetchMasterData = async (masterType) => {
switch (masterType) { switch (masterType) {
@ -414,6 +405,8 @@ const useMaster = () => {
export default useMaster; export default useMaster;
//#endregion //#endregion
// ================================Mutation==================================== // ================================Mutation====================================
//#region Job Role //#region Job Role
@ -463,6 +456,10 @@ export const useCreateJobRole = (onSuccessCallback) => {
}; };
//#endregion Job Role //#endregion Job Role
//#region Application Role //#region Application Role
export const useCreateApplicationRole = (onSuccessCallback) => { export const useCreateApplicationRole = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -508,6 +505,10 @@ export const useUpdateApplicationRole = (onSuccessCallback) => {
}; };
//#endregion //#endregion
//#region Create work Category //#region Create work Category
export const useCreateWorkCategory = (onSuccessCallback) => { export const useCreateWorkCategory = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -553,6 +554,11 @@ export const useUpdateWorkCategory = (onSuccessCallback) => {
}; };
//#endregion //#endregion
//#region Contact Category //#region Contact Category
export const useCreateContactCategory = (onSuccessCallback) => { export const useCreateContactCategory = (onSuccessCallback) => {
@ -603,6 +609,10 @@ export const useUpdateContactCategory = (onSuccessCallback) => {
//#endregion //#endregion
//#region Contact Tag //#region Contact Tag
export const useCreateContactTag = (onSuccessCallback) => { export const useCreateContactTag = (onSuccessCallback) => {
@ -649,6 +659,10 @@ export const useUpdateContactTag = (onSuccessCallback) => {
}; };
//#endregion //#endregion
//#region Expense Category //#region Expense Category
export const useCreateExpenseCategory = (onSuccessCallback) => { export const useCreateExpenseCategory = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -675,10 +689,7 @@ export const useUpdateExpenseCategory = (onSuccessCallback) => {
return useMutation({ return useMutation({
mutationFn: async ({ id, payload }) => { mutationFn: async ({ id, payload }) => {
const response = await MasterRespository.updateExpenseCategory( const response = await MasterRespository.updateExpenseCategory(id, payload);
id,
payload
);
return response.data; return response.data;
}, },
onSuccess: (data, variables) => { onSuccess: (data, variables) => {
@ -697,6 +708,11 @@ export const useUpdateExpenseCategory = (onSuccessCallback) => {
//#endregion //#endregion
//#region Payment Mode //#region Payment Mode
export const useCreatePaymentMode = (onSuccessCallback) => { export const useCreatePaymentMode = (onSuccessCallback) => {
@ -743,6 +759,10 @@ export const useUpdatePaymentMode = (onSuccessCallback) => {
//#endregion //#endregion
// Services------------------------------- // Services-------------------------------
// export const useCreateService = (onSuccessCallback) => { // export const useCreateService = (onSuccessCallback) => {
@ -824,6 +844,10 @@ export const useUpdateService = (onSuccessCallback) => {
//#endregion //#endregion
//#region Activity Grouph //#region Activity Grouph
export const useCreateActivityGroup = (onSuccessCallback) => { export const useCreateActivityGroup = (onSuccessCallback) => {
@ -888,6 +912,10 @@ export const useUpdateActivityGroup = (onSuccessCallback) => {
//#endregion //#endregion
//#region Activities //#region Activities
export const useCreateActivity = (onSuccessCallback) => { export const useCreateActivity = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -942,6 +970,11 @@ export const useUpdateActivity = (onSuccessCallback) => {
//#endregion //#endregion
//#region Expense Status //#region Expense Status
export const useCreateExpenseStatus = (onSuccessCallback) => { export const useCreateExpenseStatus = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -985,6 +1018,10 @@ export const useUpdateExpenseStatus = (onSuccessCallback) => {
}; };
//#endregion //#endregion
//#region Document-Category //#region Document-Category
export const useCreateDocumentCatgory = (onSuccessCallback) => { export const useCreateDocumentCatgory = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -1031,6 +1068,11 @@ export const useUpdateDocumentCategory = (onSuccessCallback) => {
}; };
//#endregion //#endregion
//#region Document-Type //#region Document-Type
export const useCreateDocumentType = (onSuccessCallback) => { export const useCreateDocumentType = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -1075,6 +1117,10 @@ export const useUpdateDocumentType = (onSuccessCallback) => {
}; };
//#endregion //#endregion
//#region Payment Adjustment Head //#region Payment Adjustment Head
export const useCreatePaymentAjustmentHead = (onSuccessCallback) => { export const useCreatePaymentAjustmentHead = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -1101,10 +1147,7 @@ export const useUpdatePaymentAjustmentHead = (onSuccessCallback) => {
return useMutation({ return useMutation({
mutationFn: async ({ id, payload }) => { mutationFn: async ({ id, payload }) => {
const resp = await MasterRespository.updatePaymentAjustmentHead( const resp = await MasterRespository.updatePaymentAjustmentHead(id, payload);
id,
payload
);
return resp.data; return resp.data;
}, },
onSuccess: (data) => { onSuccess: (data) => {
@ -1121,6 +1164,10 @@ export const useUpdatePaymentAjustmentHead = (onSuccessCallback) => {
}; };
//#endregion //#endregion
//#region ==Delete Master== //#region ==Delete Master==
export const useDeleteMasterItem = () => { export const useDeleteMasterItem = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -1156,6 +1203,8 @@ export const useDeleteMasterItem = () => {
//#endregion //#endregion
export const useDeleteServiceGroup = () => { export const useDeleteServiceGroup = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();

View File

@ -24,9 +24,7 @@ export const useOrganizationModal = () => {
dispatch( dispatch(
openOrgModal({ openOrgModal({
isOpen: true, isOpen: true,
orgData: options.hasOwnProperty("orgData") orgData: options.hasOwnProperty("orgData") ? options.orgData : orgData,
? options.orgData
: orgData,
startStep: options.startStep ?? startStep ?? 1, startStep: options.startStep ?? startStep ?? 1,
prevStep: options.prevStep ?? prevStep ?? 1, prevStep: options.prevStep ?? prevStep ?? 1,
flowType: options.flowType ?? flowType ?? "default", flowType: options.flowType ?? flowType ?? "default",
@ -39,30 +37,16 @@ export const useOrganizationModal = () => {
// ================================Query============================================================= // ================================Query=============================================================
export const useGlobaleOrganizations = (pageSize, pageNumber, searchString) => { export const useOrganization=(id)=>{
return useQuery({ return useQuery({
queryKey: ["global_organization",pageSize, pageNumber, searchString], queryKey:["organization",id],
queryFn: async () => { queryFn:async()=> {
const resp = await OrganizationRepository.getGlobalOrganization( const resp = await await OrganizationRepository.getOrganizaion(id);
pageSize, return resp.data
pageNumber, },
searchString enabled:!!id
); })
return resp.data; }
},
});
};
export const useOrganization = (id) => {
return useQuery({
queryKey: ["organization", id],
queryFn: async () => {
const resp = await await OrganizationRepository.getOrganizaion(id);
return resp.data;
},
enabled: !!id,
});
};
export const useOrganizationBySPRID = (sprid) => { export const useOrganizationBySPRID = (sprid) => {
return useQuery({ return useQuery({
queryKey: ["organization by", sprid], queryKey: ["organization by", sprid],
@ -117,7 +101,7 @@ export const useOrganizationEmployees = (
organizationId, organizationId,
searchString searchString
), ),
enabled: !!projectId, enabled: !!projectId ,
}); });
}; };
@ -154,10 +138,10 @@ export const useAssignOrgToProject = (onSuccessCallback) => {
useClient.invalidateQueries({ useClient.invalidateQueries({
queryKey: ["projectAssignedOrganiztions"], queryKey: ["projectAssignedOrganiztions"],
}); });
useClient.invalidateQueries({ useClient.invalidateQueries({
queryKey: ["projectAssignedOrganiztionsName"], queryKey: ["projectAssignedOrganiztionsName"],
}); });
useClient.invalidateQueries({ useClient.invalidateQueries({
queryKey: ["projectAssignedServices", projectId], queryKey: ["projectAssignedServices", projectId],
}); });
@ -197,14 +181,12 @@ export const useAssignOrgToTenant = (onSuccessCallback) => {
export const useUpdateOrganization = (onSuccessCallback) => { export const useUpdateOrganization = (onSuccessCallback) => {
const useClient = useQueryClient(); const useClient = useQueryClient();
return useMutation({ return useMutation({
mutationFn: async ({ orgId, payload }) => mutationFn: async ({orgId,payload}) =>
await OrganizationRepository.updateOrganizaion(orgId, payload), await OrganizationRepository.updateOrganizaion(orgId,payload),
onSuccess: (_, variables) => { onSuccess: (_, variables) => {
useClient.invalidateQueries({ queryKey: ["organizationList"] }); useClient.invalidateQueries({ queryKey: ["organizationList"] });
useClient.invalidateQueries({ useClient.invalidateQueries({ queryKey: ["projectAssignedOrganiztionsName"] });
queryKey: ["projectAssignedOrganiztionsName"],
});
showToast("Organization Updated successfully", "success"); showToast("Organization Updated successfully", "success");
if (onSuccessCallback) onSuccessCallback(); if (onSuccessCallback) onSuccessCallback();
}, },

View File

@ -1,25 +0,0 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { PurchaseRepository } from "../repositories/PurchaseRepository";
export const useCreatePurchaseInvoice = (onSuccessCallback) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (payload) =>
await PurchaseRepository.CreatePurchase(payload),
onSuccess: (data, variables) => {
showToast("Purchase Invoice Created successfully", "success");
if (onSuccessCallback) onSuccessCallback();
},
onError: (error) => {
showToast(
error?.response?.data?.message ||
error.message ||
"Failed to create invoice",
"error"
);
},
});
};

View File

@ -157,7 +157,4 @@ export const MasterRespository = {
), ),
getTeamRole: () => api.get(`/api/Master/team-roles/list`), getTeamRole: () => api.get(`/api/Master/team-roles/list`),
getInvoiceAttachmentTypes:()=>api.get("/api/Master/invoice-attachment-type/list")
}; };

View File

@ -2,9 +2,8 @@ import { api } from "../utils/axiosClient";
const OrganizationRepository = { const OrganizationRepository = {
createOrganization: (data) => api.post("/api/Organization/create", data), createOrganization: (data) => api.post("/api/Organization/create", data),
updateOrganizaion: (id, data) => updateOrganizaion:(id,data)=>api.put(`/api/Organization/edit/${id}`,data),
api.put(`/api/Organization/edit/${id}`, data), getOrganizaion:(id)=>api.get(`/api/Organization/details/${id}`),
getOrganizaion: (id) => api.get(`/api/Organization/details/${id}`),
getOrganizationList: (pageSize, pageNumber, active, sprid, searchString) => { getOrganizationList: (pageSize, pageNumber, active, sprid, searchString) => {
return api.get( return api.get(
`/api/Organization/list?pageSize=${pageSize}&pageNumber=${pageNumber}&active=${active}&${ `/api/Organization/list?pageSize=${pageSize}&pageNumber=${pageNumber}&active=${active}&${
@ -40,11 +39,6 @@ const OrganizationRepository = {
return api.get(url); return api.get(url);
}, },
getGlobalOrganization: (pageSize, pageNumber, searchString) =>
api.get(
`/api/Organization/list/basic?pageSize=${pageSize}&pageNumber=${pageNumber}&searchString=${searchString}`
),
}; };
export default OrganizationRepository; export default OrganizationRepository;

View File

@ -1,5 +0,0 @@
import { api } from "../utils/axiosClient";
export const PurchaseRepository = {
CreatePurchase: (data) => api.post("/api/PurchaseInvoice/create", data),
};