Skip to content

Commit

Permalink
fix bug with phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza-Mos committed Aug 31, 2024
1 parent 0ab2d0c commit 9bbdc0a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion apps/member-profile/app/routes/_profile.profile.general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,13 @@ export default function UpdateGeneralInformationSection() {
/>

<InputField
defaultValue={student.phoneNumber?.toString() || undefined}
defaultValue={student.phoneNumber || undefined}
description="Enter your 10-digit phone number below (no formatting characters e.g. '-' or '(')."
error={errors.phoneNumber}
label="Phone Number"
name={keys.phoneNumber}
placeholder="1234567890"
type="number"
/>

<Button.Group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type Kysely } from 'kysely';
export async function up(db: Kysely<any>) {
await db.schema
.alterTable('students')
.addColumn('phone_number', 'integer')
.addColumn('phone_number', 'text')
.execute();
}

Expand Down
1 change: 0 additions & 1 deletion packages/db/src/scripts/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ async function seed(trx: Transaction<DB>) {
otherDemographics: [],
race: [],
schoolId: schoolId1,
phoneNumber: 1234567890,
},
])
.execute();
Expand Down
8 changes: 4 additions & 4 deletions packages/types/src/domain/student.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ export const Student = Entity.merge(StudentSocialLinks)
joinedSlackAt: z.coerce.date().optional(),
lastName: z.string().trim().min(1),
phoneNumber: z
.number()
.int()
.gte(1000000000) // 10-digit numbers start from 1000000000
.lte(9999999999) // 10-digit numbers end at 9999999999
.string()
.trim()
.length(10, 'Phone Number must be a 10-digit number')
.regex(/^\d+$/, 'Phone Number must contain only digits')
.optional(),

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/components/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Form.Field = function FormField({

type InputFieldProps = FieldProps<string> &
Pick<FormFieldProps, 'description' | 'label' | 'required'> &
Pick<InputProps, 'disabled' | 'placeholder'>;
Pick<InputProps, 'disabled' | 'placeholder' | 'type'>;

export function InputField({
defaultValue,
Expand All @@ -82,6 +82,7 @@ export function InputField({
name,
placeholder,
required,
type = 'text',
}: InputFieldProps) {
return (
<Form.Field
Expand All @@ -98,6 +99,7 @@ export function InputField({
name={name}
placeholder={placeholder}
required={required}
type={type}
/>
</Form.Field>
);
Expand Down

0 comments on commit 9bbdc0a

Please sign in to comment.