فهرست منبع

:tida: create material-ui@react project

Jeremy Zheng 4 سال پیش
والد
کامیت
70bdeeadd3
50فایلهای تغییر یافته به همراه1194 افزوده شده و 0 حذف شده
  1. 13 0
      material-ui/.gitignore
  2. 13 0
      material-ui/README.md
  3. 77 0
      material-ui/package.json
  4. BIN
      material-ui/public/favicon.ico
  5. 43 0
      material-ui/public/index.html
  6. BIN
      material-ui/public/logo192.png
  7. BIN
      material-ui/public/logo512.png
  8. 25 0
      material-ui/public/manifest.json
  9. 3 0
      material-ui/public/robots.txt
  10. 10 0
      material-ui/src/404.tsx
  11. 22 0
      material-ui/src/components/form.tsx
  12. 5 0
      material-ui/src/hooks.ts
  13. 4 0
      material-ui/src/index.css
  14. 51 0
      material-ui/src/index.tsx
  15. 65 0
      material-ui/src/layouts/Copyright.tsx
  16. 40 0
      material-ui/src/layouts/application/index.tsx
  17. 5 0
      material-ui/src/layouts/dashboard/index.tsx
  18. 28 0
      material-ui/src/locales/en-US.ts
  19. 30 0
      material-ui/src/locales/index.ts
  20. 5 0
      material-ui/src/locales/zh-Hans.ts
  21. 5 0
      material-ui/src/locales/zh-Hant.ts
  22. 2 0
      material-ui/src/logo.svg
  23. 32 0
      material-ui/src/plugins/demo/index.tsx
  24. 6 0
      material-ui/src/plugins/demo/posts/edit.tsx
  25. 6 0
      material-ui/src/plugins/demo/posts/index.tsx
  26. 6 0
      material-ui/src/plugins/demo/posts/new.tsx
  27. 6 0
      material-ui/src/plugins/demo/topics/edit.tsx
  28. 6 0
      material-ui/src/plugins/demo/topics/index.tsx
  29. 6 0
      material-ui/src/plugins/demo/topics/new.tsx
  30. 16 0
      material-ui/src/plugins/index.tsx
  31. 25 0
      material-ui/src/plugins/nut/home.tsx
  32. 36 0
      material-ui/src/plugins/nut/index.tsx
  33. 130 0
      material-ui/src/plugins/nut/install.tsx
  34. 103 0
      material-ui/src/plugins/nut/users/NonSignInLayout.tsx
  35. 33 0
      material-ui/src/plugins/nut/users/confirm.tsx
  36. 33 0
      material-ui/src/plugins/nut/users/forgot-password.tsx
  37. 6 0
      material-ui/src/plugins/nut/users/logs.tsx
  38. 6 0
      material-ui/src/plugins/nut/users/reset-password.tsx
  39. 43 0
      material-ui/src/plugins/nut/users/sign-in.tsx
  40. 70 0
      material-ui/src/plugins/nut/users/sign-up.tsx
  41. 33 0
      material-ui/src/plugins/nut/users/unlock.tsx
  42. 6 0
      material-ui/src/plugins/nut/users/update-profile.tsx
  43. 1 0
      material-ui/src/react-app-env.d.ts
  44. 40 0
      material-ui/src/reducers/current-user.ts
  45. 35 0
      material-ui/src/reducers/site-info.ts
  46. 15 0
      material-ui/src/reportWebVitals.ts
  47. 1 0
      material-ui/src/request.ts
  48. 5 0
      material-ui/src/setupTests.ts
  49. 17 0
      material-ui/src/store.ts
  50. 26 0
      material-ui/tsconfig.json

+ 13 - 0
material-ui/.gitignore

@@ -0,0 +1,13 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules/
+/yarn.lock
+
+# testing
+
+# production
+/build/
+
+# misc
+/.env.*.local

+ 13 - 0
material-ui/README.md

