Add starter staff app
This commit is contained in:
parent
29550317f7
commit
384ec365e8
16 changed files with 177 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
# Payments
|
||||
|
||||
Code that runs on `payments.ente.io`. It brokers between our services and
|
||||
Stripe's API for payments.
|
||||
|
||||
|
|
3
web/apps/staff/.eslintrc.cjs
Normal file
3
web/apps/staff/.eslintrc.cjs
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
extends: ["@/build-config/eslintrc-vite"],
|
||||
};
|
3
web/apps/staff/README.md
Normal file
3
web/apps/staff/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
## Staff dashboard
|
||||
|
||||
Web app for staff members to help with support etc.
|
12
web/apps/staff/index.html
Normal file
12
web/apps/staff/index.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>Staff | ente.io</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
22
web/apps/staff/package.json
Normal file
22
web/apps/staff/package.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "staff",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc && vite build",
|
||||
"dev": "vite",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18",
|
||||
"react-dom": "^18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@/build-config": "*",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"@vitejs/plugin-react": "^4.2",
|
||||
"vite": "^5.2"
|
||||
}
|
||||
}
|
11
web/apps/staff/src/App.tsx
Normal file
11
web/apps/staff/src/App.tsx
Normal file
|
@ -0,0 +1,11 @@
|
|||
import React from "react";
|
||||
import S from "./utils/strings";
|
||||
|
||||
export const App: React.FC = () => {
|
||||
return (
|
||||
<div>
|
||||
<h1>{S.hello}</h1>
|
||||
<a href="https://help.ente.io">help.ente.io</a>
|
||||
</div>
|
||||
);
|
||||
};
|
5
web/apps/staff/src/components/Container.tsx
Normal file
5
web/apps/staff/src/components/Container.tsx
Normal file
|
@ -0,0 +1,5 @@
|
|||
import React from "react";
|
||||
|
||||
export const Container: React.FC<React.PropsWithChildren> = ({ children }) => (
|
||||
<div className="container">{children}</div>
|
||||
);
|
13
web/apps/staff/src/main.tsx
Normal file
13
web/apps/staff/src/main.tsx
Normal file
|
@ -0,0 +1,13 @@
|
|||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { App } from "./App";
|
||||
import "./styles/globals.css";
|
||||
|
||||
const root = document.getElementById("root");
|
||||
if (!root) throw new Error("Could not load root element to render onto");
|
||||
|
||||
ReactDOM.createRoot(root).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
);
|
17
web/apps/staff/src/services/support-service.ts
Normal file
17
web/apps/staff/src/services/support-service.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
const apiOrigin = import.meta.env.VITE_ENTE_ENDPOINT ?? "https://api.ente.io";
|
||||
|
||||
/** Fetch details of the user associated with the given {@link authToken}. */
|
||||
export const getUserDetails = async (authToken: string) => {
|
||||
const url = `${apiOrigin}/users/details/v2`;
|
||||
const res = await fetch(url, {
|
||||
headers: {
|
||||
"X-Auth-Token": authToken,
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to fetch ${url}: HTTP ${res.status}`);
|
||||
const json: unknown = await res.json();
|
||||
if (json && typeof json === "object") {
|
||||
return json;
|
||||
}
|
||||
throw new Error(`Unexpected response for ${url}: ${JSON.stringify(json)}`);
|
||||
};
|
38
web/apps/staff/src/styles/globals.css
Normal file
38
web/apps/staff/src/styles/globals.css
Normal file
|
@ -0,0 +1,38 @@
|
|||
:root {
|
||||
color-scheme: light dark;
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: system-ui, sans-serif;
|
||||
|
||||
margin: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
min-height: 100svh;
|
||||
}
|
||||
|
||||
a {
|
||||
color: green;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: darkgreen;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
}
|
||||
|
||||
a {
|
||||
color: lightgreen;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: chartreuse;
|
||||
}
|
||||
}
|
13
web/apps/staff/src/utils/strings.ts
Normal file
13
web/apps/staff/src/utils/strings.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* 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 = {
|
||||
hello: "Hello Ente!",
|
||||
error_generic: "Oops, something went wrong.",
|
||||
};
|
||||
|
||||
export default S;
|
18
web/apps/staff/src/vite-env.d.ts
vendored
Normal file
18
web/apps/staff/src/vite-env.d.ts
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Type shims provided by vite, e.g. for asset imports
|
||||
https://vitejs.dev/guide/features.html#client-types */
|
||||
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
/** Types for the vite injected environment variables */
|
||||
interface ImportMetaEnv {
|
||||
/**
|
||||
* Override the origin (scheme://host:port) of Ente's API to connect to.
|
||||
*
|
||||
* This is useful when testing or connecting to alternative installations.
|
||||
*/
|
||||
readonly VITE_ENTE_ENDPOINT: string | undefined;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
env: ImportMetaEnv;
|
||||
}
|
5
web/apps/staff/tsconfig.json
Normal file
5
web/apps/staff/tsconfig.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"extends": "@/build-config/tsconfig-vite.json",
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
4
web/apps/staff/tsconfig.node.json
Normal file
4
web/apps/staff/tsconfig.node.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"extends": "@/build-config/tsconfig-vite.node.json",
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
7
web/apps/staff/vite.config.ts
Normal file
7
web/apps/staff/vite.config.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
});
|
|
@ -13,6 +13,7 @@
|
|||
"build:cast": "yarn workspace cast next build",
|
||||
"build:payments": "yarn workspace payments build",
|
||||
"build:photos": "yarn workspace photos next build",
|
||||
"build:staff": "yarn workspace staff build",
|
||||
"deploy:accounts": "open 'https://github.com/ente-io/ente/compare/deploy/accounts...main?quick_pull=1&title=[web]+Deploy+accounts&body=Deploy+accounts.ente.io'",
|
||||
"deploy:auth": "open 'https://github.com/ente-io/ente/compare/deploy/auth...main?quick_pull=1&title=[web]+Deploy+auth&body=Deploy+auth.ente.io'",
|
||||
"deploy:cast": "open 'https://github.com/ente-io/ente/compare/deploy/cast...main?quick_pull=1&title=[web]+Deploy+cast&body=Deploy+cast.ente.io'",
|
||||
|
@ -25,6 +26,7 @@
|
|||
"dev:cast": "yarn workspace cast next dev -p 3001",
|
||||
"dev:payments": "yarn workspace payments dev",
|
||||
"dev:photos": "yarn workspace photos next dev",
|
||||
"dev:staff": "yarn workspace staff dev",
|
||||
"lint": "yarn prettier --check . && yarn workspaces run eslint --report-unused-disable-directives",
|
||||
"lint-fix": "yarn prettier --write . && yarn workspaces run eslint --fix .",
|
||||
"preview": "yarn preview:photos",
|
||||
|
@ -32,7 +34,8 @@
|
|||
"preview:auth": "yarn build:auth && python3 -m http.server -d apps/auth/out 3000",
|
||||
"preview:cast": "yarn build:cast && python3 -m http.server -d apps/accounts/out 3001",
|
||||
"preview:payments": "yarn workspace payments preview",
|
||||
"preview:photos": "yarn build:photos && python3 -m http.server -d apps/photos/out 3000"
|
||||
"preview:photos": "yarn build:photos && python3 -m http.server -d apps/photos/out 3000",
|
||||
"preview:staff": "yarn workspace staff preview"
|
||||
},
|
||||
"resolutions": {
|
||||
"libsodium": "0.7.9"
|
||||
|
|
Loading…
Add table
Reference in a new issue