Refactor_Expenses #321
@ -168,7 +168,7 @@ const ExpenseList = () => {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="d-none d-md-table-cell"><i className='bx bx-rupee b-xs'></i>{expense.amount}</td>
|
<td className="d-none d-md-table-cell text-end"><i className='bx bx-rupee b-xs'></i>{expense.amount}</td>
|
||||||
<td>
|
<td>
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@ -67,3 +67,8 @@ export const ExpenseSchema = (expenseTypes) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ActionSchema = z.object({
|
||||||
|
comment : z.string().min(1,{message:"Please leave comment"}),
|
||||||
|
selectedStatus: z.string().min(1, { message: "Please select a status" }),
|
||||||
|
})
|
||||||
@ -24,8 +24,6 @@ export const useExpense =(ExpenseId)=>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------Mutation---------------------------------------------
|
// ---------------------------Mutation---------------------------------------------
|
||||||
|
|
||||||
export const useCreateExpnse =(onSuccessCallBack)=>{
|
export const useCreateExpnse =(onSuccessCallBack)=>{
|
||||||
@ -40,29 +38,24 @@ export const useCreateExpnse =(onSuccessCallBack)=>{
|
|||||||
if (onSuccessCallBack) onSuccessCallBack();
|
if (onSuccessCallBack) onSuccessCallBack();
|
||||||
},
|
},
|
||||||
onError:(error)=>{
|
onError:(error)=>{
|
||||||
showToast(error.message || "Something went wrong please try again !","success")
|
showToast(error.message || "Something went wrong please try again !","error")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useActionOnExpense=(onSuccessCallBack)=>{
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async(payload)=>{
|
||||||
|
await ExpenseRepository.ActionOnExpense(payload)
|
||||||
|
},
|
||||||
|
onSuccess:(data,variables)=>{
|
||||||
|
console.log(data)
|
||||||
|
showToast("Expense Created Successfully","success")
|
||||||
|
if (onSuccessCallBack) onSuccessCallBack();
|
||||||
|
},
|
||||||
|
onError:(error)=>{
|
||||||
|
showToast(error.message || "Something went wrong please try again !","error")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const demoExpense = {
|
|
||||||
projectId: "proj_123",
|
|
||||||
expensesTypeId: "1", // corresponds to Travel
|
|
||||||
paymentModeId: "pm_456",
|
|
||||||
paidById: "emp_789",
|
|
||||||
transactionDate: "2025-07-21",
|
|
||||||
transactionId: "TXN-001234",
|
|
||||||
description: "Taxi fare from airport to hotel",
|
|
||||||
location: "New York",
|
|
||||||
supplerName: "City Taxi Service",
|
|
||||||
amount: 45.50,
|
|
||||||
noOfPersons: 2,
|
|
||||||
billAttachments: [
|
|
||||||
{
|
|
||||||
fileName: "receipt.pdf",
|
|
||||||
base64Data: "JVBERi0xLjQKJcfs...", // truncated base64 example string
|
|
||||||
contentType: "application/pdf",
|
|
||||||
fileSize: 450000, // less than 5MB
|
|
||||||
description: "Taxi receipt",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user