Skip to content

Conversation

@LOTaher
Copy link
Collaborator

@LOTaher LOTaher commented Jan 3, 2026

[Full-Stack] - Positions Cleanup

Changes

  • Extracted away data model related fetch calls in hooks to lib/api/*.
  • Added get positions by organization ID route at GET /api/positions?orgId=...
  • Removed positions/action.ts and replaced it with endpoints in /api/positions/route.ts
  • Made position creation throw on duplicate position names
  • Cleaned up props and modals on the position related pages
  • Removed error toasts and now using error text similar to the position create modal to keep everything consistent
  • Fixed a few error utilities

Screenshots

image image

Checklist

Please go through all items before requesting reviewers:

  • All commits are tagged with the ticket number
  • No linting errors / newline warnings
  • All code follows repository-configured formatting
  • No merge conflicts
  • All checks passing
  • Screenshots included for UI changes
  • Remove non-applicable sections of this template
  • PR assigned to yourself
  • Reviewers requested & Slack ping sent
  • PR linked to the issue (fill in 'Closes #')
  • If design-related, notify the designer in Slack

Closes

Closes #127

@vercel
Copy link

vercel bot commented Jan 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sarge Ready Ready Preview, Comment Jan 7, 2026 4:07am

@LOTaher LOTaher changed the title 127/position creation toasts [Full-Stack] Positions Cleanup Jan 7, 2026
@LOTaher LOTaher marked this pull request as ready for review January 7, 2026 02:30
@@ -0,0 +1,66 @@
import { type AssessmentWithRelations } from '@/lib/services/assessment.service';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be good to define the types within the types directory - thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. Will fix, thanks

@@ -0,0 +1,48 @@
import {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is related to abstracting away the fetch calls from hooks can u explain the reasoning for doing it this way


<TabsContent value="active" className="flex flex-col gap-4">
{positions.length > 0 ? (
{active.length > 0 ? (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we say active are we referring to the active tab selected or the positions that are active / live


handleCreate,
handleCancel,
} = useCreateCandidateModal({
Copy link
Collaborator

@bderbs30 bderbs30 Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.reddit.com/r/reactjs/comments/xwzptl/whats_your_opinion_on_extracting_all_or_most/

I see we're extracting logic for state and effect to these hooks - ig this is up to us but is this common?

I think its clean but also might be overabstracting things that aren't going to be used elsewhere

ig in the future if we decide to have a create candidate modal functionality elsewhere then this might be helpful

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can move away from actions if its something people aren't a hundo on

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do similar things with tanstack query I believe

export interface CreatePositionModalProps {
open: boolean;
onOpenChange: (open: boolean) => void;
setActive: React.Dispatch<React.SetStateAction<PositionWithCounts[]>>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we move away from useState to use the dispatch? If we did, what is the reasoning (not familiar with dispatch)

@@ -0,0 +1,29 @@
import type { PositionPreviewData } from './usePositionPreviewModal';

export type Candidate = NonNullable<PositionPreviewData>['candidates'][number];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to define it as NonNullable? Were there typing issues otherwise?

toast.error('Batch creation failed');
} catch (err) {
const message = err instanceof Error ? err.message : 'Batch creation failed';
console.error(err);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove this console error before we merge :)

setError('Failed to batch create candidates');
toast.error('Batch creation failed');
} catch (err) {
const message = err instanceof Error ? err.message : 'Batch creation failed';
Copy link
Collaborator

@bderbs30 bderbs30 Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to check the instance I'm assuming its because you do err.message so we need to check the type of the err object right?


// In the future we may want to add the ability to create a position AND upload a CSV
// of candidates at the same time. If that were the case, we'd want to create a new
// route to create a position with the count fields included in the returned object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we could have it create the position and then update it - so it'd be two calls rather than a single create

we would then be using previous logic

thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Frontend] - Position creation Toasts

3 participants