fix: edit member

This commit is contained in:
amel
2024-08-29 11:12:57 +08:00
parent 1780f8a19b
commit ecac5b20ea
3 changed files with 33 additions and 30 deletions

View File

@@ -136,7 +136,10 @@ export async function PUT(request: Request, context: { params: { id: string } })
where: { where: {
nik: data.nik, nik: data.nik,
email: data.email, email: data.email,
phone: data.phone phone: data.phone,
NOT: {
id: id
}
}, },
}); });

View File

@@ -53,10 +53,6 @@ export const funEditStatusMember = async (path: string, data: IStatusmember) =>
export const funEditMember = async (path: string, data: IEditDataMember) => { export const funEditMember = async (path: string, data: IEditDataMember) => {
if (data.name.length < 3)
return { success: false, message: 'Minimal 3 karakter' }
const response = await fetch(`/api/user/${path}`, { const response = await fetch(`/api/user/${path}`, {
method: "PUT", method: "PUT",
headers: { headers: {

View File

@@ -122,8 +122,12 @@ export default function EditMember({ id }: { id: string }) {
idUserRole: data.idUserRole idUserRole: data.idUserRole
}) })
if (res.success) {
toast.success(res.message) toast.success(res.message)
router.push(`/member?active=true`) router.push(`/member?active=true`)
} else {
toast.error(res.message)
}
} }
} catch (error) { } catch (error) {