import {horizontalFormOptions, apiPost} from '../constants.js'
import {confirmPasswordFormItem, passwordFormItem} from "./dialog-user-item.js";

export function userChangePasswordDialog() {
    return {
        actionType: 'dialog',
        dialog: {
            title: '修改密码',
            actions: [
                {
                    type: 'reset',
                    label: '清空',
                },
                {
                    type: 'submit',
                    label: '修改',
                    level: 'primary',
                }
            ],
            body: {
                type: 'form',
                api: apiPost('${base}/user_management/change_password'),
                ...horizontalFormOptions(),
                body: [
                    {
                        type: 'input-password',
                        name: 'oldPassword',
                        label: '旧密码',
                        placeholder: '请输入旧密码',
                        required: true,
                    },
                    passwordFormItem('newPassword', '新密码'),
                    confirmPasswordFormItem('confirmNewPassword', 'newPassword', '新密码'),
                ]
            }
        }
    }
}