Skip to content

Commit

Permalink
New Working Package
Browse files Browse the repository at this point in the history
  • Loading branch information
Alder Whiteford authored and Alder Whiteford committed May 7, 2024
1 parent 42e9b70 commit 212558a
Show file tree
Hide file tree
Showing 47 changed files with 2,756 additions and 7,418 deletions.
4 changes: 2 additions & 2 deletions frontend/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "echo \"Woah there, we have no frontend tests as of right now. Let's just say we're passing.\" && exit 0"
},
"dependencies": {
"@generatesac/lib": "^1.0.41",
"@generatesac/lib": "^0.0.1",
"@reduxjs/toolkit": "^2.2.3",
"next": "14.2.3",
"react": "^18",
Expand All @@ -32,6 +32,6 @@
"postcss": "^8",
"prettier": "^3.2.4",
"tailwindcss": "^3.4.1",
"typescript": "^5"
"typescript": "^5.4.5"
}
}
25 changes: 19 additions & 6 deletions frontend/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -11,16 +15,25 @@
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
"@/*": [
"./*"
]
},
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
5,288 changes: 60 additions & 5,228 deletions frontend/dashboard/yarn.lock

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions frontend/lib/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
};
3 changes: 0 additions & 3 deletions frontend/lib/.eslintrc.json

This file was deleted.

26 changes: 24 additions & 2 deletions frontend/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
node_modules/
dist
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 4 additions & 4 deletions frontend/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ This repository holds the common types, apis, and components for frontend librar

To install the page, navigate to the target repo and initiate the following command:

- `yarn add @generatesac/lib`
- `yarn add @generatesac/blocks`

## Development / Testing

When contributing to the package, you will likely want to test your code locally before pushing to remote. To link it with real-time updates, following the steps below:

1. Navigate to `/frontend/lib` and run `yarn link`
2. Mavigate to the target repo, ppen a second terminal and run `yarn link "@generatesac/lib"`
2. Mavigate to the target repo, ppen a second terminal and run `yarn link "@generatesac/blocks"`
3. Navigate back to `/frontend/lib` and run `yarn watch`.

When you are ready to finish local development:

1. Exit out of "watch mode" using `cmd + C` / `ctrl + C`
1. Exit out of "watch mode" using `ctrl + C`
1. Navigate to `/frontend/lib` and run `yarn unlink`
1. Navigate to the target repo and run `yarn link "@generatesac/lib"`
1. Navigate to the target repo and run `yarn link "@generatesac/blocks"`

## Contributing

