diff --git a/src/Pages/IO_Management/ViewIO/ViewIOdataHeader.jsx b/src/Pages/IO_Management/ViewIO/ViewIOdataHeader.jsx
index 4e1fed3..ba4a2e3 100644
--- a/src/Pages/IO_Management/ViewIO/ViewIOdataHeader.jsx
+++ b/src/Pages/IO_Management/ViewIO/ViewIOdataHeader.jsx
@@ -132,7 +132,7 @@ const ViewIOdataHeader = () => {
h={"100%"}
w={"100%"}
objectFit={'cover'}
- src={" https://admin.tanami.betadelivery.com/" + IODetails?.artifactsImage?.[0]?.artifactPathName}
+ src={" https://tanami.betadelivery.com/" + IODetails?.artifactsImage?.[0]?.artifactPathName}
alt={IODetails?.ioName}
/>
) : (
diff --git a/src/Pages/Master/ExchangeRate/EditExchangeRate.jsx b/src/Pages/Master/ExchangeRate/EditExchangeRate.jsx
index 3f0cf30..f78979c 100644
--- a/src/Pages/Master/ExchangeRate/EditExchangeRate.jsx
+++ b/src/Pages/Master/ExchangeRate/EditExchangeRate.jsx
@@ -14,6 +14,7 @@ import {
Text,
Tooltip,
useDisclosure,
+ useToast,
} from "@chakra-ui/react";
import React, { useContext, useRef, useState, useEffect } from "react";
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
@@ -22,6 +23,9 @@ import { FiEdit3 } from "react-icons/fi";
import { BiMessageSquareEdit } from "react-icons/bi";
import { TbEdit } from "react-icons/tb";
import { EditIcon, ViewIcon } from "@chakra-ui/icons";
+import { formatDate } from "../../../Components/Functions/UTCConvertor";
+import { useGetExchangeRateByIdQuery, useUpdateExchangeRateMutation } from "../../../Services/exchange.rate.service";
+import ToastBox from "../../../Components/ToastBox";
// Convert date to YYYY-MM-DD format
const formatDateValue = (date) => {
@@ -39,70 +43,84 @@ const formatDateValue = (date) => {
const EditExchangeRate = ({ id, setIsLoading, updateHistory }) => {
const btnRef = useRef();
+ const toast = useToast();
const { isOpen, onOpen, onClose } = useDisclosure();
const { rateExchange, setRateExchange } = useContext(GlobalStateContext);
+ const [ isBtnLoading, setIsBtnLoading ] = useState(false)
- const foundObject = rateExchange.find((item) => item.id === id);
+ const { data, isLoading, errors } = useGetExchangeRateByIdQuery(id, {
+ skip: !id,
+ });
- const [effectFrom, setEffectFrom] = useState("");
- const [effectTill, setEffectTill] = useState("");
- const [rate, setRate] = useState("");
+ const [ updateExchange ] = useUpdateExchangeRateMutation()
+ const foundObject = data?.data;
+ const [rate, setRate] = useState("");
const [alert, setAlert] = useState(false);
useEffect(() => {
if (foundObject) {
- setEffectFrom(formatDateValue(foundObject.effectFrom));
- setEffectTill(formatDateValue(foundObject.effectTill));
setRate(foundObject.rate);
}
}, [foundObject]);
- const handleSave = () => {
- setIsLoading(true);
- const previousRate = foundObject.rate;
- const updatedExchange = rateExchange.map((item) =>
- item.id === id
- ? {
- ...item,
- effectFrom: new Date(effectFrom),
- effectTill: new Date(effectTill),
- rate: parseFloat(rate),
- }
- : item
- );
- setTimeout(() => {
- setRateExchange(updatedExchange);
- updateHistory(id, previousRate, parseFloat(rate), new Date(effectFrom));
- setIsLoading(false);
- setAlert(false);
- onClose();
- }, 100);
- setIsLoading(true);
+ const handleSave = async () => {
+ setIsBtnLoading(true)
+ try {
+
+ const data = {
+ rate: rate
+ }
+ const res = await updateExchange({data, id})
+ console.log(res?.data?.statusCode);
+ if (res?.data?.statusCode === 200) {
+ console.log("hit");
+ toast({
+ render: () => ,
+ });
+ setIsBtnLoading(false)
+ setAlert(false)
+ onClose()
+ }
+
+ } catch (error) {
+
+ }
+
+
+
+
+
};
return (
- <>
-
+
{
From
- {foundObject?.fromCurr}
+ {foundObject?.fromCurrency_xid}
To
- {foundObject?.toCurr}
+ {foundObject?.toCurrency_xid}
Effective from
- setEffectFrom(e.target.value)}
- fontSize={"sm"}
- type="date"
- size={"sm"}
- />
-
-
-
- Effective to
- setEffectTill(e.target.value)}
- type="date"
- size={"sm"}
- />
+ {formatDate(foundObject?.effectiveFrom)}
@@ -185,12 +187,12 @@ const EditExchangeRate = ({ id, setIsLoading, updateHistory }) => {
-
setAlert(false)}
alertHandler={handleSave}
message={"Are you sure you want to update rates?"}
+ isLoading={isBtnLoading}
/>
>
);
diff --git a/src/Pages/Master/ExchangeRate/ExchangeHistroy.jsx b/src/Pages/Master/ExchangeRate/ExchangeHistroy.jsx
index 16580db..2d6dd79 100644
--- a/src/Pages/Master/ExchangeRate/ExchangeHistroy.jsx
+++ b/src/Pages/Master/ExchangeRate/ExchangeHistroy.jsx
@@ -100,9 +100,15 @@ const ExchangeHistory = ({ id, setIsLoading, history }) => {
// transition={"0.5s all"}
color="purple.400"
rounded={"sm"}
- size={"xs"}
+ size={{base:'xs', lg:'xs'}}
+
+
+ display={'flex'}
+ alignItems={'center'}
+ gap={1}
+
>
-
+ View history
{
const toast = useToast();
@@ -43,6 +45,18 @@ const ExchangeRate = () => {
const [mouseEnteredId, setMouseEnteredId] = useState("");
const [history, setHistory] = useState([]);
+ // ===============================[ Paginations ]
+ const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
+ const [currentPage, setCurrentPage] = useState(1);
+
+ const {
+ data,
+ isLoading: isExchangeRateLoading,
+ errors,
+ } = useGetAllExchangeRatesQuery({ page: currentPage, size: pageSize })
+
+ console.log(data?.data);
+
useEffect(() => {
// Simulate loading
const timer = setTimeout(() => {
@@ -85,12 +99,11 @@ const ExchangeRate = () => {
"From currency",
"To currency",
"Effective from",
- "Effective till",
"Rate",
"Action",
];
- const extractedArray = filteredData?.map((item, index) => ({
+ const extractedArray = data?.data?.map((item, index) => ({
"Sr.No": (
{
fontWeight={"600"}
className="d-flex align-items-center fw- web-text-small"
>
- {item.fromCurr}
+ {item.fromCurrency_xid}
),
"To currency": (
@@ -121,7 +134,7 @@ const ExchangeRate = () => {
fontWeight={"600"}
className="d-flex align-items-center fw- web-text-small"
>
- {item.toCurr}
+ {item.toCurrency_xid}
),
"Effective from": (
@@ -132,18 +145,7 @@ const ExchangeRate = () => {
fontWeight={"600"}
className="d-flex align-items-center web-text-small"
>
- {formatDate(item.effectFrom)}
-
- ),
- "Effective till": (
-
- {formatDate(item.effectTill)}
+ {formatDate(item.effectiveFrom)}
),
Rate: (
diff --git a/src/Services/exchange.rate.service.js b/src/Services/exchange.rate.service.js
index f5cd131..a08dca4 100644
--- a/src/Services/exchange.rate.service.js
+++ b/src/Services/exchange.rate.service.js
@@ -1,22 +1,41 @@
// exchangeRate.service.js
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
+import { api } from "./api.service";
-const baseUrl = import.meta.env.VITE_API_BASE_URL + "/api";
+const baseUrl = api?.defaults.baseURL;
// Define a service using a base URL and expected endpoints
export const exchangeRate = createApi({
reducerPath: "exchangeRate",
baseQuery: fetchBaseQuery({ baseUrl }),
- tagTypes: [],
+ tagTypes: ["getAllExchangeRate", "getExchangeById"],
+
endpoints: (builder) => ({
- getExchangeRates: builder.query({
- query: () => '/getExchangeRates',
+ getAllExchangeRates: builder.query({
+ query: ({ page, size }) =>
+ `/currencyExchange/admin?page=${page}&size=${size}`,
+ providesTags: ["getAllExchangeRate"],
}),
+
getExchangeRateById: builder.query({
- query: (id) => `/getExchangeRate/${id}`,
+ query: (id) => `/currencyExchange/admin/${id}`,
+ providesTags: ["getAllExchangeRate"],
+ }),
+
+ updateExchangeRate: builder.mutation({
+ query: ({ data, id }) => ({
+ url: `/currencyExchange/admin/${id}`,
+ method: "PATCH",
+ body: data,
+ }),
+ invalidatesTags: ["getAllExchangeRate"],
}),
}),
});
// Export hooks for usage in functional components
-export const { useGetExchangeRatesQuery, useGetExchangeRateByIdQuery } = exchangeRate;
+export const {
+ useGetAllExchangeRatesQuery,
+ useGetExchangeRateByIdQuery,
+ useUpdateExchangeRateMutation,
+} = exchangeRate;
diff --git a/src/Services/io.service.js b/src/Services/io.service.js
index 65dc28d..6170c2a 100644
--- a/src/Services/io.service.js
+++ b/src/Services/io.service.js
@@ -198,12 +198,6 @@ export const ioService = createApi({
}),
invalidatesTags: ["getIOById"],
}),
-
-
-
-
-
-
updateStatusIo: builder.mutation({
query: ({ data, id }) => ({