| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  | import { fieldTypes } from "../forms"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { AutoFormItems } from "~/types/auto-forms"; | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const useUserForm = () => { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   const i18n = useI18n(); | 
					
						
							| 
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |   const userForm: AutoFormItems = [ | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       section: i18n.t("user.user-details"), | 
					
						
							|  |  |  |       label: i18n.t("user.user-name"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "username", | 
					
						
							|  |  |  |       type: fieldTypes.TEXT, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.full-name"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "fullName", | 
					
						
							|  |  |  |       type: fieldTypes.TEXT, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.email"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "email", | 
					
						
							|  |  |  |       type: fieldTypes.TEXT, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.password"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "password", | 
					
						
							|  |  |  |       disableUpdate: true, | 
					
						
							|  |  |  |       type: fieldTypes.PASSWORD, | 
					
						
							| 
									
										
										
										
											2022-08-13 21:38:26 -08:00
										 |  |  |       rules: ["required", "minLength:8"], | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2023-02-26 13:12:16 -06:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.authentication-method"), | 
					
						
							| 
									
										
										
										
											2023-02-26 13:12:16 -06:00
										 |  |  |       varName: "authMethod", | 
					
						
							|  |  |  |       type: fieldTypes.SELECT, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       hint: i18n.t("user.authentication-method-hint"), | 
					
						
							| 
									
										
										
										
											2023-02-26 13:12:16 -06:00
										 |  |  |       disableCreate: true, | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |       options: [{ text: "Mealie" }, { text: "LDAP" }, { text: "OIDC" }], | 
					
						
							| 
									
										
										
										
											2023-02-26 13:12:16 -06:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       section: i18n.t("user.permissions"), | 
					
						
							|  |  |  |       label: i18n.t("user.administrator"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "admin", | 
					
						
							|  |  |  |       type: fieldTypes.BOOLEAN, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.user-can-invite-other-to-group"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "canInvite", | 
					
						
							|  |  |  |       type: fieldTypes.BOOLEAN, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.user-can-manage-group"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "canManage", | 
					
						
							|  |  |  |       type: fieldTypes.BOOLEAN, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.user-can-organize-group-data"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "canOrganize", | 
					
						
							|  |  |  |       type: fieldTypes.BOOLEAN, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2024-09-17 10:48:14 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.user-can-manage-household"), | 
					
						
							| 
									
										
										
										
											2024-09-17 10:48:14 -05:00
										 |  |  |       varName: "canManageHousehold", | 
					
						
							|  |  |  |       type: fieldTypes.BOOLEAN, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       label: i18n.t("user.enable-advanced-features"), | 
					
						
							| 
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 |  |  |       varName: "advanced", | 
					
						
							|  |  |  |       type: fieldTypes.BOOLEAN, | 
					
						
							|  |  |  |       rules: ["required"], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return { | 
					
						
							|  |  |  |     userForm, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | }; |