Skip to content

Commit

Permalink
Merge pull request #603 from lexicongovernance/next-streamline
Browse files Browse the repository at this point in the history
Next v2.6.0
  • Loading branch information
diegoalzate authored Jul 30, 2024
2 parents fddf2d9 + 085e804 commit 8165aad
Show file tree
Hide file tree
Showing 151 changed files with 3,156 additions and 3,809 deletions.
7 changes: 1 addition & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:@tanstack/eslint-plugin-query/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
Expand All @@ -28,11 +27,7 @@ module.exports = {
// Warn to encourage type safety, could be upgraded to 'error' for stricter enforcement
'@typescript-eslint/no-explicit-any': 'warn',

// 5. '@tanstack/query/exhaustive-deps': Ensure exhaustive dependency arrays in React hooks
// Warn to highlight potential issues, but doesn't necessarily break the build
'@tanstack/query/exhaustive-deps': 'warn',

// 6. '@typescript-eslint/no-unused-vars': Avoid unused variables, enforcing cleaner code
// 5. '@typescript-eslint/no-unused-vars': Avoid unused variables, enforcing cleaner code
// Error to ensure unused variables are caught during linting
'@typescript-eslint/no-unused-vars': [
'error',
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = {
singleQuote: true,
quoteProps: 'consistent',
printWidth: 100,
};
plugins: ['prettier-plugin-tailwindcss'],
};
60 changes: 13 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,29 @@
{
"name": "lexicon-frontend",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {
"berlin:dev": "pnpm -r --filter berlin dev",
"berlin:build": "pnpm -r --filter berlin build",
"berlin:preview": "pnpm -r --filter berlin preview",
"dev": "pnpm -r --filter berlin dev",
"build": "pnpm -r --filter berlin build",
"preview": "pnpm -r --filter berlin preview",
"format": "pnpm exec prettier --check \"packages/**/*.{ts,tsx,json,md}\"",
"format:fix": "pnpm exec prettier --write \"packages/**/*.{ts,tsx,json,md}\"",
"lint": "pnpm exec eslint ."
},
"keywords": [],
"author": "",
"license": "ISC",
"engines": {
"node": "^20"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@pcd/passport-interface": "^0.8.0",
"@pcd/pcd-types": "^0.8.0",
"@pcd/semaphore-identity-pcd": "^0.8.0",
"@pcd/semaphore-signature-pcd": "^0.9.0",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-icons": "^1.3.0",
"@tanstack/react-query": "^5.13.4",
"@tanstack/react-query-devtools": "^5.13.5",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.397.0",
"react": "^18.2.0",
"react-content-loader": "^7.0.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.49.3",
"react-hot-toast": "^2.4.1",
"react-joyride": "^2.8.2",
"react-markdown": "^9.0.1",
"react-router-dom": "^6.20.1",
"styled-components": "^6.1.1",
"zod": "^3.22.4",
"zustand": "^4.4.7"
},
"devDependencies": {
"@hookform/devtools": "^4.3.1",
"@tanstack/eslint-plugin-query": "^5.18.0",
"@types/node": "^20.12.4",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"@vitejs/plugin-react": "^4.2.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.4",
"prettier-plugin-tailwindcss": "^0.6.5",
"prettier": "^3.1.1",
"typescript": "^5.5.2",
"vite": "^5.0.0",
"vite-plugin-node-polyfills": "^0.17.0"
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"@typescript-eslint/parser": "^7.2.0",
"typescript": "^5.5.2"
},
"engines": {
"node": "^20"
}
}
}
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "2.4.0",
"version": "2.6.0",
"type": "module",
"main": "./src/index.ts"
}
11 changes: 5 additions & 6 deletions packages/api/src/deleteComment.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { DeleteCommentRequest, DeleteCommentResponse } from './types';
import { ApiRequest, DeleteCommentRequest, DeleteCommentResponse } from './types';

