Skip to content

Commit

Permalink
#93 frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
fdhhhdjd committed Nov 5, 2022
1 parent cadd27a commit e7bda43
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 10 deletions.
Binary file modified dump.rdb
Binary file not shown.
4 changes: 4 additions & 0 deletions frontend/src/v1/configs/Apis/Payment_Api/Api_Payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const API_PAYMENT = {
// * TRANSACTION TRIPE
API_TRANSACTION_PAYMENT_STRIPE: "/api/payment/stripe",

//* TRANSACTION_PAYMENT_STRIPE_SUCCESS

API_TRANSACTION_PAYMENT_STRIPE_SUCCESS: "/api/payment/stripe/success",

//* CHECK TOTAL PAYMENT
API_TOTAL_PAYMENT: "/api/payment/total"
};
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/v1/redux/payment_slice/Api_Redux_Thunk_Payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,25 @@ export const Transaction_Payment_Stripe_Initial = createAsyncThunk(
}
}
);
export const Transaction_Payment_Stripe_success_Initial = createAsyncThunk(
"Payment/Transaction/Stripe/Success",
async ({ accessToken, id }, { rejectWithValue }) => {
const config = {
headers: {
Authorization: `Bearer ${accessToken}`,
},
};
try {
const response = await axios.get(
`${API_PAYMENT.API_TRANSACTION_PAYMENT_STRIPE_SUCCESS}/${id}`,
config
);
return response.data;
} catch (error) {
if (!error.response) {
throw error;
}
return rejectWithValue(error.response.data);
}
}
);
16 changes: 14 additions & 2 deletions frontend/src/v1/redux/payment_slice/payment_slice.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice } from "@reduxjs/toolkit";
import {
Get_Detail_User_Payment_Initial, Check_Stock_Product_Initial, Check_Total_Cart_Initial,
Transaction_Payment_Initial, Transaction_Payment_Stripe_Initial
Transaction_Payment_Initial, Transaction_Payment_Stripe_Initial, Transaction_Payment_Stripe_success_Initial
} from "./Api_Redux_Thunk_Payment";
const initialState = {
loading: false,
Expand Down Expand Up @@ -80,7 +80,7 @@ const Payments = createSlice({
state.loading = false;
state.error = action.payload;
},
//* Transaction Payment Paypal
//* Transaction Payment Stripe
[Transaction_Payment_Stripe_Initial.pending]: (state, action) => {
state.loading = true;
},
Expand All @@ -92,6 +92,18 @@ const Payments = createSlice({
state.loading = false;
state.error = action.payload;
},
//* Transaction Payment Stripe Success
[Transaction_Payment_Stripe_success_Initial.pending]: (state, action) => {
state.loading = true;
},
[Transaction_Payment_Stripe_success_Initial.fulfilled]: (state, action) => {
state.loading = false;
state.transaction = action.payload.element;
},
[Transaction_Payment_Stripe_success_Initial.rejected]: (state, action) => {
state.loading = false;
state.error = action.payload;
},
},
});
const Payment_Slice = Payments.reducer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Transaction_Paypal = () => {
};
useEffect(() => {
if (transaction) {
navigate(`/transaction/success/${uuidv4()}`)
navigate(`/transaction/paypal/success/${uuidv4()}`)
}
}, [transaction])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { BsBagCheckFill } from "react-icons/bs";
import { Link, useParams } from "react-router-dom";
import { Metadata, runFireworks } from "../../../../imports/General_Global_Import";
import { CartBuySuccessStyle } from "../../../../../styles/Transaction_Style/CartBuySuccessStyle";
import { Transaction_Payment_Stripe_success_Initial } from "../../../../../redux/payment_slice/Api_Redux_Thunk_Payment";
import STORAGES from "../../../../../utils/storage";
import { useDispatch } from "react-redux";
const Transaction_Success = () => {
const { type, id } = useParams();
const dispatch = useDispatch();
const accessToken = STORAGES.getLocalStorage("accessToken");
useEffect(() => {
runFireworks();
}, []);
useEffect(() => {
if (type === "stripe") {
console.log(id)
dispatch(Transaction_Payment_Stripe_success_Initial({ accessToken, id }))
}
}, [id])
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { memo } from "react";
import { TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
import Lazy_Load_Img from "../../custom_hook/Lazy_Load_Img";
const TransformWrappers = ({ url_image }) => {
console.log(url_image);
return (
<React.Fragment>
<div className="col-md-6">
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/v1/user_ui/custom_hook/Lazy_Load_Img.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Lazy_Load_Img = ({ url, style, scrollPosition }) => {

return (
<React.Fragment>
{/* {style ? (
{style ? (
<img
alt="...loading"
ref={imgRef}
Expand All @@ -30,17 +30,17 @@ const Lazy_Load_Img = ({ url, style, scrollPosition }) => {
/>
) : (
<img alt="...loading" ref={imgRef} className="lazy-load" />
)} */}
<LazyLoadImage
)}
{/* <LazyLoadImage
src={url}
PlaceholderSrc={comment_png}
effect="opacity"
alt={url}
placeholderSrc={url}
scrollPosition={scrollPosition}
/>
/> */}
</React.Fragment>
);
};

export default trackWindowScroll(Lazy_Load_Img);
export default Lazy_Load_Img;
// export default trackWindowScroll(Lazy_Load_Img);

0 comments on commit e7bda43

Please sign in to comment.