-
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.
* copy answers from other contexts * copy answers from other contexts * copy answers from other contexts * copy answers from other contexts
- Loading branch information
1 parent
ad56b23
commit 1d8bb00
Showing
11 changed files
with
192 additions
and
6 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
45 changes: 45 additions & 0 deletions
45
frontend/beCompliant/src/components/createContextPage/CopyContextDropdown.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,45 @@ | ||
import { Box, FormControl, FormLabel, Select, Spinner } from '@kvib/react'; | ||
import { useFetchTeamTableContexts } from '../../hooks/useFetchTeamTableContexts'; | ||
|
||
export function CopyContextDropdown({ | ||
tableId, | ||
teamId, | ||
copyContext, | ||
setCopyContext, | ||
}: { | ||
tableId: string; | ||
teamId: string; | ||
copyContext: string | null; | ||
setCopyContext: (context: string) => void; | ||
}) { | ||
const { data: contexts, isLoading: contextsIsLoading } = | ||
useFetchTeamTableContexts(teamId, tableId); | ||
|
||
if (contextsIsLoading) { | ||
return <Spinner size="sm" />; | ||
} | ||
|
||
return ( | ||
<Box marginBottom="1rem"> | ||
<FormLabel htmlFor="select"> | ||
Kopier svar fra eksisterende skjema | ||
</FormLabel> | ||
<FormControl> | ||
<Select | ||
id="select" | ||
placeholder="Velg skjema" | ||
onChange={(e) => setCopyContext(e.target.value)} | ||
bgColor="white" | ||
borderColor="gray.200" | ||
value={copyContext ?? undefined} | ||
> | ||
{contexts?.map((context) => ( | ||
<option key={context.id} value={context.id}> | ||
{context.name} | ||
</option> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
); | ||
} |
15 changes: 15 additions & 0 deletions
15
frontend/beCompliant/src/hooks/useFetchTeamTableContexts.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,15 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { apiConfig } from '../api/apiConfig'; | ||
import { axiosFetch } from '../api/Fetch'; | ||
import { Context } from './useFetchTeamContexts'; | ||
|
||
export function useFetchTeamTableContexts(teamId: string, tableId: string) { | ||
return useQuery({ | ||
queryKey: apiConfig.contexts.forTeamAndTable.queryKey(teamId, tableId), | ||
queryFn: () => | ||
axiosFetch<Context[]>({ | ||
url: `${apiConfig.contexts.forTeamAndTable.url(teamId, tableId)}`, | ||
}).then((response) => response.data), | ||
enabled: !!teamId && !!tableId, | ||
}); | ||
} |
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