@@ -0,0 +1,13 @@
+# Dashboard
+
+## Install dependencies
+
+```bash
+yarn install
+```
+
+### `yarn start`
+
+Runs the app in the development mode. Open [http://localhost:3000/my/](http://localhost:3000/my/) to view it in the browser.
+
+The page will reload if you make edits. You will also see any lint errors in the console.

+ 77 - 0
material-ui/package.json

@@ -0,0 +1,77 @@
+{
+    "name": "iapt",
+    "version": "0.1.0",
+    "private": true,
+    "homepage": "/my/",
+    "dependencies": {
+        "@emotion/react": "^11.8.2",
+        "@emotion/styled": "^11.8.1",
+        "@fontsource/roboto": "^4.5.3",
+        "@loadable/component": "^5.15.2",
+        "@mui/icons-material": "^5.5.0",
+        "@mui/material": "^5.5.0",
+        "@reduxjs/toolkit": "^1.8.0",
+        "@testing-library/jest-dom": "^5.14.1",
+        "@testing-library/react": "^12.0.0",
+        "@testing-library/user-event": "^13.2.1",
+        "@types/jest": "^27.0.1",
+        "@types/loadable__component": "^5.13.4",
+        "@types/node": "^16.7.13",
+        "@types/react": "^17.0.20",
+        "@types/react-dom": "^17.0.9",
+        "@types/react-redux": "^7.1.23",
+        "dinero.js": "^2.0.0-alpha.8",
+        "emoji-mart": "^3.0.1",
+        "google-map-react": "^2.1.10",
+        "js-cookie": "^3.0.1",
+        "jwt-decode": "^3.1.2",
+        "material-design-icons": "^3.0.1",
+        "moment": "^2.29.1",
+        "moment-timezone": "^0.5.34",
+        "qrcode.react": "^2.0.0",
+        "react": "^17.0.2",
+        "react-color": "^2.19.3",
+        "react-copy-to-clipboard": "^5.0.4",
+        "react-dom": "^17.0.2",
+        "react-dropzone": "^12.0.4",
+        "react-helmet-async": "^1.2.3",
+        "react-highlight-words": "^0.17.0",
+        "react-hook-form": "^7.27.1",
+        "react-intl": "^5.24.6",
+        "react-json-view": "^1.21.3",
+        "react-markdown": "^8.0.0",
+        "react-quill": "^2.0.0-beta.4",
+        "react-redux": "^7.2.6",
+        "react-router-dom": "6",
+        "react-scripts": "5.0.0",
+        "react-sparklines": "^1.7.0",
+        "react-syntax-highlighter": "^15.4.5",
+        "typescript": "^4.4.2",
+        "video.js": "^7.17.0",
+        "web-vitals": "^2.1.0"
+    },
+    "scripts": {
+        "start": "react-scripts start",
+        "build": "react-scripts build",
+        "test": "react-scripts test",
+        "eject": "react-scripts eject"
+    },
+    "eslintConfig": {
+        "extends": [
+            "react-app",
+            "react-app/jest"
+        ]
+    },
+    "browserslist": {
+        "production": [
+            ">0.2%",
+            "not dead",
+            "not op_mini all"
+        ],
+        "development": [
+            "last 1 chrome version",
+            "last 1 firefox version",
+            "last 1 safari version"
+        ]
+    }
+}

BIN
material-ui/public/favicon.ico


+ 43 - 0
material-ui/public/index.html

@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
+    <meta name="theme-color" content="#000000" />
+    <meta
+      name="description"
+      content="Web site created using create-react-app"
+    />
+    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
+    <!--
+      manifest.json provides metadata used when your web app is installed on a
+      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
+    -->
+    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
+    <!--
+      Notice the use of %PUBLIC_URL% in the tags above.
+      It will be replaced with the URL of the `public` folder during the build.
+      Only files inside the `public` folder can be referenced from the HTML.
+
+      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
+      work correctly both with client-side routing and a non-root public URL.
+      Learn how to configure a non-root public URL by running `npm run build`.
+    -->
+    <title>React App</title>
+  </head>
+  <body>
+    <noscript>You need to enable JavaScript to run this app.</noscript>
+    <div id="root"></div>
+    <!--
+      This HTML file is a template.
+      If you open it directly in the browser, you will see an empty page.
+
+      You can add webfonts, meta tags, or analytics to this file.
+      The build step will place the bundled scripts into the <body> tag.
+
+      To begin the development, run `npm start` or `yarn start`.
+      To create a production bundle, use `npm run build` or `yarn build`.
+    -->
+  </body>
+</html>

BIN
material-ui/public/logo192.png


BIN
material-ui/public/logo512.png


+ 25 - 0
material-ui/public/manifest.json

@@ -0,0 +1,25 @@
+{
+  "short_name": "React App",
+  "name": "Create React App Sample",
+  "icons": [
+    {
+      "src": "favicon.ico",
+      "sizes": "64x64 32x32 24x24 16x16",
+      "type": "image/x-icon"
+    },
+    {
+      "src": "logo192.png",
+      "type": "image/png",
+      "sizes": "192x192"
+    },
+    {
+      "src": "logo512.png",
+      "type": "image/png",
+      "sizes": "512x512"
+    }
+  ],
+  "start_url": ".",
+  "display": "standalone",
+  "theme_color": "#000000",
+  "background_color": "#ffffff"
+}

+ 3 - 0
material-ui/public/robots.txt

@@ -0,0 +1,3 @@
+# https://www.robotstxt.org/robotstxt.html
+User-agent: *
+Disallow:

+ 10 - 0
material-ui/src/404.tsx

@@ -0,0 +1,10 @@
+import { useIntl } from "react-intl";
+
+import Layout from "./layouts/application";
+
+function Widget() {
+  const intl = useIntl();
+  return <Layout title={intl.formatMessage({ id: "404.title" })}>aaa</Layout>;
+}
+
+export default Widget;

+ 22 - 0
material-ui/src/components/form.tsx

@@ -0,0 +1,22 @@
+export const REAL_NAME_VALIDATOR = {
+  required: true,
+  minLength: 2,
+  maxLength: 32,
+};
+export const NICK_NAME_VALIDATOR = {
+  required: true,
+  minLength: 2,
+  maxLength: 32,
+  pattern: /[\\.\w-]{6,32}/,
+};
+export const EMAIL_VALIDATOR = {
+  required: true,
+  minLength: 6,
+  maxLength: 255,
+  pattern: /^[\\.a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
+};
+export const PASSWORD_VALIDATOR = {
+  required: true,
+  minLength: 6,
+  maxLength: 64,
+};

+ 5 - 0
material-ui/src/hooks.ts

@@ -0,0 +1,5 @@
+import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
+import type { RootState, AppDispatch } from "./store";
+
+export const useAppDispatch = () => useDispatch<AppDispatch>();
+export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

+ 4 - 0
material-ui/src/index.css

@@ -0,0 +1,4 @@
+body {
+  margin: 0;
+  padding: 0;
+}

+ 51 - 0
material-ui/src/index.tsx

@@ -0,0 +1,51 @@
+import "@fontsource/roboto/300.css";
+import "@fontsource/roboto/400.css";
+import "@fontsource/roboto/500.css";
+import "@fontsource/roboto/700.css";
+import "material-design-icons/iconfont/material-icons.css";
+import "react-quill/dist/quill.snow.css";
+
+import "./index.css";
+
+import React from "react";
+import ReactDOM from "react-dom";
+import { IntlProvider } from "react-intl";
+import { BrowserRouter, Route, Routes } from "react-router-dom";
+import { Provider } from "react-redux";
+import CachedOutlinedIcon from "@mui/icons-material/CachedOutlined";
+import loadable from "@loadable/component";
+
+import plugins from "./plugins";
+import { get as getLocale, messages as getMessages } from "./locales";
+import NotFound from "./404";
+import reportWebVitals from "./reportWebVitals";
+import store from "./store";
+
+const lang = getLocale();
+const messages = getMessages(lang);
+
+ReactDOM.render(
+  <React.StrictMode>
+    <Provider store={store}>
+      <IntlProvider messages={messages} locale={lang}>
+        <BrowserRouter basename="/my/">
+          <Routes>
+            {plugins.routes.map((it) => {
+              const W = loadable(it.component, {
+                fallback: <CachedOutlinedIcon />,
+              });
+              return <Route key={it.path} path={it.path} element={<W />} />;
+            })}
+            <Route path="*" element={<NotFound />} />
+          </Routes>
+        </BrowserRouter>
+      </IntlProvider>
+    </Provider>
+  </React.StrictMode>,
+  document.getElementById("root")
+);
+
+// If you want to start measuring performance in your app, pass a function
+// to log results (for example: reportWebVitals(console.log))
+// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
+reportWebVitals();

+ 65 - 0
material-ui/src/layouts/Copyright.tsx

@@ -0,0 +1,65 @@
+import Typography from "@mui/material/Typography";
+import Link from "@mui/material/Link";
+import GitHubIcon from "@mui/icons-material/GitHub";
+import HomeIcon from "@mui/icons-material/Home";
+import { FormattedMessage } from "react-intl";
+import Stack from "@mui/material/Stack";
+import { Helmet } from "react-helmet-async";
+
+import { refresh, selectSiteInfo } from "../reducers/site-info";
+import { useAppSelector, useAppDispatch } from "../hooks";
+import { set as setLocale } from "../locales";
+
+interface IProps {
+    title: string;
+}
+
+const Widget = (props: IProps) => {
+    const site = useAppSelector(selectSiteInfo);
+    const dispatch = useAppDispatch();
+    if (site.languages.length === 0) {
+        dispatch(
+            refresh({
+                title: "demo",
+                subhead: "test",
+                copyright: `${new Date().getFullYear()}`,
+                languages: ["en-US"],
+            })
+        );
+    }
+    return (
+        <Stack spacing={2} direction="row">
+            <Helmet>
+                <title>
+                    {props.title} | {site.title}
+                </title>
+            </Helmet>
+            <Typography variant="body2" color="text.secondary" align="center">
+                ©{site.copyright}
+            </Typography>
+            <Link
+                color="inherit"
+                target="_blank"
+                href="https://github.com/iapt-platform/mint"
+            >
+                <GitHubIcon />
+            </Link>
+            <Link color="inherit" target="_blank" href="/">
+                <HomeIcon />
+            </Link>
+            {site.languages.map((it) => (
+                <Link
+                    onClick={() => {
+                        setLocale(it);
+                        window.location.reload();
+                    }}
+                    key={it}
+                >
+                    <FormattedMessage id={`languages.${it}`} />
+                </Link>
+            ))}
+        </Stack>
+    );
+};
+
+export default Widget;

+ 40 - 0
material-ui/src/layouts/application/index.tsx

@@ -0,0 +1,40 @@
+import { ReactNode } from "react";
+import CssBaseline from "@mui/material/CssBaseline";
+import Box from "@mui/material/Box";
+import Container from "@mui/material/Container";
+import { createTheme, ThemeProvider } from "@mui/material/styles";
+import { HelmetProvider } from "react-helmet-async";
+
+import Copyright from "../Copyright";
+
+const theme = createTheme();
+
+interface IProps {
+  title: string;
+  children: ReactNode;
+}
+
+function Widget({ title, children }: IProps) {
+  return (
+    <HelmetProvider>
+      <ThemeProvider theme={theme}>
+        <Container component="main" maxWidth="xs">
+          <CssBaseline />
+          <Box
+            sx={{
+              marginTop: 8,
+              display: "flex",
+              flexDirection: "column",
+              alignItems: "center",
+            }}
+          >
+            {children}
+          </Box>
+          <Copyright title={title} />
+        </Container>
+      </ThemeProvider>
+    </HelmetProvider>
+  );
+}
+
+export default Widget;

+ 5 - 0
material-ui/src/layouts/dashboard/index.tsx

@@ -0,0 +1,5 @@
+function Widget() {
+  return <div>dashboard layout</div>;
+}
+
+export default Widget;

+ 28 - 0
material-ui/src/locales/en-US.ts

@@ -0,0 +1,28 @@
+const items = {
+  "buttons.search": "Search",
+  "buttons.submit": "Submit",
+
+  "fields.email": "Email address",
+  "fields.real-name": "Real name",
+  "fields.nick-name": "Nick name",
+  "fields.password": "Password",
+  "fields.password-confirmation": "Password confirmation",
+  "fields.body": "Body",
+
+  "helpers.real-name": "Real-name's length should between 2~32",
+  "helpers.email": "Please entry a valid email address",
+  "helpers.password": "Password's length should between 6~64",
+  "helpers.password-confirmation": "Passwords not match",
+
+  "404.title": "Not found",
+
+  "nut.install.title": "Install",
+  "nut.users.sign-in.title": "Sign in",
+  "nut.users.sign-up.title": "Sign Up",
+  "nut.users.confirm.title": "Resend confirmation instructions",
+  "nut.users.unlock.title": "Resend unlock instructions",
+  "nut.users.forgot-password.title": "Forgot your password?",
+  "nut.leave-words.new.title": "Leave us a message",
+};
+
+export default items;

+ 30 - 0
material-ui/src/locales/index.ts

@@ -0,0 +1,30 @@
+import enUS from "./en-US";
+import zhHans from "./zh-Hans";
+import zhHant from "./zh-Hant";
+
+const KEY = "locale";
+
+export const get = (): string => {
+  return localStorage.getItem(KEY) || "en-US";
+};
+
+export const set = (lang: string) => {
+  localStorage.setItem(KEY, lang);
+};
+
+const languages = {
+  "languages.en-US": "English",
+  "languages.zh-Hans": "简体中文",
+  "languages.zh-Hant": "繁體中文",
+};
+
+export const messages = (lang: string): any => {
+  switch (lang) {
+    case "zh-Hans":
+      return { ...languages, ...zhHans };
+    case "zh-Hant":
+      return { ...languages, ...zhHant };
+    default:
+      return { ...languages, ...enUS };
+  }
+};

+ 5 - 0
material-ui/src/locales/zh-Hans.ts

@@ -0,0 +1,5 @@
+const items = {
+  "buttons.search": "搜索",
+};
+
+export default items;

+ 5 - 0
material-ui/src/locales/zh-Hant.ts

@@ -0,0 +1,5 @@
+const items = {
+  "buttons.search": "檢索",
+};
+
+export default items;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 2 - 0
material-ui/src/logo.svg


+ 32 - 0
material-ui/src/plugins/demo/index.tsx

@@ -0,0 +1,32 @@
+import { IPlugin } from "..";
+
+export const plugin: IPlugin = {
+    routes: [
+        {
+            path: "/demo/topics/new",
+            component: () => import("./topics/new"),
+        },
+        {
+            path: "/demo/topics/edit",
+            component: () => import("./topics/edit"),
+        },
+        {
+            path: "/demo/topics",
+            component: () => import("./topics/index"),
+        },
+        {
+            path: "/demo/posts/new",
+            component: () => import("./posts/new"),
+        },
+        {
+            path: "/demo/posts/edit",
+            component: () => import("./posts/edit"),
+        },
+        {
+            path: "/demo/posts",
+            component: () => import("./posts/index"),
+        },
+    ],
+};
+
+export default plugin;

+ 6 - 0
material-ui/src/plugins/demo/posts/edit.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo posts edit</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/posts/index.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo posts index </div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/posts/new.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo posts new</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/topics/edit.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo topics edit</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/topics/index.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo topics index</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/demo/topics/new.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+    // TODO
+    return <div>demo topics new</div>;
+}
+
+export default Widget;

+ 16 - 0
material-ui/src/plugins/index.tsx

@@ -0,0 +1,16 @@
+import nut from "./nut";
+import demo from "./demo";
+
+export interface IRoute {
+    path: string;
+    component: any;
+}
+
+export interface IPlugin {
+    routes: IRoute[];
+}
+
+const plugin: IPlugin = {
+    routes: [...demo.routes, ...nut.routes],
+};
+export default plugin;

+ 25 - 0
material-ui/src/plugins/nut/home.tsx

@@ -0,0 +1,25 @@
+import { FormattedMessage } from "react-intl";
+import { Link } from "react-router-dom";
+
+function Widget() {
+  // TODO
+  return (
+    <div>
+      home of <FormattedMessage id="languages.zh-Hant" />
+      <ol>
+        <li>
+          <Link to="/users/sign-in">Sign In</Link>
+        </li>
+        <li>
+          <Link to="/users/sign-up">Sign up</Link>
+        </li>
+        <li>
+          <Link to="/install">install</Link>
+        </li>
+        <li></li>
+      </ol>
+    </div>
+  );
+}
+
+export default Widget;

+ 36 - 0
material-ui/src/plugins/nut/index.tsx

@@ -0,0 +1,36 @@
+import { IPlugin } from "..";
+
+const plugin: IPlugin = {
+    routes: [
+        {
+            path: "/users/forgot-password",
+            component: () => import("./users/forgot-password"),
+        },
+        {
+            path: "/users/unlock",
+            component: () => import("./users/unlock"),
+        },
+        {
+            path: "/users/confirm",
+            component: () => import("./users/confirm"),
+        },
+        {
+            path: "/users/sign-in",
+            component: () => import("./users/sign-in"),
+        },
+        {
+            path: "/users/sign-up",
+            component: () => import("./users/sign-up"),
+        },
+        {
+            path: "/install",
+            component: () => import("./install"),
+        },
+        {
+            path: "/",
+            component: () => import("./home"),
+        },
+    ],
+};
+
+export default plugin;

+ 130 - 0
material-ui/src/plugins/nut/install.tsx

@@ -0,0 +1,130 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+import { useForm, Controller, SubmitHandler } from "react-hook-form";
+import { useIntl } from "react-intl";
+
+import Layout from "./users/NonSignInLayout";
+import {
+  REAL_NAME_VALIDATOR,
+  EMAIL_VALIDATOR,
+  PASSWORD_VALIDATOR,
+} from "../../components/form";
+
+interface IFormData {
+  realName: string;
+  email: string;
+  password: string;
+  passwordConfirmation: string;
+}
+
+const Widget = () => {
+  const intl = useIntl();
+  const {
+    control,
+    formState: { errors },
+    handleSubmit,
+  } = useForm<IFormData>({
+    defaultValues: {
+      realName: "",
+      email: "",
+      password: "",
+      passwordConfirmation: "",
+    },
+  });
+  const onSubmit: SubmitHandler<IFormData> = (data) => {
+    // TODO
+    console.log(data);
+  };
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.install.title" })}
+      handleSubmit={handleSubmit(onSubmit)}
+    >
+      <Grid item xs={12}>
+        <Controller
+          name="realName"
+          control={control}
+          rules={REAL_NAME_VALIDATOR}
+          render={({ field }) => (
+            <TextField
+              required
+              fullWidth
+              label={intl.formatMessage({ id: "fields.real-name" })}
+              error={errors.realName !== undefined}
+              helperText={
+                errors.realName &&
+                intl.formatMessage({ id: "helpers.real-name" })
+              }
+              {...field}
+            />
+          )}
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <Controller
+          name="email"
+          rules={EMAIL_VALIDATOR}
+          control={control}
+          render={({ field }) => (
+            <TextField
+              required
+              fullWidth
+              label={intl.formatMessage({ id: "fields.email" })}
+              type="email"
+              error={errors.email !== undefined}
+              helperText={
+                errors.email && intl.formatMessage({ id: "helpers.email" })
+              }
+              {...field}
+            />
+          )}
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <Controller
+          name="password"
+          rules={PASSWORD_VALIDATOR}
+          control={control}
+          render={({ field }) => (
+            <TextField
+              required
+              fullWidth
+              label={intl.formatMessage({ id: "fields.password" })}
+              type="password"
+              error={errors.password !== undefined}
+              helperText={
+                errors.password &&
+                intl.formatMessage({ id: "helpers.password" })
+              }
+              {...field}
+            />
+          )}
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <Controller
+          name="passwordConfirmation"
+          control={control}
+          render={({ field }) => (
+            <TextField
+              required
+              fullWidth
+              label={intl.formatMessage({ id: "fields.password-confirmation" })}
+              type="password"
+              error={errors.passwordConfirmation !== undefined}
+              helperText={
+                errors.passwordConfirmation &&
+                intl.formatMessage({ id: "helpers.password-confirmation" })
+              }
+              {...field}
+            />
+          )}
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 103 - 0
material-ui/src/plugins/nut/users/NonSignInLayout.tsx

@@ -0,0 +1,103 @@
+import { ReactNode } from "react";
+import Button from "@mui/material/Button";
+import Grid from "@mui/material/Grid";
+import Box from "@mui/material/Box";
+import Avatar from "@mui/material/Avatar";
+import Typography from "@mui/material/Typography";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+import PersonPinOutlinedIcon from "@mui/icons-material/PersonPinOutlined";
+import PersonAddAltOutlinedIcon from "@mui/icons-material/PersonAddAltOutlined";
+import ConfirmationNumberOutlinedIcon from "@mui/icons-material/ConfirmationNumberOutlined";
+import PasswordOutlinedIcon from "@mui/icons-material/PasswordOutlined";
+import ListItemIcon from "@mui/material/ListItemIcon";
+import ListItemText from "@mui/material/ListItemText";
+import List from "@mui/material/List";
+import ListItem from "@mui/material/ListItem";
+import ListItemButton from "@mui/material/ListItemButton";
+import { useNavigate } from "react-router-dom";
+import { FormattedMessage } from "react-intl";
+
+import Layout from "../../../layouts/application";
+
+const shared_links = [
+    {
+        to: "/users/sign-in",
+        label: "nut.users.sign-in.title",
+        icon: <PersonPinOutlinedIcon />,
+    },
+    {
+        to: "/users/sign-up",
+        label: "nut.users.sign-up.title",
+        icon: <PersonAddAltOutlinedIcon />,
+    },
+    {
+        to: "/users/confirm",
+        label: "nut.users.confirm.title",
+        icon: <ConfirmationNumberOutlinedIcon />,
+    },
+    {
+        to: "/users/unlock",
+        label: "nut.users.unlock.title",
+        icon: <LockOutlinedIcon />,
+    },
+    {
+        to: "/users/forgot-password",
+        label: "nut.users.forgot-password.title",
+        icon: <PasswordOutlinedIcon />,
+    },
+];
+interface IProps {
+    title: string;
+    children: ReactNode;
+    logo: ReactNode;
+    handleSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
+}
+
+function Widget({ title, logo, children, handleSubmit }: IProps) {
+    // const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
+    //   event.preventDefault();
+    //   const data = new FormData(event.currentTarget);
+    //   handleSubmit(data);
+    // };
+    const navigate = useNavigate();
+    return (
+        <Layout title={title}>
+            <Avatar sx={{ bgcolor: "secondary.main" }}>{logo}</Avatar>
+            <Typography component="h1" variant="h5">
+                {title}
+            </Typography>
+            <Box component="form" noValidate onSubmit={handleSubmit}>
+                <Grid container spacing={2}>
+                    {children}
+                    <Grid item>
+                        <Button type="submit" fullWidth variant="contained">
+                            <FormattedMessage id="buttons.submit" />
+                        </Button>
+                    </Grid>
+                    <Grid item>
+                        <List>
+                            {shared_links.map((it) => (
+                                <ListItem key={it.to} disablePadding>
+                                    <ListItemButton
+                                        onClick={() => navigate(it.to)}
+                                    >
+                                        <ListItemIcon>{it.icon}</ListItemIcon>
+                                        <ListItemText
+                                            primary={
+                                                <FormattedMessage
+                                                    id={it.label}
+                                                />
+                                            }
+                                        />
+                                    </ListItemButton>
+                                </ListItem>
+                            ))}
+                        </List>
+                    </Grid>
+                </Grid>
+            </Box>
+        </Layout>
+    );
+}
+
+export default Widget;

+ 33 - 0
material-ui/src/plugins/nut/users/confirm.tsx

@@ -0,0 +1,33 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+
+import Layout from "./NonSignInLayout";
+import { useIntl } from "react-intl";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.confirm.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 33 - 0
material-ui/src/plugins/nut/users/forgot-password.tsx

@@ -0,0 +1,33 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+
+import Layout from "./NonSignInLayout";
+import { useIntl } from "react-intl";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.forgot-password.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/nut/users/logs.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+  // TODO
+  return <div>logs</div>;
+}
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/nut/users/reset-password.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+  // TODO
+  return <div>reset password</div>;
+}
+
+export default Widget;

