-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
2,048 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const API_CAROUSEL = { | ||
//* GET ALL CAROUSEL | ||
GET_ALL_CAROUSEL: "/api/carousel", | ||
}; | ||
export default API_CAROUSEL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const API_PRODUCT = { | ||
//* GET ALL PRODUCT | ||
GET_ALL_PRODUCT: "/api/product", | ||
|
||
//* GET DETAIL PRODUCT | ||
GET_DETAIL_PRODUCT: "/api/product/detail", | ||
}; | ||
export default API_PRODUCT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
frontend/src/v1/redux/carousel_slice.js/Api_Redux_Thunk_Carousel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { createAsyncThunk } from "@reduxjs/toolkit"; | ||
import axios from "axios"; | ||
import API_CAROUSEL from "../../configs/Apis/Carousel_Api/Api_Carousel"; | ||
|
||
export const Get_All_Carousel_Initial = createAsyncThunk( | ||
"Carousel/Get/All", | ||
async () => { | ||
try { | ||
const response = await axios.get(`${API_CAROUSEL.GET_ALL_CAROUSEL}`); | ||
return response.data; | ||
} catch (error) { | ||
if (!error.response) { | ||
throw error; | ||
} | ||
return error.response.data; | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
import { Get_All_Carousel_Initial } from "./Api_Redux_Thunk_Carousel"; | ||
const initialState = { | ||
loading: false, | ||
error: null, | ||
result_carousel: null, | ||
}; | ||
const Carousels = createSlice({ | ||
name: "carousels", | ||
initialState, | ||
reducers: { | ||
reset_carousel: (state) => { | ||
state.result_carousel = null; | ||
}, | ||
}, | ||
extraReducers: { | ||
//* Get All Carousel | ||
[Get_All_Carousel_Initial.pending]: (state, action) => { | ||
state.loading = true; | ||
}, | ||
[Get_All_Carousel_Initial.fulfilled]: (state, action) => { | ||
state.loading = false; | ||
state.result_carousel = action.payload.element.carousels; | ||
}, | ||
[Get_All_Carousel_Initial.rejected]: (state, action) => { | ||
state.loading = false; | ||
state.error = action.payload; | ||
}, | ||
}, | ||
}); | ||
const Carousels_Slice = Carousels.reducer; | ||
export const { reset_carousel } = Carousels.actions; | ||
export default Carousels_Slice; |
35 changes: 35 additions & 0 deletions
35
frontend/src/v1/redux/product_slice/Api_Redux_Thunk_Products.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { createAsyncThunk } from "@reduxjs/toolkit"; | ||
import axios from "axios"; | ||
import API_PRODUCT from "../../configs/Apis/Products_Api/Api_Product"; | ||
|
||
export const Get_All_Product_Initial = createAsyncThunk( | ||
"Product/Get/All", | ||
async () => { | ||
try { | ||
const response = await axios.get(`${API_PRODUCT.GET_ALL_PRODUCT}`); | ||
return response.data; | ||
} catch (error) { | ||
if (!error.response) { | ||
throw error; | ||
} | ||
return error.response.data; | ||
} | ||
} | ||
); | ||
|
||
export const Get_Detail_Product_Initial = createAsyncThunk( | ||
"Product/Get/Detail", | ||
async (id) => { | ||
try { | ||
const response = await axios.get( | ||
`${API_PRODUCT.GET_DETAIL_PRODUCT}/${id}` | ||
); | ||
return response.data; | ||
} catch (error) { | ||
if (!error.response) { | ||
throw error; | ||
} | ||
return error.response.data; | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
import { | ||
Get_All_Product_Initial, | ||
Get_Detail_Product_Initial, | ||
} from "./Api_Redux_Thunk_Products"; | ||
const initialState = { | ||
loading: false, | ||
error: null, | ||
result_product: null, | ||
result_product_detail: null, | ||
}; | ||
const Products = createSlice({ | ||
name: "products", | ||
initialState, | ||
reducers: { | ||
reset_product: (state) => { | ||
state.result_product = null; | ||
}, | ||
reset_product_detail: (state) => { | ||
state.result_product_detail = null; | ||
}, | ||
}, | ||
extraReducers: { | ||
//* Get All Product | ||
[Get_All_Product_Initial.pending]: (state, action) => { | ||
state.loading = true; | ||
}, | ||
[Get_All_Product_Initial.fulfilled]: (state, action) => { | ||
state.loading = false; | ||
state.result_product = action.payload.element; | ||
}, | ||
[Get_All_Product_Initial.rejected]: (state, action) => { | ||
state.loading = false; | ||
state.error = action.payload; | ||
}, | ||
//* Get Detail Product | ||
[Get_Detail_Product_Initial.pending]: (state, action) => { | ||
state.loading = true; | ||
}, | ||
[Get_Detail_Product_Initial.fulfilled]: (state, action) => { | ||
state.loading = false; | ||
state.result_product_detail = action.payload.element; | ||
}, | ||
[Get_Detail_Product_Initial.rejected]: (state, action) => { | ||
state.loading = false; | ||
state.error = action.payload; | ||
}, | ||
}, | ||
}); | ||
const Product_Slice = Products.reducer; | ||
export const { reset_product, reset_product_detail } = Products.actions; | ||
export default Product_Slice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
frontend/src/v1/redux/upload_slice/Api_Redux_Thunk_Upload.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { createAsyncThunk } from "@reduxjs/toolkit"; | ||
import axios from "axios"; | ||
import API_UPLOAD from "../../configs/Apis/Upload_Api/Api_Upload"; | ||
|
||
export const Upload_Cloud_Initial = createAsyncThunk( | ||
"Upload/Image/Cloud", | ||
async ({ formData, accessToken }, { rejectWithValue }) => { | ||
const config = { | ||
headers: { | ||
"content-type": "multipart/form-data", | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}; | ||
try { | ||
const response = await axios.post( | ||
`${API_UPLOAD.UPLOAD_IMAGE_CLOUD}`, | ||
formData, | ||
config | ||
); | ||
return response.data; | ||
} catch (error) { | ||
if (!error.response) { | ||
throw error; | ||
} | ||
return rejectWithValue(error.response.data); | ||
} | ||
} | ||
); | ||
|
||
export const Destroy_Cloud_Initial = createAsyncThunk( | ||
"Destroy/Image/Cloud", | ||
async ({ public_id, accessToken }, { rejectWithValue }) => { | ||
const config = { | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}; | ||
try { | ||
const response = await axios.post( | ||
`${API_UPLOAD.DESTROY_IMAGE_CLOUD}`, | ||
{ | ||
public_id, | ||
}, | ||
config | ||
); | ||
return response.data; | ||
} catch (error) { | ||
if (!error.response) { | ||
throw error; | ||
} | ||
return rejectWithValue(error.response.data); | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
import { | ||
Destroy_Cloud_Initial, | ||
Upload_Cloud_Initial, | ||
} from "./Api_Redux_Thunk_Upload"; | ||
const initialState = { | ||
loading: false, | ||
error: null, | ||
result: null, | ||
result_destroy: null, | ||
}; | ||
const Upload_Cloud = createSlice({ | ||
name: "Upload_Cloud", | ||
initialState, | ||
reducers: { | ||
reset_upload: (state) => { | ||
state.result = null; | ||
}, | ||
}, | ||
extraReducers: { | ||
//* Upload Cloud | ||
[Upload_Cloud_Initial.pending]: (state, action) => { | ||
state.loading = true; | ||
}, | ||
[Upload_Cloud_Initial.fulfilled]: (state, action) => { | ||
state.loading = false; | ||
state.result = action.payload.element; | ||
}, | ||
[Upload_Cloud_Initial.rejected]: (state, action) => { | ||
state.loading = false; | ||
state.error = action.payload; | ||
}, | ||
//* Destroy Cloud | ||
[Destroy_Cloud_Initial.pending]: (state, action) => { | ||
state.loading = true; | ||
}, | ||
[Destroy_Cloud_Initial.fulfilled]: (state, action) => { | ||
state.loading = false; | ||
state.result_destroy = action.payload; | ||
}, | ||
[Destroy_Cloud_Initial.rejected]: (state, action) => { | ||
state.loading = false; | ||
state.error = action.payload; | ||
}, | ||
}, | ||
}); | ||
const Upload_Cloud_Slice = Upload_Cloud.reducer; | ||
export const { reset_upload } = Upload_Cloud.actions; | ||
export default Upload_Cloud_Slice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.