-
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.
fix(contributions): ajout d'un selecteur de references pour les fiche…
…s SP (#1029)
- Loading branch information
Showing
20 changed files
with
499 additions
and
348 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
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
38 changes: 38 additions & 0 deletions
38
targets/frontend/src/components/contributions/answers/references/FicheSpDocumentInput.tsx
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,38 @@ | ||
import { getRouteBySource } from "@socialgouv/cdtn-sources"; | ||
import { Control } from "react-hook-form"; | ||
import { Document } from "../../type"; | ||
import { ReferenceInput } from "./ReferenceInput"; | ||
import { useFicheSpSearchCdtnReferencesQuery } from "./ficheSpReferenceSearch.query"; | ||
|
||
type Props = { | ||
name: string; | ||
control: Control<any>; | ||
disabled?: boolean; | ||
}; | ||
|
||
export const FicheSpDocumentInput = ({ | ||
name, | ||
control, | ||
disabled = false, | ||
}: Props): React.ReactElement => ( | ||
<ReferenceInput<Document> | ||
label={`Fiche service-public`} | ||
color="info" | ||
name={name} | ||
disabled={disabled} | ||
control={control} | ||
fetcher={useFicheSpSearchCdtnReferencesQuery} | ||
isEqual={(option, value) => value.cdtnId === option.cdtnId} | ||
getLabel={(item) => `${item.title} (${item.slug})`} | ||
onClick={(item) => { | ||
const newWindow = window.open( | ||
`https://code.travail.gouv.fr/${getRouteBySource(item.source)}/${ | ||
item.slug | ||
}`, | ||
"_blank", | ||
"noopener,noreferrer" | ||
); | ||
if (newWindow) newWindow.opener = null; | ||
}} | ||
/> | ||
); |
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.