-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨(backoffice) add template name field into ContractDefinition edit view
We recenty create a new contract template. From now, there was only one, so the contract definition edit view in the back office application did not display input for this field.
- Loading branch information
Showing
12 changed files
with
165 additions
and
40 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
43 changes: 43 additions & 0 deletions
43
...d/admin/src/components/templates/contract-definition/inputs/RHFContractDefinitionName.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,43 @@ | ||
import { useIntl, defineMessages } from "react-intl"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { | ||
RHFSelect, | ||
RHFSelectProps, | ||
} from "@/components/presentational/hook-form/RHFSelect"; | ||
import { ContractDefinitionRepository } from "@/services/repositories/contract-definition/ContractDefinitionRepository"; | ||
|
||
const messages = defineMessages({ | ||
inputLabel: { | ||
id: "components.templates.contractDefinitions.inputs.RHFContractDefinitionName.inputLabel", | ||
defaultMessage: "Template name", | ||
description: 'Label for the "name" input', | ||
}, | ||
}); | ||
|
||
type Props = RHFSelectProps & { | ||
name: string; | ||
}; | ||
|
||
function RHFContractDefinitionName({ name }: Props) { | ||
const intl = useIntl(); | ||
const templateNames = useQuery({ | ||
queryKey: ["contractDefinitionTemplates"], | ||
staleTime: Infinity, | ||
gcTime: Infinity, | ||
queryFn: async () => { | ||
return ContractDefinitionRepository.getAllTemplates(); | ||
}, | ||
}); | ||
|
||
return ( | ||
<RHFSelect | ||
data-testid="contract-definition-template-name-input" | ||
disabled={templateNames.isLoading} | ||
name={name} | ||
options={templateNames.data ?? []} | ||
label={intl.formatMessage(messages.inputLabel)} | ||
/> | ||
); | ||
} | ||
|
||
export default RHFContractDefinitionName; |
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
7 changes: 5 additions & 2 deletions
7
src/frontend/admin/src/services/factories/contract-definition/index.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
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