Add manual expert#862
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
can we rename it to something more generic like ExpertFormModal?
| } | ||
|
|
||
| function buildPayload(values: { | ||
| interface AddModeProps { |
There was a problem hiding this comment.
I do not think that we should differentiate input Props based on the mode.
we can have something like
export interface ExpertFormModalProps {
isOpen: boolean;
onClose: () => void;
searchId: string; // required for add flow
expert?: ExpertResult; // undefined = add, defined = edit
onSuccess: () => Promise<void>;
}
There was a problem hiding this comment.
Parent passes onSuccess={refetch} so the grid updates after save
| const [submitError, setSubmitError] = useState<string | null>(null); | ||
| const [isSubmitting, setIsSubmitting] = useState(false); |
There was a problem hiding this comment.
And now i think we shoudl have submit flow inside modal:
const [, patchExpert] = usePatchExpert();
const [, createExpert] = useCreateExpert(); // new
const handleSubmit = async () => {
try {
if (isEditMode) {
await patchExpert(expert.expertId!, payload);
} else {
await createExpert(searchId, payload);
}
await onSuccess();
onClose();
} catch (err) {
setSubmitError(extractApiErrorMessage(err, 'Failed to update expert'));
} finally {
setIsSubmitting(false);
}
};
|




No description provided.