Skip to content

Commit

Permalink
💄 Show error when we don't have available interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
srod committed Jan 10, 2025
1 parent 88f5750 commit b7f36cf
Showing 1 changed file with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { campaignAtom } from "@/module/campaigns/atoms/campaign";
import { campaignStepAtom } from "@/module/campaigns/atoms/steps";
import { FormFromTo } from "@/module/campaigns/component/Creation/MetricsCampaign/FormFromTo";
import { Panel } from "@/module/common/component/Panel";
import { FormDescription } from "@/module/forms/Form";
Expand All @@ -9,7 +10,8 @@ import {
type ProductTypesKey,
interactionTypes,
} from "@frak-labs/core-sdk";
import { useAtomValue } from "jotai/index";
import { Button } from "@module/component/Button";
import { useAtomValue, useSetAtom } from "jotai";
import { useMemo } from "react";
import type { UseFormReturn } from "react-hook-form";

Expand All @@ -20,6 +22,7 @@ export function FormPriceRange({
form: UseFormReturn<Campaign["triggers"]>;
productTypes: ProductTypesKey[];
}) {
const setStep = useSetAtom(campaignStepAtom);
const { type: currentGoal } = useAtomValue(campaignAtom);
const availableInteractions = useMemo(() => {
if (!currentGoal) return [];
Expand Down Expand Up @@ -48,13 +51,33 @@ export function FormPriceRange({

return (
<Panel title="Configure Price Range">
<FormDescription>
Set a price range for each campaign objective. The budget will
be distributed between the referee and referrer according to an
automatically optimized allocation key. Frak will apply a 20%
management fee to support the campaign delivery and to cover
operational costs.
</FormDescription>
{availableInteractions.length === 0 && (
<>
<FormDescription>
<span className="error">
No interactions available for the current goal,
please select another goal at previous step.
</span>
</FormDescription>
<FormDescription>
<Button
variant={"informationOutline"}
onClick={() => setStep((prev) => prev - 1)}
>
Go back to previous step
</Button>
</FormDescription>
</>
)}
{availableInteractions.length > 0 && (
<FormDescription>
Set a price range for each campaign objective. The budget
will be distributed between the referee and referrer
according to an automatically optimized allocation key. Frak
will apply a 20% management fee to support the campaign
delivery and to cover operational costs.
</FormDescription>
)}
{availableInteractions.map(({ key, label }) => (
<FormFromTo
key={key}
Expand Down

0 comments on commit b7f36cf

Please sign in to comment.