Expand Down
106 changes: 57 additions & 49 deletions frontend/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,59 @@
{
"name": "@generatesac/lib",
"version": "1.0.53",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"description": "This repository holds the common types, apis, and components for frontend library used by the Student Activity Calendar.",
"repository": {
"url": "https://github.com/GenerateNU/sac"
},
"license": "ISC",
"scripts": {
"test": "echo \"Woah there, we have no frontend tests as of right now. Let's just say we're passing.\" && exit 0",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
"format": "prettier --write .",
"clean": "rimraf dist",
"build": "yarn clean && tsc",
"watch": "tsc --watch"
},
"dependencies": {
"@blocknote/core": "^0.12.4",
"@blocknote/react": "^0.12.4",
"@reduxjs/toolkit": "^2.2.3",
"@tiptap/pm": "^2.3.1",
"eslint": "^9.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.1.0",
"react-redux": "^9.1.2",
"rollup-plugin-typescript2": "^0.36.0",
"zod": "^3.23.4"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/react": "^18",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.4",
"rimraf": "^5.0.5",
"tslib": "^2.6.2",
"typescript": "^5.4.5"
},
"peerDependencies": {
"react": "^18.3.1"
},
"publishConfig": {
"@generatesac:registry": "https://npm.pkg.github.com"
}
"name": "@generatesac/lib",
"version": "0.0.1",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"description": "This repository holds the common types, apis, and components for frontend library used by the Student Activity Calendar.",
"repository": {
"url": "https://github.com/GenerateNU/sac"
},
"license": "ISC",
"scripts": {
"dev": "vite",
"format": "prettier --write .",
"build": "tsc && vite build",
"watch": "yarn build --watch",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@blocknote/core": "^0.12.4",
"@blocknote/react": "^0.12.4",
"@reduxjs/toolkit": "^2.2.3",
"@tiptap/pm": "^2.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.2.1",
"react-redux": "^9.1.2",
"zod": "^3.23.6"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.12.10",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"glob": "^10.3.12",
"prettier": "^3.2.5",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vite-plugin-dts": "^3.9.1",
"vite-plugin-lib-inject-css": "^2.0.1"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"publishConfig": {
"@generatesac:registry": "https://npm.pkg.github.com"
}
}
128 changes: 64 additions & 64 deletions frontend/lib/src/api/authApi.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
import { LoginRequestBody, RefreshTokenRequestBody } from '../types/auth';
import { User, userSchema } from '../types/user';
import { LoginRequestBody, RefreshTokenRequestBody } from "../types/auth";
import { User, userSchema } from "../types/user";
import {
EmailRequestBody,
VerifyEmailRequestBody,
VerifyPasswordResetTokenRequestBody
} from '../types/verification';
import { baseApi } from './base';
EmailRequestBody,
VerifyEmailRequestBody,
VerifyPasswordResetTokenRequestBody,
} from "../types/verification";
import { baseApi } from "./base";

const AUTH_API_BASE_URL = '/auth';
const AUTH_API_BASE_URL = "/auth";

export const authApi = baseApi.injectEndpoints({
endpoints: (builder) => ({
login: builder.mutation<User, LoginRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/login`,
method: 'POST',
body
}),
transformResponse: (response: User) => {
return userSchema.parse(response);
}
}),
logout: builder.mutation<void, void>({
query: () => ({
url: `${AUTH_API_BASE_URL}/logout`,
method: 'POST'
})
}),
refresh: builder.mutation<void, RefreshTokenRequestBody>({
query: (body) => ({
url: 'refresh',
method: 'POST',
body
})
}),
forgotPassword: builder.mutation<void, EmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/forgot-password`,
method: 'POST',
body
})
}),
verifyPasswordResetToken: builder.mutation<
void,
VerifyPasswordResetTokenRequestBody
>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/verify-reset`,
method: 'POST',
body
})
}),
sendCode: builder.mutation<void, EmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/send-code`,
method: 'POST',
body
})
}),
verifyEmail: builder.mutation<void, VerifyEmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/verify-email`,
method: 'POST',
body
})
})
})
endpoints: (builder) => ({
login: builder.mutation<User, LoginRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/login`,
method: "POST",
body,
}),
transformResponse: (response: User) => {
return userSchema.parse(response);
},
}),
logout: builder.mutation<void, void>({
query: () => ({
url: `${AUTH_API_BASE_URL}/logout`,
method: "POST",
}),
}),
refresh: builder.mutation<void, RefreshTokenRequestBody>({
query: (body) => ({
url: "refresh",
method: "POST",
body,
}),
}),
forgotPassword: builder.mutation<void, EmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/forgot-password`,
method: "POST",
body,
}),
}),
verifyPasswordResetToken: builder.mutation<
void,
VerifyPasswordResetTokenRequestBody
>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/verify-reset`,
method: "POST",
body,
}),
}),
sendCode: builder.mutation<void, EmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/send-code`,
method: "POST",
body,
}),
}),
verifyEmail: builder.mutation<void, VerifyEmailRequestBody>({
query: (body) => ({
url: `${AUTH_API_BASE_URL}/verify-email`,
method: "POST",
body,
}),
}),
}),
});
Loading

0 comments on commit 212558a

Please sign in to comment.