+ 43 - 0
material-ui/src/plugins/nut/users/sign-in.tsx

@@ -0,0 +1,43 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+
+import Layout from "./NonSignInLayout";
+import { useIntl } from "react-intl";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.sign-in.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          name="password"
+          label={intl.formatMessage({ id: "fields.password" })}
+          type="password"
+          id="password"
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 70 - 0
material-ui/src/plugins/nut/users/sign-up.tsx

@@ -0,0 +1,70 @@
+import TextField from "@mui/material/TextField";
+import FormControlLabel from "@mui/material/FormControlLabel";
+import Checkbox from "@mui/material/Checkbox";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+import { useIntl } from "react-intl";
+
+import Layout from "./NonSignInLayout";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.sign-up.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="realName"
+          label={intl.formatMessage({ id: "fields.real-name" })}
+          name="lastName"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          name="password"
+          label={intl.formatMessage({ id: "fields.password" })}
+          type="password"
+          id="password"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          name="passwordConfirmation"
+          label={intl.formatMessage({ id: "fields.password-confirmation" })}
+          type="password"
+          id="passwordConfirmation"
+        />
+      </Grid>
+      <Grid item xs={12}>
+        <FormControlLabel
+          control={<Checkbox value="allowExtraEmails" color="primary" />}
+          label="I want to receive inspiration, marketing promotions and updates via email."
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 33 - 0
material-ui/src/plugins/nut/users/unlock.tsx

