upd: member

Deskripsi;
- upload gambar pada tambah member
- upload gambar pada edit member

NO Issues
This commit is contained in:
amel
2025-05-19 15:05:06 +08:00
parent fb7149ce02
commit b45822fff2
4 changed files with 71 additions and 23 deletions

View File

@@ -37,6 +37,7 @@ export default function CreateMember() {
const [isSelect, setSelect] = useState(false);
const [disableBtn, setDisableBtn] = useState(true)
const [valChoose, setValChoose] = useState("")
const [imgForm, setImgForm] = useState<any>()
const [error, setError] = useState({
group: false,
position: false,
@@ -144,9 +145,21 @@ export default function CreateMember() {
try {
const hasil = await decryptToken(String(token?.current))
const fd = new FormData()
fd.append("data", JSON.stringify(
{ user: hasil, ...dataForm }
))
if (imgForm != undefined) {
fd.append("file", {
uri: imgForm.uri,
type: imgForm.mimeType,
name: imgForm.fileName,
} as any)
} else {
fd.append("file", "undefined")
}
const response = await apiCreateUser(fd)
if (response.success) {
ToastAndroid.show('Berhasil menambahkan data', ToastAndroid.SHORT)
@@ -166,10 +179,13 @@ export default function CreateMember() {
mediaTypes: ["images"],
allowsEditing: true,
quality: 1,
aspect: [1, 1],
});
if (!result.canceled) {
setSelectedImage(result.assets[0].uri);
setImgForm(result.assets[0]);
} else {
alert("Tidak ada gambar yang dipilih");
}