Frontend: unified /runs URL (#3912)
This commit is contained in:
17
skyvern-frontend/src/hooks/useFirstParam.ts
Normal file
17
skyvern-frontend/src/hooks/useFirstParam.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
/**
|
||||
* Given a list of parameter names, returns the value of the first one that exists in the URL parameters.
|
||||
*/
|
||||
const useFirstParam = (...paramNames: string[]) => {
|
||||
const params = useParams();
|
||||
for (const name of paramNames) {
|
||||
const value = params[name];
|
||||
if (value) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export { useFirstParam };
|
||||
Reference in New Issue
Block a user