Open History to see the last commit
1import type { StaticScreenProps } from "@react-navigation/native";
2import { useMemo } from "react";
3import { NativeStackScreenOptions } from "../../native/StackHeader";
4
5import { NewTaskDraftScreen } from "./NewTaskDraftScreen";
6
7type NewTaskDraftRouteParams = {
8 readonly environmentId?: string | string[];
9 readonly projectId?: string | string[];
10 readonly title?: string | string[];
11 readonly pendingTaskId?: string | string[];
12 readonly incomingShareId?: string | string[];
13};
14
15export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraftRouteParams>) {
16 const params = route.params ?? {};
17
18 // Keyed on the params object so a fresh navigation to this (already
19 // mounted) screen produces a new reference, letting the draft screen
20 // re-apply the requested project.
21 const initialProjectRef = useMemo(
22 () => ({
23 environmentId: Array.isArray(params.environmentId)
24 ? params.environmentId[0]
25 : params.environmentId,
26 projectId: Array.isArray(params.projectId) ? params.projectId[0] : params.projectId,
27 }),
28 [route.params],
29 );
30
31 return (
32 <>
33 <NativeStackScreenOptions
34 options={{
35 title: Array.isArray(params.title) ? params.title[0] : (params.title ?? "New task"),
36 }}
37 />
38 <NewTaskDraftScreen
39 initialProjectRef={initialProjectRef}
40 incomingShareId={
41 Array.isArray(params.incomingShareId) ? params.incomingShareId[0] : params.incomingShareId
42 }
43 pendingTaskId={
44 Array.isArray(params.pendingTaskId) ? params.pendingTaskId[0] : params.pendingTaskId
45 }
46 />
47 </>
48 );
49}