import { createDomain, sample } from 'effector';
import { RouteGenerateRes } from '../../bff-auth/src/export-types';
import { generateFx } from '../generate';
import { createRoute } from 'atomic-router';

export const PageResultRoute = createRoute();

const resultDomain = createDomain('result');

export const $result = resultDomain.store<null | RouteGenerateRes>(null)
    .on(generateFx.doneData, (_, payload) => payload)

sample({
    clock: generateFx.doneData,
    fn: (data) => ({ postId: data.request_id }),
    target: PageResultRoute.open,
});