diff --git a/src/pages/Membership/DetailUser.js b/src/pages/Membership/DetailUser.js
index 38f178f..aff0513 100644
--- a/src/pages/Membership/DetailUser.js
+++ b/src/pages/Membership/DetailUser.js
@@ -275,6 +275,10 @@ export const DetailUser = observer(() => {
store.authentication.dataProfit.userDetail?.image_identity,
"detail"
);
+ console.log(
+ store.authentication.listImage,
+ "detail gambar"
+ );
return (
@@ -283,8 +287,9 @@ export const DetailUser = observer(() => {
Detail User
-
+
{store.authentication.userData.role === "Admin" && (
+
{
Withdraw Profit
+
)}
-
+ {store.authentication.userData.role === "Supervisor" && (
+
+
+
+
+
+
+
+ )}
+ {store.authentication.userData.role === "Sales" && (
+
+
+
+
+
+
+
+ )}
+
@@ -416,7 +570,7 @@ export const DetailUser = observer(() => {
: "Inaktif"}
- {store.authentication.userData.role === "Sales" && (
+ {/* {store.authentication.userData.role === "Sales" && (
Foto Identitas
@@ -438,12 +592,11 @@ export const DetailUser = observer(() => {
Foto Toko
-
- {data.map((item) => (
+
+ {store.authentication.listImage.map((item) => (
{
- )}
+ )} */}
{store.authentication.userData.role === "Admin" && (
@@ -478,11 +631,48 @@ export const DetailUser = observer(() => {
Foto Toko
- {data.map((item) => (
+ {store.authentication.listImage.map((item) => (
+ ))}
+
+
+
+
+ )}
+ {store.authentication.userData.role === "Sales" && (
+
+
+ Foto Identitas
+
+
+
+
+
+
+
+
+ Foto Toko
+
+
+ {store.authentication.listImage.map((item) => (
+ {
];
const onSubmit = async (data, image, imageStore) => {
data.superior = true;
+ console.log(imageStore, "Apa imageStore")
+
+ if(!imageStore){
+ imageStore = []
+ }
+
+ if (initialData.id) {
+ data.image_identity = image;
+ data.image_store = imageStore;
+ }
if (initialData.id) {
setConfirmLoading(true);
@@ -267,6 +277,7 @@ export const Membership = observer(() => {
image_store: imageStore,
};
await store.membership.update(initialData.id, request);
+ console.log(data, "edit data");
message.success(
initialData.isChangePassword
? "Success Change Member Password"
diff --git a/src/pages/Membership/MembershipModal.js b/src/pages/Membership/MembershipModal.js
index 4981af4..6595ee5 100644
--- a/src/pages/Membership/MembershipModal.js
+++ b/src/pages/Membership/MembershipModal.js
@@ -1,4 +1,4 @@
-import React, { useState } from "react";
+import React, { useState, useEffect } from "react";
import {
Form,
Input,
@@ -36,7 +36,29 @@ export const MembershipModal = ({
const [responseFilenameStore, setResponseFilenameStore] = useState("");
const [loading, setLoading] = useState(false);
const [loadingStore, setLoadingStore] = useState(false);
-
+
+ useEffect(() => {
+ if (initialData.id) {
+ setFileList([
+ {
+ url: `${appConfig.apiUrl}/config/image/${initialData.image_identity}`,
+ },
+ ]);
+ setFileStore([
+ {
+ url: `${appConfig.apiUrl}/config/image/${initialData.image_store}`,
+ },
+ ]);
+ setImage(
+ `${appConfig.apiUrl}/config/image/${initialData.image_identity}`
+ );
+ setImageStore(
+ `${appConfig.apiUrl}/config/image/${initialData.image_store}`
+ );
+ }
+ return () => {};
+ }, [initialData]);
+
const beforeUpload = (file) => {
let isLt2M;
let allowedFile = ["image/jpeg", "image/png"];
@@ -88,12 +110,15 @@ export const MembershipModal = ({
console.log(res, "ini respon 2");
setImageStore(`${appConfig.apiUrl}/config/image/${res.body.filename}`);
setResponseFilenameStore([...responseFilenameStore, res.body.filename]);
- setFileStore([...fileStore, {
- uid: "-1",
- name: res.body.filename,
- status: "done",
- url: `${appConfig.apiUrl}/config/image/${res.body.filename}`,
- } ]);
+ setFileStore([
+ ...fileStore,
+ {
+ uid: "-1",
+ name: res.body.filename,
+ status: "done",
+ url: `${appConfig.apiUrl}/config/image/${res.body.filename}`,
+ },
+ ]);
setLoadingStore(false);
};
@@ -156,9 +181,12 @@ export const MembershipModal = ({
form
.validateFields()
.then((values) => {
- onCreate(values,responseFilename,responseFilenameStore);
+ console.log(values, "apa valuesanya");
+ values.image_identity = responseFilename;
+ values.image_store = responseFilenameStore;
+ onCreate(values, responseFilename, responseFilenameStore);
form.resetFields();
- setFileStore([])
+ setFileStore([]);
setImage("");
setFileList([]);
setPreviewImage("");
@@ -272,6 +300,7 @@ export const MembershipModal = ({
onChange={handleChange}
beforeUpload={(file) => beforeUpload(file)}
customRequest={(args) => uploadHandler(args)}
+ maxCount={1}
onRemove={(file) => {
setImage("");
setLoading(false);
@@ -450,7 +479,7 @@ export const MembershipModal = ({
setFileStore([]);
}}
>
- {fileStore.length >= 3 ? null:uploadButtonStore }
+ {fileStore.length >= 3 ? null : uploadButtonStore}
{
)} */}
{store.authentication.userData.role === "Retail" && (
+ //
+ //
+ // Foto Identitas
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ // Foto Toko
+ //
+ //
+ // {JSON.parse(
+ // store.authentication.profileData.userDetail
+ // ?.image_store
+ // ).map((item) => (
+ //
+ // ))}
+ //
+ //
+ //
+ //
Foto Identitas
@@ -315,18 +355,14 @@ export const Profile = observer(() => {
Foto Toko
- {JSON.parse(
- store.authentication.profileData.userDetail
- ?.image_store
- ).map((item) => (
+ {store.authentication.imageProfil.map((item) => (
))}
diff --git a/src/store/authentication.js b/src/store/authentication.js
index eb4121e..3754135 100644
--- a/src/store/authentication.js
+++ b/src/store/authentication.js
@@ -10,6 +10,7 @@ export class Authentication {
profileData = {};
dataProfit=[];
listImage=[];
+ imageProfil=[];
constructor(ctx) {
this.ctx = ctx;
@@ -58,7 +59,8 @@ export class Authentication {
const response = await http.get(`/auth/profile/${id}`);
console.log(response)
this.dataProfit = response.body ?? [];
- this.listImage = this.dataProfit.userDetail ? JSON.parse(this.dataProfit.userDetail?.image_store) : [];
+ this.listImage = this.dataProfit.userDetail?.image_store ? JSON.parse(this.dataProfit.userDetail?.image_store) : [];
+
this.total_data = response?.body?.count ?? 0;
} catch (e) {
console.error(e);
@@ -70,6 +72,9 @@ export class Authentication {
const response = await http.get('/auth/profile');
console.log(response)
this.profileData = response.body;
+ this.imageProfil = this.profileData.userDetail?.image_store ? JSON.parse(this.profileData.userDetail?.image_store) : [];
+
+ //this.imageProfil = this.profileData.userDetail?.image_store ? JSON.parse(this.profileData.userDetail?.image_store) : [];
} catch (e) {
console.error(e);
}