Skip to content

Commit 94d7062

Browse files
authored
Merge pull request framer#404 from darkroomengineering/ashby
Ashby - Validate Job Board Name and allow Job Board URL
2 parents ffed95a + 213a765 commit 94d7062

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

plugins/ashby/src/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ form {
7777
pointer-events: none;
7878
}
7979

80-
.setup div {
80+
.setup .field {
8181
display: flex;
8282
flex-direction: row;
8383
align-items: center;

plugins/ashby/src/components/SelectDataSource.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,36 @@ export function SelectDataSource({
2929

3030
setIsLoading(true)
3131

32-
getDataSource(jobBoardName, selectedDataSourceId)
33-
.then(dataSource => {
34-
onSelectDataSource(dataSource)
35-
onSelectJobBoardName(jobBoardName)
32+
// support job board URL
33+
const parsedJobBoardName = jobBoardName.replace("https://jobs.ashbyhq.com/", "")
34+
35+
// check if the job board name is valid
36+
fetch(`https://api.ashbyhq.com/posting-api/job-board/${parsedJobBoardName}`)
37+
.then(e => {
38+
if (e.status !== 200) {
39+
throw new Error("Invalid job board name")
40+
}
41+
42+
getDataSource(parsedJobBoardName, selectedDataSourceId)
43+
.then(dataSource => {
44+
onSelectDataSource(dataSource)
45+
onSelectJobBoardName(parsedJobBoardName)
46+
})
47+
.catch((error: unknown) => {
48+
console.error(error)
49+
framer.notify(error instanceof Error ? error.message : "An unknown error occurred", {
50+
variant: "error",
51+
})
52+
})
53+
.finally(() => {
54+
setIsLoading(false)
55+
})
3656
})
3757
.catch((error: unknown) => {
3858
console.error(error)
3959
framer.notify(error instanceof Error ? error.message : "An unknown error occurred", {
4060
variant: "error",
4161
})
42-
})
43-
.finally(() => {
4462
setIsLoading(false)
4563
})
4664
},
@@ -54,7 +72,7 @@ export function SelectDataSource({
5472
<img src={hero} alt="Ashby Hero" />
5573

5674
<form onSubmit={handleSubmit}>
57-
<div>
75+
<div className="field">
5876
<p>Job Board Name</p>
5977
<input
6078
id="jobBoardName"

0 commit comments

Comments
 (0)