@@ -0,0 +1,33 @@
+import TextField from "@mui/material/TextField";
+import Grid from "@mui/material/Grid";
+import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
+
+import Layout from "./NonSignInLayout";
+import { useIntl } from "react-intl";
+
+const Widget = () => {
+  const handleSubmit = () => {
+    // TODO
+    // console.log(data.get("email"));
+  };
+  const intl = useIntl();
+  return (
+    <Layout
+      logo={<LockOutlinedIcon />}
+      title={intl.formatMessage({ id: "nut.users.unlock.title" })}
+      handleSubmit={handleSubmit}
+    >
+      <Grid item xs={12}>
+        <TextField
+          required
+          fullWidth
+          id="email"
+          label={intl.formatMessage({ id: "fields.email" })}
+          name="email"
+        />
+      </Grid>
+    </Layout>
+  );
+};
+
+export default Widget;

+ 6 - 0
material-ui/src/plugins/nut/users/update-profile.tsx

@@ -0,0 +1,6 @@
+function Widget() {
+  // TODO
+  return <div>update profile</div>;
+}
+
+export default Widget;

+ 1 - 0
material-ui/src/react-app-env.d.ts

@@ -0,0 +1 @@
+/// <reference types="react-scripts" />

+ 40 - 0
material-ui/src/reducers/current-user.ts

