-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add order purchase callback #37
Conversation
Signed-off-by: Hector Vergara <[email protected]>
Deploying tickets with Cloudflare Pages
|
|
||
useEffect(() => { | ||
if (!triggered.current) { | ||
void checkPurchaseOrder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Podemos llamar al checkPurchaseOrderMutation
directo y nos ahorramos un useCallback.
Porque el checkPurchaseOrderMutation
no cambia si se renderiza el componente.
|
||
useEffect(() => { | ||
if (!triggered.current) { | ||
void checkPurchaseOrder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tangencial, pero re pocas veces veo void
🤔 no se si derepente me estoy perdiendo algo... Pero si no estamos retornando checkPurchaseOrder
es necesario? O es mas estilistico?
export const PurchaseCallback = ({ | ||
purchaseOrderId, | ||
}: PurchaseCallbackProps) => { | ||
const triggered = useRef(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tenemos un estandar definido, pero prefiero usar refs
para dom nodes, o referencias que necesitemos que no se regeneren. (Onda setInterval por ejemplo...)
Podemos conversarlo, pero soy mas partidario de errar hacia el useState
por convención/default
const purchaseOrderId = params.get("purchaseOrderId"); | ||
|
||
if (!purchaseOrderId) { | ||
return toast("Error fetching purchase order"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toast
retorna undefined, asi que tecnicamente esto esta bien. Pero como toast no es un componente, creo que seria mejor o un poco mas claro, que retornaramos null
aca y que dejaramos el toast en un useEffect
useEffect(() => {
if(!purchaseOrderId) {
toast("Error fetching purchase order");
}
}, [purchaseOrderId])
Improves purchase callback logic. Note: design & localization will be improved in future PRs, setting up minimal UI for now.