|
1 | | -import { config } from "@/config/environment"; |
2 | | -import { getUser } from "@/services/auth"; |
3 | | -import { Metadata } from "next"; |
4 | | -import { redirect } from "next/navigation"; |
| 1 | +import { |
| 2 | + getFeaturesSuggestedByUser, |
| 3 | + suggestFeature, |
| 4 | +} from "@/services/user-feedback"; |
| 5 | + |
| 6 | +import AwardBySupporting from "@/components/award-by-supporting"; |
5 | 7 | import FeatureRequestForm from "./feature-request-form"; |
6 | | -import Header from "@/components/header"; |
7 | 8 | import { FeatureSuggestCreate } from "@/types"; |
8 | | -import { getFeaturesSuggestedByUser, suggestFeature } from "@/services/user-feedback"; |
9 | | -import { Toaster } from "react-hot-toast"; |
10 | | -import { unstable_cache } from "next/cache"; |
11 | | -import AwardBySupporting from "@/components/award-by-supporting"; |
12 | 9 | import FoundBugQuestion from "@/components/found-bug-question"; |
| 10 | +import Header from "@/components/header"; |
| 11 | +import { Metadata } from "next"; |
| 12 | +import SuggestFeaturesHeader from "@/components/suggest-features-header"; |
| 13 | +import { Toaster } from "react-hot-toast"; |
13 | 14 | import { YourEntityRequests } from "@/components/your-entity-requests"; |
| 15 | +import { config } from "@/config/environment"; |
| 16 | +import { getUser } from "@/services/auth"; |
| 17 | +import { redirect } from "next/navigation"; |
| 18 | +import { unstable_cache } from "next/cache"; |
| 19 | +import { useTranslations } from "next-intl"; |
14 | 20 |
|
15 | 21 | export async function generateMetadata({ |
16 | | - params, |
| 22 | + params, |
17 | 23 | }: { |
18 | | - params: any; |
| 24 | + params: any; |
19 | 25 | }): Promise<Metadata> { |
20 | | - return { |
21 | | - title: `Suggest Features | ${config.brandName}`, |
22 | | - }; |
| 26 | + return { |
| 27 | + title: `Suggest Features | ${config.brandName}`, |
| 28 | + }; |
23 | 29 | } |
24 | 30 |
|
25 | | - |
26 | | - |
27 | | - |
28 | 31 | const SuggestFeatures = async () => { |
29 | | - const user = await getUser(); |
30 | | - if (!user) return redirect("/"); |
31 | | - |
32 | | - const getFeatures = unstable_cache( |
33 | | - async (user) => { |
34 | | - return getFeaturesSuggestedByUser(user); |
35 | | - }, |
36 | | - [user._id.toString()], |
37 | | - { |
38 | | - tags: ["features-suggestions"], |
39 | | - } |
40 | | -); |
| 32 | + const user = await getUser(); |
| 33 | + if (!user) return redirect("/"); |
41 | 34 |
|
| 35 | + const getFeatures = unstable_cache( |
| 36 | + async (user) => { |
| 37 | + return getFeaturesSuggestedByUser(user); |
| 38 | + }, |
| 39 | + [user._id.toString()], |
| 40 | + { |
| 41 | + tags: ["features-suggestions"], |
| 42 | + } |
| 43 | + ); |
42 | 44 |
|
43 | | - const featuresSuggested = await getFeatures(user); |
| 45 | + const featuresSuggested = await getFeatures(user); |
44 | 46 |
|
45 | | - |
46 | | - const handleSuggest = async(data: FeatureSuggestCreate, timezone: string) =>{ |
47 | | - "use server"; |
48 | | - const resp = await suggestFeature(data, timezone); |
49 | | - return resp; |
50 | | - } |
51 | | - return ( |
52 | | - <div className="flex flex-col min-h-screen bg-gray-50 dark:bg-gradient-to-br dark:from-gray-900 dark:via-gray-900 dark:to-gray-950"> |
53 | | - <Toaster position="bottom-center" /> |
54 | | - <Header title="Suggest Features" /> |
55 | | - <main className="flex-grow relative flex flex-col-reverse md:flex-row gap-5 max-w-7xl w-full mx-auto px-4 sm:px-6 lg:px-8 py-4"> |
56 | | - |
57 | | - <div className="md:max-w-3xl mx-auto w-full flex-1 flex flex-col gap-5"> |
58 | | - <FeatureRequestForm handleSuggest={handleSuggest} /> |
59 | | - <YourEntityRequests title="Features Requests" requests={featuresSuggested} type="suggestions" /> |
60 | | - </div> |
61 | | - <div className="flex flex-col gap-3 sticky md:h-80 w-full md:w-72 lg:w-96 "> |
62 | | - <AwardBySupporting/> |
| 47 | + const handleSuggest = async ( |
| 48 | + data: FeatureSuggestCreate, |
| 49 | + timezone: string |
| 50 | + ) => { |
| 51 | + "use server"; |
| 52 | + const resp = await suggestFeature(data, timezone); |
| 53 | + return resp; |
| 54 | + }; |
63 | 55 |
|
64 | | - |
65 | | - |
66 | | - </div> |
67 | | - </main> |
68 | | - </div> |
69 | | - ); |
| 56 | + return ( |
| 57 | + <div className='flex flex-col min-h-screen bg-gray-50 dark:bg-gradient-to-br dark:from-gray-900 dark:via-gray-900 dark:to-gray-950'> |
| 58 | + <SuggestFeaturesHeader /> |
| 59 | + <main className='flex-grow relative flex flex-col-reverse md:flex-row gap-5 max-w-7xl w-full mx-auto px-4 sm:px-6 lg:px-8 py-4'> |
| 60 | + <div className='md:max-w-3xl mx-auto w-full flex-1 flex flex-col gap-5'> |
| 61 | + <FeatureRequestForm handleSuggest={handleSuggest} /> |
| 62 | + <YourEntityRequests |
| 63 | + title='Features Requests' |
| 64 | + requests={featuresSuggested} |
| 65 | + type='suggestions' |
| 66 | + /> |
| 67 | + </div> |
| 68 | + <div className='flex flex-col gap-3 sticky md:h-80 w-full md:w-72 lg:w-96 '> |
| 69 | + <AwardBySupporting /> |
| 70 | + </div> |
| 71 | + </main> |
| 72 | + </div> |
| 73 | + ); |
70 | 74 | }; |
71 | 75 |
|
72 | 76 | export default SuggestFeatures; |
0 commit comments