-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kleros-app): add-restrictions-check-in-upload-file
- Loading branch information
1 parent
e8e48f4
commit 87eacc1
Showing
6 changed files
with
526 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { gql, type GraphQLClient } from "graphql-request"; | ||
import { Products } from "."; | ||
|
||
export type Role = { | ||
name: string; | ||
restriction: { | ||
maxSize: number; | ||
allowedMimeTypes: string[]; | ||
}; | ||
}; | ||
|
||
type FetchRolesResponse = { | ||
roles: Role[]; | ||
}; | ||
|
||
const query = gql` | ||
query Roles($product: Products!) { | ||
roles(product: $product) { | ||
name | ||
restriction { | ||
maxSize | ||
allowedMimeTypes | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export async function fetchRestrictions(client: GraphQLClient, product: Products): Promise<Role[]> { | ||
return client | ||
.request<FetchRolesResponse>(query, { product }) | ||
.then((response) => response.roles) | ||
.catch((errors) => { | ||
// eslint-disable-next-line no-console | ||
console.log("Error fetching roles :", { errors }); | ||
const errorMessage = Array.isArray(errors?.response?.errors) | ||
? errors.response.errors[0]?.message | ||
: "Error fetching roles"; | ||
throw Error(errorMessage); | ||
}); | ||
} |
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 |
---|---|---|
|
@@ -25,7 +25,8 @@ | |
"web-devtools", | ||
"eslint-config", | ||
"prettier-config", | ||
"tsconfig" | ||
"tsconfig", | ||
"kleros-app" | ||
], | ||
"packageManager": "[email protected]", | ||
"volta": { | ||
|
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
Oops, something went wrong.