import { Stack, useLocalSearchParams, useRouter } from "expo-router";

function JobsStack() {
  const router = useRouter();
  const params = useLocalSearchParams();
  console.log("*** ~ JobsStack ~ params:", params);

  return (
    <Stack
      screenOptions={{
        headerTitleStyle: {
          fontWeight: "bold",
        },
      }}
    >
      <Stack.Screen
        name="index"
        options={{
          title: "Search",
          headerSearchBarOptions: {
            placement: "automatic",
            placeholder: "Search",
            onChangeText: (event) => {
              router.setParams({
                search: event?.nativeEvent?.text,
              });
            },
          },
        }}
      />
      <Stack.Screen
        name="[jobId]"
        options={({ route }) => ({
          //headerShown: false,
          title: (route.params as any)?.title || "Job Details",
        })}
      />
    </Stack>
  );
}

export default JobsStack;