@@ -0,0 +1,40 @@
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+
+import type { RootState } from "../store";
+
+interface IState {
+  id?: string;
+  roles?: string[];
+}
+
+const initialState: IState = {};
+
+export const slice = createSlice({
+  name: "current-user",
+  initialState,
+  reducers: {
+    signIn: (state, action: PayloadAction<string>) => {
+      console.log(action.payload);
+      state.id = "todo";
+      state.roles = [];
+    },
+    signOut: (state) => {
+      state = {};
+    },
+  },
+});
+
+export const { signIn, signOut } = slice.actions;
+
+const ADMINISTRATOR = "administrator";
+
+export const isSignIn = (state: RootState): boolean =>
+  state.currentUser.id !== undefined;
+export const isAdministrtor = (state: RootState): boolean =>
+  hasRole(state, ADMINISTRATOR);
+
+export const hasRole = (state: RootState, role: string): boolean =>
+  state.currentUser.roles !== undefined &&
+  state.currentUser.roles.includes(role);
+
+export default slice.reducer;

+ 35 - 0
material-ui/src/reducers/site-info.ts

@@ -0,0 +1,35 @@
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+
+import type { RootState } from "../store";
+
+interface IState {
+  title: string;
+  subhead: string;
+  copyright: string;
+  languages: string[];
+}
+
+const initialState: IState = {
+  title: "",
+  subhead: "",
+  copyright: "",
+  languages: [],
+};
+
+const slice = createSlice({
+  name: "site-info",
+  initialState,
+  reducers: {
+    refresh: (state, action: PayloadAction<IState>) => {
+      Object.assign(state, action.payload);
+    },
+  },
+});
+
+export const { refresh } = slice.actions;
+
+export const selectSiteInfo = (state: RootState): IState => {
+  return { ...state.siteInfo };
+};
+
+export default slice.reducer;

