-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agreement): publication d'une convention collective (#1273)
* feat(agreement): ajout d'une page qui liste les conventions collectives * feat(agreement): ajout d'une page pour éditer une convention collective * feat(agreement): ajout d'une page pour créer une convention collective * feat(agreement): ajout des synonymes * feat(agreement): fix issues * feat(agreement): fix hasura request * feat(agreement): mise à jour des scripts de rollback * feat(agreement): ajout du champ publication date * feat(agreement): publication d'une convention collective * fix: types * fix: test
- Loading branch information
Showing
13 changed files
with
186 additions
and
9 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 @@ | ||
export * from "./repository"; |
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,28 @@ | ||
import { gql } from "@urql/core"; | ||
import { Agreement } from "../type"; | ||
|
||
export const agreementQuery = gql` | ||
query MyQuery($id: bpchar!) { | ||
agreement: agreement_agreements_by_pk(id: $id) { | ||
id | ||
isSupported | ||
kali_id | ||
legifranceUrl | ||
name | ||
rootText | ||
shortName | ||
synonyms | ||
updatedAt | ||
workerNumber | ||
publicationDate | ||
} | ||
} | ||
`; | ||
|
||
export type AgreementRequest = { | ||
id: string; | ||
}; | ||
|
||
export type AgreementResponse = { | ||
agreement: Agreement; | ||
}; |
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,26 @@ | ||
import { agreementQuery, AgreementRequest, AgreementResponse } from "./query"; | ||
import { ApiClient } from "src/lib/api"; | ||
|
||
export class AgreementRepository { | ||
client: ApiClient; | ||
|
||
constructor(client: ApiClient) { | ||
this.client = client; | ||
} | ||
|
||
async fetch(id: string) { | ||
const { error, data } = await this.client.query< | ||
AgreementResponse, | ||
AgreementRequest | ||
>(agreementQuery, { | ||
id, | ||
}); | ||
if (error) { | ||
throw error; | ||
} | ||
if (!data) { | ||
throw new Error(`Pas de convention collective pour l'id ${id}`); | ||
} | ||
return data.agreement; | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
targets/frontend/src/modules/agreements/components/Edition/publish.mutation.ts
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,25 @@ | ||
import { OperationResult, useMutation } from "urql"; | ||
|
||
export const publishMutation = ` | ||
mutation publish_information( | ||
$id: uuid! | ||
) { | ||
publish(id: $id, source: "conventions_collectives") { | ||
cdtnId | ||
} | ||
} | ||
`; | ||
|
||
export type PublishMutationResult = (id: string) => Promise<OperationResult>; | ||
|
||
export const usePublishMutation = (): PublishMutationResult => { | ||
const [, execute] = useMutation<string>(publishMutation); | ||
const resultFunction = async (id: string) => { | ||
const result = await execute({ id }); | ||
if (result.error) { | ||
throw new Error(result.error.message); | ||
} | ||
return result; | ||
}; | ||
return resultFunction; | ||
}; |
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
Oops, something went wrong.