-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: error structure for api error * fix: show error ASA Api returns an error + return an empty object when the siren is changed. * feat: instant error if siren is unknown * fix: a user can see a siren if it is free * feat: take care of siren only if form is validated
- Loading branch information
Showing
5 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ownersForSiren } from "./api" | ||
|
||
/** | ||
* A SIREN is free if it has no owners already bound to it. | ||
*/ | ||
export async function sirenIsFree(siren: string) { | ||
let isFree = true | ||
|
||
try { | ||
const { jsonBody } = await ownersForSiren(siren) | ||
console.log("jsonBody", jsonBody) | ||
isFree = jsonBody?.owners.length === 0 | ||
} catch (ignore) { | ||
// the API is designed to return an error if the user is not granted for the siren. This is what we want to ensure. | ||
isFree = false | ||
} | ||
console.log("isFree", siren, isFree) | ||
|
||
return isFree | ||
} |