Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/admin/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ RESEND_API_KEY=""
# Leave these empty to run without the referral widget
# REFERRAL_PROGRAM_CLIENT_ID=""
# REFERRAL_PROGRAM_CLIENT_SECRET=""
# NEXT_PUBLIC_REFREF_PROJECT_ID=""
# NEXT_PUBLIC_REFREF_PRODUCT_ID=""
# NEXT_PUBLIC_REFREF_PROGRAM_ID=""

# PostHog Analytics (OPTIONAL)
# Required only if you want to enable analytics and feature flags
# Get your project key from: https://posthog.com/
# Get your product key from: https://posthog.com/
# Leave NEXT_PUBLIC_POSTHOG_KEY empty to disable PostHog entirely (no console errors)
# Set NEXT_PUBLIC_POSTHOG_ENABLED to false to opt out of tracking while keeping PostHog initialized
NEXT_PUBLIC_POSTHOG_KEY=""
Expand Down
8 changes: 4 additions & 4 deletions apps/admin/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Create T3 App

This is a [T3 Stack](https://create.t3.gg/) project bootstrapped with `create-t3-app`.
This is a [T3 Stack](https://create.t3.gg/) product bootstrapped with `create-t3-app`.

## What's next? How do I make an app with this?

We try to keep this project as simple as possible, so you can start with just the scaffolding we set up for you, and add additional things later when they become necessary.
We try to keep this product as simple as possible, so you can start with just the scaffolding we set up for you, and add additional things later when they become necessary.

If you are not familiar with the different technologies used in this project, please refer to the respective docs. If you still are in the wind, please join our [Discord](https://t3.gg/discord) and ask for help.
If you are not familiar with the different technologies used in this product, please refer to the respective docs. If you still are in the wind, please join our [Discord](https://t3.gg/discord) and ask for help.

- [Next.js](https://nextjs.org)
- [NextAuth.js](https://next-auth.js.org)
Expand All @@ -32,7 +32,7 @@ Follow our deployment guides for [Vercel](https://create.t3.gg/en/deployment/ver

## Authentication and Route Protection

This project implements a comprehensive authentication system with multiple layers of protection:
This product implements a comprehensive authentication system with multiple layers of protection:

### Route Protection Layers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,33 @@ import {
AlertDialogTitle,
} from "@refref/ui/components/alert-dialog";

export default function ProjectsPage() {
export default function ProductsPage() {
const router = useRouter();
const [open, setOpen] = useState(false);
const [name, setName] = useState("");
const [description, setDescription] = useState("");
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const [projectToDelete, setProjectToDelete] = useState<string | null>(null);
const [productToDelete, setProductToDelete] = useState<string | null>(null);
const utils = api.useUtils();

// const { data: projects, isLoading } = api.project.getAll.useQuery();
const projects: any[] = [];
// const { data: products, isLoading } = api.product.getAll.useQuery();
const products: any[] = [];
const isLoading = false;
const createProject = api.project.create.useMutation({
const createProduct = api.product.create.useMutation({
onSuccess: () => {
setOpen(false);
setName("");
// utils.project.getAll.invalidate();
// utils.product.getAll.invalidate();
},
});

// const deleteProject = api.project.delete.useMutation({
// const deleteProduct = api.product.delete.useMutation({
// onSuccess: () => {
// setDeleteDialogOpen(false);
// // utils.project.getAll.invalidate();
// // utils.product.getAll.invalidate();
// },
// });
const deleteProject = {
const deleteProduct = {
mutate: (data: any) => {
console.log("Delete not implemented", data);
},
Expand All @@ -73,15 +73,15 @@ export default function ProjectsPage() {

const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
createProject.mutate({
createProduct.mutate({
name,
url: `https://example.com/${name.toLowerCase().replace(/\s+/g, "-")}`,
});
};

const handleDelete = () => {
if (projectToDelete) {
// deleteProject.mutate({ id: projectToDelete });
if (productToDelete) {
// deleteProduct.mutate({ id: productToDelete });
console.log("Delete not implemented");
}
};
Expand All @@ -90,7 +90,7 @@ export default function ProjectsPage() {
return <div>Loading...</div>;
}

const breadcrumbs = [{ label: "Projects", href: "/projects" }];
const breadcrumbs = [{ label: "Products", href: "/products" }];

return (
<>
Expand All @@ -101,15 +101,15 @@ export default function ProjectsPage() {
<DialogTrigger asChild>
<Button size="sm">
<Plus className="mr-2 h-4 w-4" />
Create Project
Create Product
</Button>
</DialogTrigger>
<DialogContent>
<form onSubmit={handleSubmit}>
<DialogHeader>
<DialogTitle>Create Project</DialogTitle>
<DialogTitle>Create Product</DialogTitle>
<DialogDescription>
Create a new project to organize your referral programs.
Create a new product to organize your referral programs.
</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
Expand All @@ -119,13 +119,13 @@ export default function ProjectsPage() {
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
placeholder="Enter project name"
placeholder="Enter product name"
/>
</div>
</div>
<DialogFooter>
<Button type="submit" disabled={createProject.isPending}>
{createProject.isPending ? "Creating..." : "Create Project"}
<Button type="submit" disabled={createProduct.isPending}>
{createProduct.isPending ? "Creating..." : "Create Product"}
</Button>
</DialogFooter>
</form>
Expand All @@ -136,10 +136,10 @@ export default function ProjectsPage() {
<div className="flex-1 overflow-auto">
<div className="p-4 lg:p-6 space-y-6">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{projects?.map((project) => (
<Card key={project.id} className="relative">
{products?.map((product) => (
<Card key={product.id} className="relative">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<h2 className="text-xl font-semibold">{project.name}</h2>
<h2 className="text-xl font-semibold">{product.name}</h2>
<div className="flex items-center gap-1">
<Dialog>
<DialogTrigger asChild>
Expand All @@ -149,9 +149,9 @@ export default function ProjectsPage() {
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Project Settings</DialogTitle>
<DialogTitle>Product Settings</DialogTitle>
<DialogDescription>
View your project's client ID and secret for JWT
View your product's client ID and secret for JWT
generation.
</DialogDescription>
</DialogHeader>
Expand All @@ -160,7 +160,7 @@ export default function ProjectsPage() {
<Label htmlFor="clientId">Client ID</Label>
<Input
id="clientId"
value={project.clientId ?? ""}
value={product.clientId ?? ""}
readOnly
className="font-mono"
/>
Expand All @@ -169,7 +169,7 @@ export default function ProjectsPage() {
<Label htmlFor="clientSecret">Client Secret</Label>
<Input
id="clientSecret"
value={project.clientSecret ?? ""}
value={product.clientSecret ?? ""}
readOnly
className="font-mono"
/>
Expand All @@ -187,12 +187,12 @@ export default function ProjectsPage() {
<DropdownMenuItem
className="text-destructive focus:text-destructive"
onClick={() => {
setProjectToDelete(project.id);
setProductToDelete(product.id);
setDeleteDialogOpen(true);
}}
>
<Trash2 className="mr-2 h-4 w-4" />
Delete Project
Delete Product
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Expand All @@ -212,9 +212,9 @@ export default function ProjectsPage() {
<AlertDialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete Project</AlertDialogTitle>
<AlertDialogTitle>Delete Product</AlertDialogTitle>
<AlertDialogDescription>
Are you sure you want to delete this project? This action cannot
Are you sure you want to delete this product? This action cannot
be undone.
</AlertDialogDescription>
</AlertDialogHeader>
Expand All @@ -223,9 +223,9 @@ export default function ProjectsPage() {
<AlertDialogAction
onClick={handleDelete}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
disabled={deleteProject.isPending}
disabled={deleteProduct.isPending}
>
{deleteProject.isPending ? "Deleting..." : "Delete"}
{deleteProduct.isPending ? "Deleting..." : "Delete"}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
Expand Down
10 changes: 5 additions & 5 deletions apps/admin/src/app/(authenticated)/(core)/programs/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function NewProgramPage() {
const searchParams = useSearchParams();
const templateId = searchParams?.get("templateId");
const templateName = searchParams?.get("title");
const { data: activeProject } = authClient.useActiveOrganization();
const { data: activeProduct } = authClient.useActiveOrganization();

// Create program mutation
const createProgram = api.program.create.useMutation({
Expand All @@ -31,9 +31,9 @@ export default function NewProgramPage() {
if (!templateId) router.replace("/programs");
}, [templateId, router]);

// Create program as soon as templateId and activeProject are available
// Create program as soon as templateId and activeProduct are available
useEffect(() => {
if (!templateId || !activeProject?.id) return;
if (!templateId || !activeProduct?.id) return;
// Only trigger if not already loading or succeeded
if (
!createProgram.isPending &&
Expand All @@ -43,11 +43,11 @@ export default function NewProgramPage() {
createProgram.mutate({
name: templateName ?? "Untitled Program",
description: "",
projectId: activeProject.id,
productId: activeProduct.id,
templateId,
});
}
}, [templateId, activeProject, createProgram]);
}, [templateId, activeProduct, createProgram]);

// Minimal loading spinner
return (
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/app/(authenticated)/onboarding/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default async function OnboardingLayout({
const organizations = await auth.api.listOrganizations({
headers: await headers(),
});
const hasProjects = organizations.length > 0;
if (hasProjects) {
const hasProducts = organizations.length > 0;
if (hasProducts) {
redirect("/programs");
}

Expand Down
28 changes: 14 additions & 14 deletions apps/admin/src/app/(authenticated)/onboarding/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ export default function OnboardingPage() {
const userEmail = session?.user?.email;
const [currentStep, setCurrentStep] = useState(1);

const createProject = api.project.createWithOnboarding.useMutation({
const createProduct = api.product.createWithOnboarding.useMutation({
onSuccess: () => {
toast.success("Project created successfully!");
toast.success("Product created successfully!");
router.push("/programs");
},
onError: (error) => {
toast.error(error.message || "Failed to create project");
toast.error(error.message || "Failed to create product");
},
});

const form = useOnboardingForm({
defaultValues: {
projectName: "",
projectUrl: "",
productName: "",
productUrl: "",
appType: "saas",
paymentProvider: "stripe",
otherPaymentProvider: "",
Expand All @@ -71,13 +71,13 @@ export default function OnboardingPage() {
},
onSubmit: async ({ value }) => {
// Transform URL if needed
let url = value.projectUrl;
let url = value.productUrl;
if (!url.match(/^https?:\/\//)) {
url = `https://${url}`;
}

createProject.mutate({
name: value.projectName,
createProduct.mutate({
name: value.productName,
url,
appType: value.appType,
paymentProvider: value.paymentProvider,
Expand Down Expand Up @@ -136,7 +136,7 @@ export default function OnboardingPage() {
<div className="min-h-screen flex flex-col bg-background">
{/* Header */}
<header className="border-b py-4 px-6 flex justify-between items-center">
<h1 className="text-xl font-semibold">Setup your project</h1>
<h1 className="text-xl font-semibold">Setup your product</h1>
<div className="flex items-center gap-4">
<span className="text-sm text-muted-foreground">{userEmail}</span>
<Button variant="outline" size="sm" onClick={handleLogout}>
Expand Down Expand Up @@ -186,14 +186,14 @@ export default function OnboardingPage() {
<ProductInfoStep
form={form}
fields={{
projectName: "projectName",
projectUrl: "projectUrl",
productName: "productName",
productUrl: "productUrl",
}}
onNext={handleNext}
onPrevious={handlePrevious}
isFirstStep={true}
isLastStep={false}
isSubmitting={createProject.isPending}
isSubmitting={createProduct.isPending}
submitButtonRef={submitButtonRef}
/>
)}
Expand All @@ -205,7 +205,7 @@ export default function OnboardingPage() {
onPrevious={handlePrevious}
isFirstStep={false}
isLastStep={false}
isSubmitting={createProject.isPending}
isSubmitting={createProduct.isPending}
submitButtonRef={submitButtonRef}
/>
)}
Expand All @@ -220,7 +220,7 @@ export default function OnboardingPage() {
onPrevious={handlePrevious}
isFirstStep={false}
isLastStep={true}
isSubmitting={createProject.isPending}
isSubmitting={createProduct.isPending}
submitButtonRef={submitButtonRef}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/app/(authenticated)/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SidebarItems = [
{
group: "Team",
items: [
{ label: "Project", href: "/settings/project", icon: IconBuilding },
{ label: "Product", href: "/settings/product", icon: IconBuilding },
{ label: "Members", href: "/settings/members", icon: IconUsers },
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function UsersTable({
if (!memberCounts) return "";

if (memberCounts.total === 1) {
return "Cannot remove the last member of the project.";
return "Cannot remove the last member of the product.";
}

if (user.role === "owner" && memberCounts.owners === 1) {
Expand Down
Loading