Skip to content
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

chore: (2) settings/my-account - remove pages router and use app router #16793

Merged
merged 5 commits into from
Oct 4, 2024
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { _generateMetadata } from "app/_utils";
import { getFixedT } from "app/_utils";
import { revalidatePath } from "next/cache";

import { getServerSessionForAppDir } from "@calcom/feature-auth/lib/get-server-session-for-app-dir";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
Expand All @@ -16,9 +17,14 @@ const Page = async () => {
const session = await getServerSessionForAppDir();

const t = await getFixedT(session?.user.locale || "en");
const revalidatePage = async () => {
"use server";
revalidatePath("settings/my-account/general");
};

return (
<SettingsHeader title={t("general")} description={t("general_description")} borderInShellHeader={true}>
<GeneralQueryView />
<GeneralQueryView revalidatePage={revalidatePage} />
</SettingsHeader>
);
};
Expand Down
21 changes: 17 additions & 4 deletions apps/web/modules/settings/my-account/general-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ interface GeneralViewProps {
localeProp: string;
user: RouterOutputs["viewer"]["me"];
travelSchedules: RouterOutputs["viewer"]["getTravelSchedules"];
revalidatePage: GeneralQueryViewProps["revalidatePage"];
}

const GeneralQueryView = () => {
type GeneralQueryViewProps = {
revalidatePage: () => Promise<void>;
};

const GeneralQueryView = ({ revalidatePage }: GeneralQueryViewProps) => {
const { t } = useLocale();

const { data: user, isPending } = trpc.viewer.me.useQuery();
Expand All @@ -82,10 +87,17 @@ const GeneralQueryView = () => {
if (!user) {
throw new Error(t("something_went_wrong"));
}
return <GeneralView user={user} travelSchedules={travelSchedules || []} localeProp={user.locale} />;
return (
<GeneralView
user={user}
travelSchedules={travelSchedules || []}
localeProp={user.locale}
revalidatePage={revalidatePage}
/>
);
};

const GeneralView = ({ localeProp, user, travelSchedules }: GeneralViewProps) => {
const GeneralView = ({ localeProp, user, travelSchedules, revalidatePage }: GeneralViewProps) => {
const utils = trpc.useContext();
const {
t,
Expand All @@ -105,6 +117,7 @@ const GeneralView = ({ localeProp, user, travelSchedules }: GeneralViewProps) =>
if (res.locale) {
window.calNewLocale = res.locale;
}
await revalidatePage();
},
onError: () => {
showToast(t("error_updating_settings"), "error");
Expand Down Expand Up @@ -177,7 +190,7 @@ const GeneralView = ({ localeProp, user, travelSchedules }: GeneralViewProps) =>
<div>
<Form
form={formMethods}
handleSubmit={(values) => {
handleSubmit={async (values) => {
setIsUpdateBtnLoading(true);
mutation.mutate({
...values,
Expand Down
1 change: 1 addition & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const nextConfig = {
serverComponentsExternalPackages: ["next-i18next"],
optimizePackageImports: ["@calcom/ui"],
instrumentationHook: true,
serverActions: true,
},
i18n: {
...i18n,
Expand Down
23 changes: 0 additions & 23 deletions apps/web/pages/settings/my-account/appearance.tsx

This file was deleted.

31 changes: 0 additions & 31 deletions apps/web/pages/settings/my-account/calendars.tsx

This file was deleted.

36 changes: 0 additions & 36 deletions apps/web/pages/settings/my-account/conferencing.tsx

This file was deleted.

23 changes: 0 additions & 23 deletions apps/web/pages/settings/my-account/general.tsx

This file was deleted.

31 changes: 0 additions & 31 deletions apps/web/pages/settings/my-account/out-of-office/index.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions apps/web/pages/settings/my-account/profile.tsx

This file was deleted.

Loading