+ 15 - 0
material-ui/src/reportWebVitals.ts

@@ -0,0 +1,15 @@
+import { ReportHandler } from 'web-vitals';
+
+const reportWebVitals = (onPerfEntry?: ReportHandler) => {
+  if (onPerfEntry && onPerfEntry instanceof Function) {
+    import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
+      getCLS(onPerfEntry);
+      getFID(onPerfEntry);
+      getFCP(onPerfEntry);
+      getLCP(onPerfEntry);
+      getTTFB(onPerfEntry);
+    });
+  }
+};
+
+export default reportWebVitals;

+ 1 - 0
material-ui/src/request.ts

@@ -0,0 +1 @@
+export const graphql = () => {};

+ 5 - 0
material-ui/src/setupTests.ts

@@ -0,0 +1,5 @@
+// jest-dom adds custom jest matchers for asserting on DOM nodes.
+// allows you to do things like:
+// expect(element).toHaveTextContent(/react/i)
+// learn more: https://github.com/testing-library/jest-dom
+import '@testing-library/jest-dom';

+ 17 - 0
material-ui/src/store.ts

@@ -0,0 +1,17 @@
+import { configureStore } from "@reduxjs/toolkit";
+
+import currentUser from "./reducers/current-user";
+import siteInfo from "./reducers/site-info";
+
+const store = configureStore({
+  reducer: {
+    currentUser,
+    siteInfo,
+  },
+});
+
+export type RootState = ReturnType<typeof store.getState>;
+
+export type AppDispatch = typeof store.dispatch;
+
+export default store;

+ 26 - 0
material-ui/tsconfig.json

@@ -0,0 +1,26 @@
+{
+  "compilerOptions": {
+    "target": "es5",
+    "lib": [
+      "dom",
+      "dom.iterable",
+      "esnext"
+    ],
+    "allowJs": true,
+    "skipLibCheck": true,
+    "esModuleInterop": true,
+    "allowSyntheticDefaultImports": true,
+    "strict": true,
+    "forceConsistentCasingInFileNames": true,
+    "noFallthroughCasesInSwitch": true,
+    "module": "esnext",
+    "moduleResolution": "node",
+    "resolveJsonModule": true,
+    "isolatedModules": true,
+    "noEmit": true,
+    "jsx": "react-jsx"
+  },
+  "include": [
+    "src"
+  ]
+}

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است