-
Notifications
You must be signed in to change notification settings - Fork 1
Davidgu/email sender and domain table #85
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
Open
shaply
wants to merge
8
commits into
main
Choose a base branch
from
davidgu/EmailSenderAndDomainTable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
07f8894
dashboard for pulling
shaply 35fd297
Aakash - Fix user login bug, add read only user mode (#84)
aakashg00 3d4f424
Available user types filtered based on user role (#62)
shaply 0df6405
Why was there a package-lock.json
shaply 246a3b8
Prettier
shaply 3cb391f
Prettier
shaply 05d523a
Update src/app/(dashboard)/projects/[projectId]/services/email/config…
shaply 64a7c60
Merge branch 'main' into davidgu/EmailSenderAndDomainTable
llam36 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -18,4 +18,4 @@ | |
| "hooks": "@/hooks" | ||
| }, | ||
| "iconLibrary": "lucide" | ||
| } | ||
| } | ||
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 |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| import type { NextConfig } from "next"; | ||
|
|
||
| const nextConfig: NextConfig = { | ||
| }; | ||
| const nextConfig: NextConfig = {}; | ||
|
|
||
| export default nextConfig; |
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
155 changes: 155 additions & 0 deletions
155
src/app/(dashboard)/projects/[projectId]/services/email/configurations/page.tsx
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,155 @@ | ||
| "use client"; | ||
|
|
||
| import { EmailDomainTable } from "@/components/emailDomainTable/emailDomainTable"; | ||
| import { EmailSenderTable } from "@/components/emailSenderTable/emailSenderTable"; | ||
| import { | ||
| Breadcrumb, | ||
| BreadcrumbItem, | ||
| BreadcrumbLink, | ||
| BreadcrumbList, | ||
| BreadcrumbPage, | ||
| BreadcrumbSeparator, | ||
| } from "@/components/ui/breadcrumb"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; | ||
| import { Separator } from "@/components/ui/separator"; | ||
| import { getProjectById } from "@/lib/project"; | ||
| import { getEmailConfig } from "@/lib/settings"; | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import { ProjectResponse } from "juno-sdk/build/main/internal/index"; | ||
| import { Mail, Settings } from "lucide-react"; | ||
| import Link from "next/link"; | ||
| import { useParams } from "next/navigation"; | ||
| import { useEffect, useState } from "react"; | ||
| import { toast } from "sonner"; | ||
|
|
||
| const EmailConfigurationsPage = () => { | ||
| const { projectId } = useParams<{ projectId: string }>(); | ||
|
|
||
| const [hasEmailConfig, setHasEmailConfig] = useState(null); | ||
| const [emailConfigLoading, setEmailConfigLoading] = useState(true); | ||
|
|
||
| const { | ||
| isLoading, | ||
| isError, | ||
| data: project, | ||
| error, | ||
| } = useQuery<ProjectResponse>({ | ||
| queryKey: ["project", projectId], | ||
| queryFn: async () => { | ||
| const result = await getProjectById(Number(projectId)); | ||
| if (!result.success) { | ||
| throw new Error(result.error); | ||
| } | ||
| return result.project; | ||
| }, | ||
| }); | ||
|
|
||
| if (isError) { | ||
| toast.error("Error", { | ||
| description: `Failed to fetch project: ${JSON.stringify(error)}`, | ||
| }); | ||
| } | ||
|
|
||
| useEffect(() => { | ||
| const loadEmailConfig = async () => { | ||
| try { | ||
| const configRes = await getEmailConfig(String(projectId)); | ||
| if (configRes) { | ||
| setHasEmailConfig(configRes); | ||
| } | ||
| } catch (e) { | ||
| console.error("Error loading email config:", e); | ||
| toast.error("Error loading email config", { | ||
| description: "Please try again later", | ||
| }); | ||
| } finally { | ||
| setEmailConfigLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| loadEmailConfig(); | ||
| }, [projectId]); | ||
|
|
||
| const breadcrumb = ( | ||
| <Breadcrumb className="mb-4"> | ||
| <BreadcrumbList> | ||
| <BreadcrumbItem> | ||
| <BreadcrumbLink href="/projects">Projects</BreadcrumbLink> | ||
| </BreadcrumbItem> | ||
| <BreadcrumbSeparator /> | ||
| <BreadcrumbItem> | ||
| <BreadcrumbLink href={`/projects/${projectId}`}> | ||
| {isLoading ? "****" : (project?.name ?? "Unknown")} | ||
| </BreadcrumbLink> | ||
| </BreadcrumbItem> | ||
| <BreadcrumbSeparator /> | ||
| <BreadcrumbItem> | ||
| <BreadcrumbLink href={`/projects/${projectId}/services/email`}> | ||
| </BreadcrumbLink> | ||
| </BreadcrumbItem> | ||
| <BreadcrumbSeparator /> | ||
| <BreadcrumbItem> | ||
| <BreadcrumbPage>Configurations</BreadcrumbPage> | ||
| </BreadcrumbItem> | ||
| </BreadcrumbList> | ||
| </Breadcrumb> | ||
| ); | ||
|
|
||
| if (emailConfigLoading) { | ||
| return ( | ||
| <div className="flex flex-col"> | ||
| {breadcrumb} | ||
| <Separator className="mb-8" /> | ||
| <h1 className="mb-4 text-lg font-bold">Email Configurations</h1> | ||
| <div className="space-y-4"> | ||
| <div className="h-64 animate-pulse rounded-md bg-muted" /> | ||
| <div className="h-64 animate-pulse rounded-md bg-muted" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (!hasEmailConfig) { | ||
| return ( | ||
| <div className="flex flex-col"> | ||
| {breadcrumb} | ||
| <Separator className="mb-8" /> | ||
| <h1 className="mb-4 text-lg font-bold">Email Configurations</h1> | ||
| <Card className="max-w-[35%]"> | ||
| <CardHeader> | ||
| <div className="flex items-center gap-3"> | ||
| <Mail className="h-5 w-5 text-muted-foreground" /> | ||
| <CardTitle>No Email Configuration</CardTitle> | ||
| </div> | ||
| </CardHeader> | ||
| <CardContent> | ||
| <p className="text-sm text-muted-foreground mb-4"> | ||
| Configure your email service first to manage senders and domains. | ||
| </p> | ||
| <Button asChild> | ||
| <Link href={`/projects/${projectId}/settings`}> | ||
| <Settings className="mr-2 h-4 w-4" /> | ||
| Go to Settings | ||
| </Link> | ||
| </Button> | ||
| </CardContent> | ||
| </Card> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="flex flex-col"> | ||
| {breadcrumb} | ||
| <Separator className="mb-8" /> | ||
| <div className="flex flex-col gap-8"> | ||
| <EmailSenderTable projectId={projectId} /> | ||
| <EmailDomainTable projectId={projectId} /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default EmailConfigurationsPage; | ||
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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import { redirect } from "next/navigation"; | ||
|
|
||
| export default function Home() { | ||
| redirect("/admin"); | ||
| // middleware handles redirect to correct route | ||
| return null; | ||
| } |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.