fix(space): 정리된 intent hud와 리뷰 반영
This commit is contained in:
@@ -74,6 +74,11 @@ export interface UpdateCurrentFocusSessionSelectionRequest {
|
||||
soundPresetId?: string | null;
|
||||
}
|
||||
|
||||
export interface UpdateCurrentFocusSessionIntentRequest {
|
||||
goal?: string;
|
||||
microStep?: string | null;
|
||||
}
|
||||
|
||||
export interface AdvanceCurrentGoalRequest {
|
||||
completedGoal: string;
|
||||
nextGoal: string;
|
||||
@@ -170,6 +175,17 @@ export const focusSessionApi = {
|
||||
return normalizeFocusSession(response);
|
||||
},
|
||||
|
||||
updateCurrentIntent: async (
|
||||
payload: UpdateCurrentFocusSessionIntentRequest,
|
||||
): Promise<FocusSession> => {
|
||||
const response = await apiClient<RawFocusSession>('api/v1/focus-sessions/current/intent', {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
return normalizeFocusSession(response);
|
||||
},
|
||||
|
||||
completeSession: async (payload: CompleteFocusSessionRequest): Promise<FocusSession> => {
|
||||
const response = await apiClient<RawFocusSession>('api/v1/focus-sessions/current/complete', {
|
||||
method: 'POST',
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
type FocusSessionPhase,
|
||||
type FocusSessionState,
|
||||
type StartFocusSessionRequest,
|
||||
type UpdateCurrentFocusSessionIntentRequest,
|
||||
type UpdateCurrentFocusSessionSelectionRequest,
|
||||
} from '../api/focusSessionApi';
|
||||
|
||||
@@ -72,6 +73,7 @@ interface UseFocusSessionEngineResult {
|
||||
pauseSession: () => Promise<FocusSession | null>;
|
||||
resumeSession: () => Promise<FocusSession | null>;
|
||||
restartCurrentPhase: () => Promise<FocusSession | null>;
|
||||
updateCurrentIntent: (payload: UpdateCurrentFocusSessionIntentRequest) => Promise<FocusSession | null>;
|
||||
updateCurrentSelection: (payload: UpdateCurrentFocusSessionSelectionRequest) => Promise<FocusSession | null>;
|
||||
completeSession: (payload: CompleteFocusSessionRequest) => Promise<FocusSession | null>;
|
||||
advanceGoal: (payload: AdvanceCurrentGoalRequest) => Promise<AdvanceCurrentGoalResponse | null>;
|
||||
@@ -120,7 +122,7 @@ export const useFocusSessionEngine = (): UseFocusSessionEngineResult => {
|
||||
}, [syncCurrentSession]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentSession) {
|
||||
if (!currentSession || currentSession.state !== 'running') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -235,6 +237,18 @@ export const useFocusSessionEngine = (): UseFocusSessionEngineResult => {
|
||||
|
||||
return applySession(session);
|
||||
},
|
||||
updateCurrentIntent: async (payload) => {
|
||||
if (!currentSession) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const session = await runMutation(
|
||||
() => focusSessionApi.updateCurrentIntent(payload),
|
||||
copy.focusSession.intentUpdateFailed,
|
||||
);
|
||||
|
||||
return applySession(session);
|
||||
},
|
||||
updateCurrentSelection: async (payload) => {
|
||||
if (!currentSession) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user