Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 121 additions & 1 deletion src/components/InterviwerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type FormState = {
name: string;
email: string;
sid: string;

phone: string;
availableDays: string[];

responses: Record<
Expand All @@ -63,6 +63,7 @@ const initialForm: FormState = {
email: "",
sid: "",
availableDays: [],
phone:"",
responses:
createEmptyResponses(),
};
Expand Down Expand Up @@ -201,6 +202,9 @@ export default function InterviewerForm() {
const sid =
form.sid.trim();

const phone =
form.phone.trim();

const availableDays =
form.availableDays;

Expand All @@ -212,6 +216,7 @@ export default function InterviewerForm() {
!name ||
!email ||
!sid ||
!phone||
availableDays.length ===
0
) {
Expand Down Expand Up @@ -253,6 +258,17 @@ export default function InterviewerForm() {

return;
}
if (
!/^\d{10}$/.test(
phone
)
) {
setError(
"phone number is invalid."
);

return;
}

/*
* Check questions
Expand Down Expand Up @@ -313,6 +329,7 @@ export default function InterviewerForm() {
name,
sid,
email,
phone,
availableDays,
trimmedResponses
);
Expand Down Expand Up @@ -362,6 +379,11 @@ export default function InterviewerForm() {
.applicant
.sid ||
"",
phone:
result
.applicant
.phone ||
"",

availableDays:
result
Expand Down Expand Up @@ -416,6 +438,9 @@ export default function InterviewerForm() {
const sid =
form.sid.trim();

const phone =
form.phone.trim();

const availableDays =
form.availableDays;

Expand All @@ -427,6 +452,7 @@ export default function InterviewerForm() {
!name ||
!email ||
!sid ||
!phone ||
availableDays.length ===
0
) {
Expand Down Expand Up @@ -469,6 +495,22 @@ export default function InterviewerForm() {
return;
}

/*
* Phone validation
*/

if (
!/^\d{10}$/.test(
phone
)
) {
setError(
"phone number is invalid."
);

return;
}

setSavingPersonalInfo(
true
);
Expand All @@ -480,6 +522,7 @@ export default function InterviewerForm() {
name,
email,
sid,
phone,
availableDays
);

Expand Down Expand Up @@ -530,6 +573,12 @@ export default function InterviewerForm() {
.applicant
.sid,

phone:
result
.applicant
.phone ||
"",

availableDays:
result
.applicant
Expand Down Expand Up @@ -711,6 +760,43 @@ export default function InterviewerForm() {
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-60"
/>
</div>

<div className="space-y-2">
<label
htmlFor="existing-phone"
className="text-sm font-medium"
>
Phone
</label>

<input
id="existing-phone"
type="tel"
inputMode="numeric"
maxLength={
10
}
value={
form.phone
}
disabled={
!canEdit
}
onChange={(
event
) =>
updateField(
"phone",
event.target.value.replace(
/\D/g,
""
)
)
}
placeholder="10-digit phone number"
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-60"
/>
</div>
</div>

{/* Available days */}
Expand Down Expand Up @@ -961,6 +1047,40 @@ export default function InterviewerForm() {
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none"
/>
</div>

<div className="space-y-2">
<label
htmlFor="phone"
className="text-sm font-medium"
>
Phone
</label>

<input
id="phone"
type="tel"
inputMode="numeric"
maxLength={
10
}
value={
form.phone
}
onChange={(
event
) =>
updateField(
"phone",
event.target.value.replace(
/\D/g,
""
)
)
}
placeholder="10-digit phone number"
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none"
/>
</div>
</div>

{/* Available days */}
Expand Down
16 changes: 14 additions & 2 deletions src/lib/supabase/actions/interviewers.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ const appsScriptRequest =
if (isServer) {
const appsScriptUrl =
process.env
.GOOGLE_APPS_SCRIPT_URL;
.INT_GOOGLE_APPS_SCRIPT_URL;

if (
!appsScriptUrl
) {
throw new Error(
"GOOGLE_APPS_SCRIPT_URL is not configured."
"INT_GOOGLE_APPS_SCRIPT_URL is not configured."
);
}

Expand Down Expand Up @@ -159,6 +159,10 @@ const mapInterviewer =
String(
item.sid || ""
),
phone:
String(
item.phone || ""
),

availableDays:
Array.isArray(
Expand Down Expand Up @@ -255,6 +259,7 @@ export const createInterviewer =
name: string,
sid: string,
email: string,
phone: string,
availableDays: string[],
responses: Record<
string,
Expand All @@ -279,6 +284,9 @@ export const createInterviewer =
email:
email.trim(),

phone:
phone.trim(),

availableDays:
availableDays,

Expand Down Expand Up @@ -373,6 +381,7 @@ export const updateInterviewerPersonalInfo =
name: string,
email: string,
sid: string,
phone: string,
availableDays: string[]
): Promise<
UpdateInterviewerResult
Expand All @@ -395,6 +404,9 @@ export const updateInterviewerPersonalInfo =
sid:
sid.trim(),

phone:
phone.trim(),

availableDays:
availableDays,
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/interviewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async function handler(
}

try {
const scriptUrl = process.env.GOOGLE_APPS_SCRIPT_URL;
const scriptUrl = process.env.INT_GOOGLE_APPS_SCRIPT_URL;

if (!scriptUrl) {
console.error("Missing GOOGLE_APPS_SCRIPT_URL in environment");
Expand Down
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export type InterviewerType = {
name: string;
email: string;
sid: string;
phone: string;
availableDays: string[];
responses: Record<string, string>;
status:
Expand Down
Loading