Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat(contact-form): add validation for last-contacted date and update documentation

Khuram Niazcc577cd7c7d1
diff --git a/__tests__/addContactForm.schema.spec.ts b/__tests__/addContactForm.schema.spec.ts
index f4dcab4..c205b8c 100644
--- a/__tests__/addContactForm.schema.spec.ts
+++ b/__tests__/addContactForm.schema.spec.ts
@@ -39,6 +39,22 @@ describe("AddContactFormSchema", () => {
expect(res.success).toBe(false);
});
+ it("rejects a last-contacted date in the future", () => {
+ const tomorrow = new Date();
+ tomorrow.setDate(tomorrow.getDate() + 1);
+ expect(
+ AddContactFormSchema.safeParse({ ...valid, lastContactedAt: tomorrow })
+ .success,
+ ).toBe(false);
+ });
+
+ it("accepts a last-contacted date of today", () => {
+ expect(
+ AddContactFormSchema.safeParse({ ...valid, lastContactedAt: new Date() })
+ .success,
+ ).toBe(true);
+ });
+
it("accepts an open-ended overlap", () => {
expect(
AddContactFormSchema.safeParse({
diff --git a/src/components/AddContact.tsx b/src/components/AddContact.tsx
index 2066c4e..0a25772 100644
--- a/src/components/AddContact.tsx
+++ b/src/components/AddContact.tsx
@@ -442,6 +442,7 @@ function AddContact({
isEnabled
captionLayout
fullWidth
+ disableFuture
/>
<FormMessage />
</FormItem>
diff --git a/src/components/DatePicker.tsx b/src/components/DatePicker.tsx
index 8693717..29ed0d0 100644
--- a/src/components/DatePicker.tsx
+++ b/src/components/DatePicker.tsx
@@ -30,6 +30,7 @@ interface DatePickerProps {
captionLayout?: boolean;
// Opt out of the default fixed trigger width when the field sits in a grid
fullWidth?: boolean;
+ disableFuture?: boolean;
}
export function DatePicker({
@@ -38,6 +39,7 @@ export function DatePicker({
isEnabled,
captionLayout,
fullWidth,
+ disableFuture,
}: DatePickerProps) {
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);
@@ -84,6 +86,7 @@ export function DatePicker({
startMonth={captionLayout ? new Date(1970, 0) : undefined}
endMonth={captionLayout ? new Date() : undefined}
selected={field.value}
+ disabled={disableFuture ? { after: new Date() } : undefined}
onSelect={(value) => {
field.onChange(value);
setIsPopoverOpen(false);
diff --git a/src/models/addContactForm.schema.ts b/src/models/addContactForm.schema.ts
index a332135..fe1e51a 100644
--- a/src/models/addContactForm.schema.ts
+++ b/src/models/addContactForm.schema.ts
@@ -44,7 +44,19 @@ export const AddContactFormSchema = z
// Named for ComboBox's `case "contactRole"` create path, not for the column
contactRole: z.string().optional(),
notes: optionalText(2000),
- lastContactedAt: z.date().nullable().optional(),
+ lastContactedAt: z
+ .date()
+ .nullable()
+ .optional()
+ .refine(
+ (date) => {
+ if (!date) return true;
+ const endOfToday = new Date();
+ endOfToday.setHours(23, 59, 59, 999);
+ return date <= endOfToday;
+ },
+ { message: "Last contacted date cannot be in the future." },
+ ),
})
.refine(
(v) => !v.workedFrom || !v.workedTo || v.workedTo >= v.workedFrom,
diff --git a/wiki/contacts.md b/wiki/contacts.md
index cc91ea4..56a0a69 100644
--- a/wiki/contacts.md
+++ b/wiki/contacts.md
@@ -43,7 +43,7 @@ Anywhere a Role combo box appears, typing a name that does not exist yet offers
The **How you know them** fields on the contact form: **Relationship** in your own words (`my manager`, `peer on the platform team`), **Worked together at** for the company where your paths crossed, and **From** / **To** for the stint. Leave **To** empty for a stint that has not ended — the expanded row then reads `Mar 2021 – present`.
-*Worked together at* is deliberately separate from **Company**: Company is where they are now, and the company you overlapped at is often somewhere neither of you still works. **Last contacted** is a plain date you set yourself; nothing updates it for you.
+*Worked together at* is deliberately separate from **Company**: Company is where they are now, and the company you overlapped at is often somewhere neither of you still works. **Last contacted** is a plain date you set yourself, and it can't be in the future; nothing updates it for you.
## How do I find my references?