async function deleteComment({
export async function deleteComment({
commentId,
}: DeleteCommentRequest): Promise<DeleteCommentResponse | null> {
serverUrl,
}: ApiRequest<DeleteCommentRequest>): Promise<DeleteCommentResponse | null> {
try {
const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api/comments/${commentId}`, {
const response = await fetch(`${serverUrl}/api/comments/${commentId}`, {
method: 'DELETE',
credentials: 'include',
headers: {
Expand All @@ -23,5 +24,3 @@ async function deleteComment({
return null;
}
}

export default deleteComment;
24 changes: 11 additions & 13 deletions packages/api/src/deleteLike.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { DeleteLikeRequest, DeleteLikeResponse } from './types';
import { ApiRequest, DeleteLikeRequest, DeleteLikeResponse } from './types';

async function deleteLike({ commentId }: DeleteLikeRequest): Promise<DeleteLikeResponse | null> {
export async function deleteLike({
commentId,
serverUrl,
}: ApiRequest<DeleteLikeRequest>): Promise<DeleteLikeResponse | null> {
try {
const response = await fetch(
`${import.meta.env.VITE_SERVER_URL}/api/comments/${commentId}/likes`,
{
method: 'DELETE',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
const response = await fetch(`${serverUrl}/api/comments/${commentId}/likes`, {
method: 'DELETE',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
);
});

if (!response.ok) {
throw new Error(`HTTP Error! Status: ${response.status}`);
Expand All @@ -24,5 +24,3 @@ async function deleteLike({ commentId }: DeleteLikeRequest): Promise<DeleteLikeR
return null;
}
}

export default deleteLike;
26 changes: 12 additions & 14 deletions packages/api/src/deleteUsersToGroups.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { DeleteUsersToGroupsRequest, DeleteUsersToGroupsResponse } from './types';
import { ApiRequest, DeleteUsersToGroupsRequest, DeleteUsersToGroupsResponse } from './types';

async function deleteUsersToGroups({
export async function deleteUsersToGroups({
userToGroupId,
}: DeleteUsersToGroupsRequest): Promise<DeleteUsersToGroupsResponse | { errors: string[] } | null> {
serverUrl,
}: ApiRequest<DeleteUsersToGroupsRequest>): Promise<
DeleteUsersToGroupsResponse | { errors: string[] } | null
> {
try {
const response = await fetch(
`${import.meta.env.VITE_SERVER_URL}/api/users-to-groups/${userToGroupId}`,
{
method: 'DELETE',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
const response = await fetch(`${serverUrl}/api/users-to-groups/${userToGroupId}`, {
method: 'DELETE',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
);
});

if (!response.ok) {
if (response.status < 500) {
Expand All @@ -33,5 +33,3 @@ async function deleteUsersToGroups({
return null;
}
}

export default deleteUsersToGroups;
10 changes: 5 additions & 5 deletions packages/api/src/fetchAlerts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { GetAlertsResponse } from './types';
import { ApiRequest, GetAlertsResponse } from './types';

async function fetchAlerts(): Promise<GetAlertsResponse | null> {
export async function fetchAlerts({
serverUrl,
}: ApiRequest<unknown>): Promise<GetAlertsResponse | null> {
try {
const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api/alerts`, {
const response = await fetch(`${serverUrl}/api/alerts`, {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
Expand All @@ -20,5 +22,3 @@ async function fetchAlerts(): Promise<GetAlertsResponse | null> {
return null;
}
}

export default fetchAlerts;
22 changes: 10 additions & 12 deletions packages/api/src/fetchCommentLikes.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { GetLikesRequest, GetLikesResponse } from './types';
import { ApiRequest, GetLikesRequest, GetLikesResponse } from './types';

async function fetchLikes({ commentId }: GetLikesRequest): Promise<GetLikesResponse | null> {
export async function fetchCommentLikes({
commentId,
serverUrl,
}: ApiRequest<GetLikesRequest>): Promise<GetLikesResponse | null> {
try {
const response = await fetch(
`${import.meta.env.VITE_SERVER_URL}/api/comments/${commentId}/likes`,
{
credentials: 'include',
headers: {
'Content-type': 'application/json',
},
const response = await fetch(`${serverUrl}/api/comments/${commentId}/likes`, {
credentials: 'include',
headers: {
'Content-type': 'application/json',
},
);
});

if (!response.ok) {
throw new Error(`HTTP Error! Status: ${response.status}`);
Expand All @@ -23,5 +23,3 @@ async function fetchLikes({ commentId }: GetLikesRequest): Promise<GetLikesRespo
return null;
}
}

export default fetchLikes;
22 changes: 9 additions & 13 deletions packages/api/src/fetchComments.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { GetCommentsRequest, GetCommentsResponse } from './types';
import { ApiRequest, GetCommentsRequest, GetCommentsResponse } from './types';

async function fetchComments({
export async function fetchComments({
optionId,
}: GetCommentsRequest): Promise<GetCommentsResponse | null> {
serverUrl,
}: ApiRequest<GetCommentsRequest>): Promise<GetCommentsResponse | null> {
try {
const response = await fetch(
`${import.meta.env.VITE_SERVER_URL}/api/options/${optionId}/comments`,
{
credentials: 'include',
headers: {
'Content-type': 'application/json',
},
const response = await fetch(`${serverUrl}/api/options/${optionId}/comments`, {
credentials: 'include',
headers: {
'Content-type': 'application/json',
},
);
});

if (!response.ok) {
throw new Error(`HTTP Error! Status: ${response.status}`);
Expand All @@ -25,5 +23,3 @@ async function fetchComments({
return null;
}
}

export default fetchComments;
11 changes: 6 additions & 5 deletions packages/api/src/fetchCycle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { GetCyclesResponse } from './types';
import { ApiRequest, GetCyclesResponse } from './types';

async function fetchCycle(cycleId: string): Promise<GetCyclesResponse[number] | null> {
export async function fetchCycle({
cycleId,
serverUrl,
}: ApiRequest<{ cycleId: string }>): Promise<GetCyclesResponse[number] | null> {
try {
const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api/cycles/${cycleId}`, {
const response = await fetch(`${serverUrl}/api/cycles/${cycleId}`, {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
Expand All @@ -20,5 +23,3 @@ async function fetchCycle(cycleId: string): Promise<GetCyclesResponse[number] |
return null;
}
}

export default fetchCycle;
10 changes: 5 additions & 5 deletions packages/api/src/fetchCycles.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { GetCyclesResponse } from './types';
import { ApiRequest, GetCyclesResponse } from './types';

async function fetchCycles(): Promise<GetCyclesResponse | null> {
export async function fetchCycles({
serverUrl,
}: ApiRequest<unknown>): Promise<GetCyclesResponse | null> {
try {
const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api/cycles`, {
const response = await fetch(`${serverUrl}/api/cycles`, {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
Expand All @@ -20,5 +22,3 @@ async function fetchCycles(): Promise<GetCyclesResponse | null> {
return null;
}
}

export default fetchCycles;
11 changes: 6 additions & 5 deletions packages/api/src/fetchEvent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { GetEventResponse } from './types';
import { ApiRequest, GetEventResponse } from './types';

async function fetchEvent(eventId: string): Promise<GetEventResponse | null> {
export async function fetchEvent({
serverUrl,
eventId,
}: ApiRequest<{ eventId: string }>): Promise<GetEventResponse | null> {
try {
const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api/events/${eventId}`, {
const response = await fetch(`${serverUrl}/api/events/${eventId}`, {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
Expand All @@ -20,5 +23,3 @@ async function fetchEvent(eventId: string): Promise<GetEventResponse | null> {
return null;
}
}

export default fetchEvent;
22 changes: 10 additions & 12 deletions packages/api/src/fetchEventCycles.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { GetCyclesResponse } from './types';
import { ApiRequest, GetCyclesResponse } from './types';

async function fetchEventCycles(eventId: string): Promise<GetCyclesResponse | null> {
export async function fetchEventCycles({
eventId,
serverUrl,
}: ApiRequest<{ eventId: string }>): Promise<GetCyclesResponse | null> {
try {
const response = await fetch(
`${import.meta.env.VITE_SERVER_URL}/api/events/${eventId}/cycles`,
{
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
const response = await fetch(`${serverUrl}/api/events/${eventId}/cycles`, {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
);
});

if (!response.ok) {
throw new Error(`HTTP Error! Status: ${response.status}`);
Expand All @@ -23,5 +23,3 @@ async function fetchEventCycles(eventId: string): Promise<GetCyclesResponse | nu
return null;
}
}

export default fetchEventCycles;
Loading

0 comments on commit 8165aad

Please sign in to comment.