feat: implement session creation flow
Refactor `CreateSessionDialog` to be controlled by its parent instead of using an internal `open` prop. Lift the state up to `JournalPanel` and pass the creation callback through `JournalHeader` to `SessionDropdown`.
This commit is contained in:
@@ -8,13 +8,15 @@ import {
|
||||
hydrateFromServer,
|
||||
useJournalStream,
|
||||
} from "../stores/journalStream";
|
||||
import { CreateSessionDialog } from "./CreateSessionDialog";
|
||||
|
||||
export const SessionDropdown: Component = () => {
|
||||
interface SessionDropdownProps {
|
||||
onCreate: () => void;
|
||||
}
|
||||
|
||||
export const SessionDropdown: Component<SessionDropdownProps> = (props) => {
|
||||
const stream = useJournalStream();
|
||||
const manifest = sessions;
|
||||
const [dropdownOpen, setDropdownOpen] = createSignal(false);
|
||||
const [showCreateDialog, setShowCreateDialog] = createSignal(false);
|
||||
let dropdownRef!: HTMLDivElement;
|
||||
|
||||
const handleSessionSelect = (id: string) => {
|
||||
@@ -75,7 +77,8 @@ export const SessionDropdown: Component = () => {
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
setShowCreateDialog(true);
|
||||
setDropdownOpen(false);
|
||||
props.onCreate();
|
||||
}}
|
||||
class="w-full text-left px-3 py-1 text-xs text-blue-600 hover:bg-gray-100"
|
||||
>
|
||||
@@ -83,10 +86,6 @@ export const SessionDropdown: Component = () => {
|
||||
</button>
|
||||
</div>
|
||||
</Show>
|
||||
<CreateSessionDialog
|
||||
open={showCreateDialog()}
|
||||
onClose={() => setShowCreateDialog(false)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user