generated from rectangular-labs/monorepo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
chore: fix workflow generations #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,292 @@ | ||
| import { Button } from "@rectangular-labs/ui/components/ui/button"; | ||
| import { Input } from "@rectangular-labs/ui/components/ui/input"; | ||
| import { Label } from "@rectangular-labs/ui/components/ui/label"; | ||
| import { toast } from "@rectangular-labs/ui/components/ui/sonner"; | ||
| import { Textarea } from "@rectangular-labs/ui/components/ui/textarea"; | ||
| import { useMutation } from "@tanstack/react-query"; | ||
| import { createFileRoute, notFound } from "@tanstack/react-router"; | ||
| import { useState } from "react"; | ||
| import { getApiClientRq } from "~/lib/api"; | ||
|
|
||
| export const Route = createFileRoute("/_authed/admin")({ | ||
| beforeLoad: ({ context }) => { | ||
| if (!context.user?.email?.endsWith("fluidposts.com")) { | ||
| throw notFound(); | ||
| } | ||
| }, | ||
| component: RouteComponent, | ||
| }); | ||
|
|
||
| function RouteComponent() { | ||
| const api = getApiClientRq(); | ||
| const [organizationSlug, setOrganizationSlug] = useState(""); | ||
| const [projectSlug, setProjectSlug] = useState(""); | ||
| const [instructions, setInstructions] = useState(""); | ||
| const [phaseStrategyName, setPhaseStrategyName] = useState(""); | ||
|
|
||
| const { mutate: triggerOnboarding, isPending } = useMutation( | ||
| api.admin.triggerOnboardingTask.mutationOptions({ | ||
| onSuccess: () => { | ||
| toast.success("Triggered onboarding workflow successfully."); | ||
| }, | ||
| onError: (error) => { | ||
| toast.error(error.message); | ||
| }, | ||
| }), | ||
| ); | ||
|
|
||
| const { mutate: triggerStrategySuggestions, isPending: isPendingStrategy } = | ||
| useMutation( | ||
| api.admin.triggerStrategySuggestionsTask.mutationOptions({ | ||
| onSuccess: () => { | ||
| toast.success( | ||
| "Triggered strategy suggestions workflow successfully.", | ||
| ); | ||
| setInstructions(""); | ||
| }, | ||
| onError: (error) => { | ||
| toast.error(error.message); | ||
| }, | ||
| }), | ||
| ); | ||
|
|
||
| const { mutate: triggerStrategyPhase, isPending: isPendingStrategyPhase } = | ||
| useMutation( | ||
| api.admin.triggerStrategyPhaseGenerationTask.mutationOptions({ | ||
| onSuccess: () => { | ||
| toast.success( | ||
| "Triggered strategy phase generation workflow successfully.", | ||
| ); | ||
| setPhaseStrategyName(""); | ||
| }, | ||
| onError: (error) => { | ||
| toast.error(error.message); | ||
| }, | ||
| }), | ||
| ); | ||
|
|
||
| const handleSubmit = (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
| if (!organizationSlug.trim()) { | ||
| toast.error("Please enter an organization slug"); | ||
| return; | ||
| } | ||
| if (!projectSlug.trim()) { | ||
| toast.error("Please enter a project slug"); | ||
| return; | ||
| } | ||
| triggerOnboarding({ organizationSlug, projectSlug }); | ||
| }; | ||
|
|
||
| const handleStrategySubmit = (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
| if (!organizationSlug.trim()) { | ||
| toast.error("Please enter an organization slug"); | ||
| return; | ||
| } | ||
| if (!projectSlug.trim()) { | ||
| toast.error("Please enter a project slug"); | ||
| return; | ||
| } | ||
| triggerStrategySuggestions({ | ||
| organizationSlug, | ||
| projectSlug, | ||
| instructions, | ||
| }); | ||
| }; | ||
|
|
||
| const handleStrategyPhaseSubmit = (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
| if (!organizationSlug.trim()) { | ||
| toast.error("Please enter an organization slug"); | ||
| return; | ||
| } | ||
| if (!projectSlug.trim()) { | ||
| toast.error("Please enter a project slug"); | ||
| return; | ||
| } | ||
| if (!phaseStrategyName.trim()) { | ||
| toast.error("Please enter a strategy name"); | ||
| return; | ||
| } | ||
|
|
||
| triggerStrategyPhase({ | ||
| organizationSlug, | ||
| projectSlug, | ||
| strategyName: phaseStrategyName, | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <main className="mx-auto flex w-full max-w-3xl flex-col items-center space-y-6 p-6"> | ||
| <div className="flex w-full max-w-md flex-col gap-2"> | ||
| <h1 className="font-bold text-3xl tracking-tight">Admin</h1> | ||
| <p className="text-muted-foreground"> | ||
| Internal tools for the fluidposts team. | ||
| </p> | ||
| </div> | ||
|
|
||
| <div className="w-full max-w-md rounded-lg border bg-card text-card-foreground shadow-sm"> | ||
| <div className="flex flex-col space-y-1.5 p-6"> | ||
| <h3 className="font-semibold leading-none tracking-tight"> | ||
| Trigger Onboarding Task | ||
| </h3> | ||
| <p className="text-muted-foreground text-sm"> | ||
| Trigger the onboarding workflow in the api-seo package for a | ||
| specific project. | ||
| </p> | ||
| </div> | ||
| <div className="p-6 pt-0"> | ||
| <form className="space-y-4" onSubmit={handleSubmit}> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="organizationSlug">Organization Slug</Label> | ||
| <Input | ||
| disabled={isPending} | ||
| id="organizationSlug" | ||
| onChange={(e) => setOrganizationSlug(e.target.value)} | ||
| placeholder="e.g. acme" | ||
| value={organizationSlug} | ||
| /> | ||
| </div> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="projectSlug">Project Slug</Label> | ||
| <Input | ||
| disabled={isPending} | ||
| id="projectSlug" | ||
| onChange={(e) => setProjectSlug(e.target.value)} | ||
| placeholder="e.g. acme-corp" | ||
| value={projectSlug} | ||
| /> | ||
| </div> | ||
| <Button | ||
| disabled={ | ||
| !organizationSlug.trim() || !projectSlug.trim() || isPending | ||
| } | ||
| isLoading={isPending} | ||
| type="submit" | ||
| > | ||
| Trigger Workflow | ||
| </Button> | ||
| </form> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="w-full max-w-md rounded-lg border bg-card text-card-foreground shadow-sm"> | ||
| <div className="flex flex-col space-y-1.5 p-6"> | ||
| <h3 className="font-semibold leading-none tracking-tight"> | ||
| Trigger Strategy Suggestions Task | ||
| </h3> | ||
| <p className="text-muted-foreground text-sm"> | ||
| Trigger the strategy suggestions workflow in the api-seo package for | ||
| a specific project. | ||
| </p> | ||
| </div> | ||
| <div className="p-6 pt-0"> | ||
| <form className="space-y-4" onSubmit={handleStrategySubmit}> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="strategyOrganizationSlug"> | ||
| Organization Slug | ||
| </Label> | ||
| <Input | ||
| disabled={isPendingStrategy} | ||
| id="strategyOrganizationSlug" | ||
| onChange={(e) => setOrganizationSlug(e.target.value)} | ||
| placeholder="e.g. acme" | ||
| value={organizationSlug} | ||
| /> | ||
| </div> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="strategyProjectSlug">Project Slug</Label> | ||
| <Input | ||
| disabled={isPendingStrategy} | ||
| id="strategyProjectSlug" | ||
| onChange={(e) => setProjectSlug(e.target.value)} | ||
| placeholder="e.g. acme-corp" | ||
| value={projectSlug} | ||
| /> | ||
| </div> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="instructions">Instructions</Label> | ||
| <Textarea | ||
| disabled={isPendingStrategy} | ||
| id="instructions" | ||
| onChange={(e) => setInstructions(e.target.value)} | ||
| placeholder="Enter instructions for strategy generation..." | ||
| value={instructions} | ||
| /> | ||
| </div> | ||
| <Button | ||
| disabled={ | ||
| !organizationSlug.trim() || | ||
| !projectSlug.trim() || | ||
| isPendingStrategy | ||
| } | ||
| isLoading={isPendingStrategy} | ||
| type="submit" | ||
| > | ||
| Trigger Strategy Suggestions | ||
| </Button> | ||
| </form> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="w-full max-w-md rounded-lg border bg-card text-card-foreground shadow-sm"> | ||
| <div className="flex flex-col space-y-1.5 p-6"> | ||
| <h3 className="font-semibold leading-none tracking-tight"> | ||
| Trigger Strategy Phase Generation | ||
| </h3> | ||
| <p className="text-muted-foreground text-sm"> | ||
| Trigger the strategy phase generation workflow in the api-seo | ||
| package for a specific strategy. | ||
| </p> | ||
| </div> | ||
| <div className="p-6 pt-0"> | ||
| <form className="space-y-4" onSubmit={handleStrategyPhaseSubmit}> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="phaseOrganizationSlug">Organization Slug</Label> | ||
| <Input | ||
| disabled={isPendingStrategyPhase} | ||
| id="phaseOrganizationSlug" | ||
| onChange={(e) => setOrganizationSlug(e.target.value)} | ||
| placeholder="e.g. rectangular-labs" | ||
| value={organizationSlug} | ||
| /> | ||
| </div> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="phaseProjectSlug">Project Slug</Label> | ||
| <Input | ||
| disabled={isPendingStrategyPhase} | ||
| id="phaseProjectSlug" | ||
| onChange={(e) => setProjectSlug(e.target.value)} | ||
| placeholder="e.g. acme-corp" | ||
| value={projectSlug} | ||
| /> | ||
| </div> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="phaseStrategyName">Strategy Name</Label> | ||
| <Input | ||
| disabled={isPendingStrategyPhase} | ||
| id="phaseStrategyName" | ||
| onChange={(e) => setPhaseStrategyName(e.target.value)} | ||
| placeholder="e.g. Topic Cluster For CRM ROI" | ||
| value={phaseStrategyName} | ||
| /> | ||
| </div> | ||
| <Button | ||
| disabled={ | ||
| !organizationSlug.trim() || | ||
| !projectSlug.trim() || | ||
| !phaseStrategyName.trim() || | ||
| isPendingStrategyPhase | ||
| } | ||
| isLoading={isPendingStrategyPhase} | ||
| type="submit" | ||
| > | ||
| Trigger Strategy Phase Generation | ||
| </Button> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| </main> | ||
| ); | ||
| } | ||
ElasticBottle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both forms share the same projectSlug state variable. When a user enters a project slug in one form, it will appear in both forms. This creates a confusing user experience. Each form should have its own independent state variable for the project slug.