Skip to content

Commit

Permalink
update tn-forms and change default implementatino of dynamic form fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Pari Work Temp committed Sep 23, 2024
1 parent a16b513 commit fca98c4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@sentry/react-native": "~5.22.0",
"@shopify/flash-list": "1.6.4",
"@tanstack/react-query": "^5.15.0",
"@thinknimble/tn-forms": "^3.1.3",
"@thinknimble/tn-forms": "^3.2.0",
"@thinknimble/tn-forms-react": "^1.0.3",
"@thinknimble/tn-models": "^3.0.0",
"axios": "^1.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"@tanstack/react-query": "^5.15.0",
"@thinknimble/tn-forms": "^3.1.8",
"@thinknimble/tn-forms": "^3.2.0",
"@thinknimble/tn-forms-react": "^1.0.3",
"@thinknimble/tn-models": "^3.0.0",
"axios": "^1.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@headlessui/vue": "1.7.16",
"@heroicons/vue": "2.0.18",
"@thinknimble/tn-forms": "3.1.8",
"@thinknimble/tn-forms": "3.2.0",
"@thinknimble/tn-models": "^3.0.0",
"@thinknimble/tn-utils": "2.0.1",
"@tanstack/vue-query": "^5.28.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
import { useAlert } from '@/composables/CommonAlerts'
import { MustMatchValidator } from '@thinknimble/tn-forms'

export function useUsers() {
const userStore = useUserStore()
Expand All @@ -22,10 +23,24 @@ export function useUsers() {
const loginForm = reactive(new LoginForm({}))
const forgotPasswordForm = reactive(new EmailForgotPasswordForm({}))
const resetPasswordForm = reactive(new ResetPasswordForm({}))
const registerForm = reactive(new AccountForm({}))
const registerForm = ref(new AccountForm({}))
const loading = ref(false)
const { errorAlert, successAlert } = useAlert()

const fillUserForm = (data: UserShape | null ) =>{
if(data){
registerForm.value = new AccountForm(data)

}else{
registerForm.value = new AccountForm()
}
registerForm.value.addFormLevelValidator(
'confirmPassword',
new MustMatchValidator({ matcher: 'password' }),
)

}

const getCodeUidFromRoute = () => {
const { uid, token } = router.currentRoute.value.params
return { uid, token }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Form, {
IFormField,
MinLengthValidator,
RequiredValidator,
MustMatchValidator,
} from '@thinknimble/tn-forms'

export type AccountFormInputs = {
Expand Down Expand Up @@ -131,14 +130,6 @@ export class ResetPasswordForm extends Form<ResetPasswordInput> {
value: '',
validators: [],
})

static dynamicValidators = {
confirmPassword: [
new MustMatchValidator({
matcher: 'password',
}),
],
}
}

export type TResetPasswordForm = ResetPasswordForm & ResetPasswordInput
Expand Down

0 comments on commit fca98c4

Please sign in to comment.