diff --git a/client/src/components/UpdateUser.vue b/client/src/components/UpdateUser.vue index ca57482e..e407c9a1 100644 --- a/client/src/components/UpdateUser.vue +++ b/client/src/components/UpdateUser.vue @@ -32,11 +32,11 @@ + :rules="[...requiredRules, ...lengthRules(45)]"> + :rules="[...requiredRules, ...lengthRules(45)]"> + :rules="[...emailRules, ...lengthRules(45)]"> + :rules="[...requiredRules, ...lengthRules(100)]"> @@ -69,7 +69,7 @@ + :rules="[...requiredStringRules, ...lengthRules(30)]"> { + console.log("image.value[0].name",image.value[0].name) + console.log("selectedUser.value.image",selectedUser.value.image) + + selectedUser.value.user_type = selectedUser.value.user_type === "Team Lead" ? "Supervisor" : selectedUser.value.user_type await $api.myprofile.update(selectedUser.value.id, { ...selectedUser.value, @@ -288,6 +293,7 @@ export default { supervisorPage, supervisorCount, requiredStringRules, + lengthRules, requiredRules, isLoading, userIsActive, diff --git a/client/src/utils/validators.ts b/client/src/utils/validators.ts index 8a950bf8..6bcedcc9 100644 --- a/client/src/utils/validators.ts +++ b/client/src/utils/validators.ts @@ -29,14 +29,14 @@ export const jobRules = [ (v: string) => typeof v === 'string' || 'Role must be a string.', (v: string) => !!v || 'Role is required.', (v: string) => - (v && v.length >= 3 && v.length <= 50) || 'Role must be between 3 and 50 characters.' + (v && v.length >= 3 && v.length <= 150) || 'Role must be between 3 and 150 characters.' ] export const addressRules = [ (v: string) => typeof v === 'string' || 'Address must be a string.', (v: string) => !!v || 'Address is required.', (v: string) => - (v && v.length >= 3 && v.length <= 50) || 'Address must be between 3 and 50 characters.' + (v && v.length >= 3 && v.length <= 150) || 'Address must be between 3 and 150 characters.' ] // export const socialInsuranceRules = [ // (v: string) => typeof v === 'string' || 'Social Number must be a string.', @@ -56,3 +56,8 @@ export const vacationRules = [ (v: string) => +v <= 80 || 'The maximum allowed value is 80. ', (v: string) => /^(?!00)\d{1,2}$/.test(v) || 'Invalid value.' ] + +export const lengthRules = (maxValue : number) => [ + (v: string) => + (v && v.length >= 3 && v.length <= maxValue) || `The maximum allowed value is ${maxValue}.` +]; \ No newline at end of file diff --git a/server/cshr/migrations/0009_alter_user_gender_alter_user_team_and_more.py b/server/cshr/migrations/0009_alter_user_gender_alter_user_team_and_more.py new file mode 100644 index 00000000..48369bb3 --- /dev/null +++ b/server/cshr/migrations/0009_alter_user_gender_alter_user_team_and_more.py @@ -0,0 +1,48 @@ +# Generated by Django 4.2.9 on 2024-04-23 09:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("cshr", "0008_alter_vacation_actual_days"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="gender", + field=models.CharField( + choices=[("Male", "male"), ("Female", "female")], max_length=30 + ), + ), + migrations.AlterField( + model_name="user", + name="team", + field=models.CharField( + choices=[ + ("Business Development", "Businessdevelopment"), + ("Development", "Development"), + ("HR & Finance", "Hrandfinance"), + ("QA", "Qa"), + ("Marketing", "Marketing"), + ("Operations", "Operations"), + ("Support", "Support"), + ], + max_length=30, + ), + ), + migrations.AlterField( + model_name="user", + name="user_type", + field=models.CharField( + choices=[ + ("Admin", "admin"), + ("User", "user"), + ("Supervisor", "supervisor"), + ], + max_length=30, + ), + ), + ] diff --git a/server/cshr/models/users.py b/server/cshr/models/users.py index c8ccdedc..abaa2939 100644 --- a/server/cshr/models/users.py +++ b/server/cshr/models/users.py @@ -95,12 +95,12 @@ class User(AbstractBaseUser, TimeStamp): telegram_link = models.CharField(max_length=100) birthday = models.DateField() joining_at = models.DateField() - team = models.CharField(max_length=20, choices=TEAM.choices) + team = models.CharField(max_length=30, choices=TEAM.choices) salary = models.JSONField(default=dict, null=True, blank=True) location = models.ForeignKey(Office, on_delete=models.CASCADE) skills = models.ManyToManyField(UserSkills, related_name="skills", blank=True) - user_type = models.CharField(max_length=20, choices=USER_TYPE.choices) - gender = models.CharField(max_length=20, choices=GENDER_TYPE.choices) + user_type = models.CharField(max_length=30, choices=USER_TYPE.choices) + gender = models.CharField(max_length=30, choices=GENDER_TYPE.choices) social_insurance_number = models.CharField(max_length=45, null=True, blank=True) address = models.CharField(max_length=150) job_title = models.CharField(max_length=150)