소스 검색

Clean up strings

Manav Rathi 1 년 전
부모
커밋
c0fee7bc91
4개의 변경된 파일18개의 추가작업 그리고 15개의 파일을 삭제
  1. 2 2
      web/apps/payments/src/pages/404.tsx
  2. 2 2
      web/apps/payments/src/pages/_app.tsx
  3. 2 6
      web/apps/payments/src/pages/index.tsx
  4. 12 5
      web/apps/payments/src/utils/strings.ts

+ 2 - 2
web/apps/payments/src/pages/404.tsx

@@ -1,7 +1,7 @@
 import { Container } from "components/Container";
+import S from "utils/strings";
 import React from "react";
-import constants from "utils/strings";
 
 export default function Home() {
-    return <Container>{constants.NOT_FOUND}</Container>;
+    return <Container>{S.error_404}</Container>;
 }

+ 2 - 2
web/apps/payments/src/pages/_app.tsx

@@ -1,14 +1,14 @@
 import type { AppProps } from "next/app";
 import Head from "next/head";
 import React from "react";
-import constants from "utils/strings";
+import S from "utils/strings";
 import "../styles/globals.css";
 
 function MyApp({ Component, pageProps }: AppProps) {
     return (
         <>
             <Head>
-                <title>{constants.TITLE}</title>
+                <title>{S.title}</title>
             </Head>
             <Component {...pageProps} />
         </>

+ 2 - 6
web/apps/payments/src/pages/index.tsx

@@ -2,7 +2,7 @@ import { Container } from "components/Container";
 import { Spinner } from "components/Spinner";
 import * as React from "react";
 import { parseAndHandleRequest } from "services/billing-service";
-import constants from "utils/strings";
+import S from "utils/strings";
 
 export default function Home() {
     const [failed, setFailed] = React.useState(false);
@@ -20,9 +20,5 @@ export default function Home() {
         main();
     }, []);
 
-    return (
-        <Container>
-            {failed ? constants.SOMETHING_WENT_WRONG : <Spinner />}
-        </Container>
-    );
+    return <Container>{failed ? S.error_generic : <Spinner />}</Container>;
 }

+ 12 - 5
web/apps/payments/src/utils/strings.ts

@@ -1,7 +1,14 @@
-const englishConstants = {
-    TITLE: "Payments | ente.io",
-    SOMETHING_WENT_WRONG: "Oops, something went wrong.",
-    NOT_FOUND: "404 | This page could not be found.",
+/**
+ * User facing strings in the app
+ *
+ * By keeping them separate, we make our lives easier if/when we need to
+ * localize the corresponding pages. Right now, these are just the values in the
+ * default language, English.
+ */
+const S = {
+    title: "Payments | ente.io",
+    error_generic: "Oops, something went wrong.",
+    error_404: "404 | This page could not be found.",
 };
 
-export default englishConstants;
+export default S;