Skip to content

Commit

Permalink
Create release 1.0.0
Browse files Browse the repository at this point in the history
Official launch of CodeParty
  • Loading branch information
yhtMinceraft1010X committed Nov 11, 2023
2 parents 2324449 + 2edefff commit 624dc02
Show file tree
Hide file tree
Showing 90 changed files with 14,007 additions and 1,213 deletions.
1 change: 1 addition & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
environment: production
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: 'read'
id-token: 'write'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
.env.firebase_emulators_test
secrets/
yarn-error.log
bash.exe.stackdump
sh.exe.stackdump
40 changes: 25 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

Prerequisites for PeerPrep Monorepo:

1. **Yarn:** Ensure you have the latest version of Yarn installed. Yarn
1. **Yarn:** Ensure you have the latest version of Yarn installed. Yarn
Workspaces is available in Yarn v1.0 and later.
2. Installation (if not already installed):
2. Installation (if not already installed):

```bash
npm install -g yarn
```

3. **Node.js:** Check each application's documentation for the recommended
3. **Node.js:** Check each application's documentation for the recommended
Node.js version.
4. **Git (Optional but Recommended):**
5. **Docker (If deploying with Docker):**
6. **Kubernetes Tools (If deploying with Kubernetes):**
4. **Git (Optional but Recommended):**
5. **Docker (If deploying with Docker):**
6. **Kubernetes Tools (If deploying with Kubernetes):**
---
Expand Down Expand Up @@ -52,10 +52,19 @@ your services / frontend.
MONGO_ATLAS_URL=<redacted>
FIREBASE_SERVICE_ACCOUNT=<redacted>
NEXT_PUBLIC_FRONTEND_FIREBASE_CONFIG={"apiKey": <redacted>,"authDomain": <redacted>,"projectId": <redacted>,"storageBucket": <redacted>,"messagingSenderId": <redacted>,"appId": <redacted>}
TWILIO_ACCOUNT_SID=<redacted>
TWILIO_API_KEY=<redacted>
TWILIO_API_SECRET=<redacted>
```
Note: For `NEXT_PUBLIC_FRONTEND_FIREBASE_CONFIG`, the JSON should not have newlines since Next.js may not process it correctly.
The difference between it and `FIREBASE_SERVICE_ACCOUNT` are shown below:
1. **Installing secret detection hooks:** From the root directory, run:
| Variable | Purpose |
| -------- | ------- |
| FIREBASE_SERVICE_ACCOUNT | For backend verification and administrative tasks |
| NEXT_PUBLIC_FRONTEND_FIREBASE_CONFIG | For the frontend to connect to Firebase |
2. **Installing secret detection hooks:** From the root directory, run:
```bash
pip install pre-commit
pre-commit install
Expand All @@ -66,7 +75,7 @@ As a tip, if you think a file will eventually store secrets, immediately add it
it in case you forget later on when you have a lot more files to commit.
1. **Installing Dependencies:** From the root directory (`/peerprep`), run:
3. **Installing Dependencies:** From the root directory (`/peerprep`), run:
```bash
yarn install
Expand All @@ -83,27 +92,27 @@ it in case you forget later on when you have a lot more files to commit.
This command will install dependencies for all services and the frontend in a
centralized `node_modules` directory at the root.
1. **Adding Dependencies:** To add a dependency to a specific workspace (e.g.,
4. **Adding Dependencies:** To add a dependency to a specific workspace (e.g.,
`user-service`), use:
```bash
yarn workspace user-service add [dependency-name]
```
1. **Initializing Prisma:** In the root file, run the following:
5. **Initializing Prisma:** In the root file, run the following:
```bash
yarn prisma generate ## Do this whenever we change the models in schema.prisma
```
1. **Running Backend Scripts:** To run a script specific to a workspace (e.g.,
6. **Running Backend Scripts:** To run a script specific to a workspace (e.g.,
the `start` script for `user-service`), use:
```bash
yarn workspace user-service start
```
1. **Running Frontend Scripts:** To run the frontend cod, use:
7. **Running Frontend Scripts:** To run the frontend cod, use:
```bash
yarn workspace frontend dev ## For development
Expand All @@ -113,7 +122,8 @@ it in case you forget later on when you have a lot more files to commit.
yarn workspace frontend build ## For first time setup run the build command
yarn workspace frontend start ## For subsequent runs
```
1. **Running everything at once:** To run everything at once and still maintain the ability to hot-reload your changes, use:
8. **Running everything at once:** To run everything at once and still maintain the ability to hot-reload your changes, use:
```bash
./start-app-no-docker.sh # on mac /linus
Expand All @@ -134,13 +144,13 @@ yarn docker:build
```
This will create new Docker images.
1. **Run yarn docker:devup:** From the root repo, run
2. **Run yarn docker:devup:** From the root repo, run
```bash
yarn docker:devup
```
This will start all the containers.
1. **Once done, run yarn docker:devdown:** From the root repo, run
3. **Once done, run yarn docker:devdown:** From the root repo, run
```bash
yarn docker:devdown
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
spec:
containers:
- env:
- name: FRONTEND_ADDRESS
value: "https://www.codeparty.org"
- name: PRISMA_DATABASE_URL
valueFrom:
secretKeyRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ spec:
spec:
containers:
- env:
- name: FRONTEND_ADDRESS
value: "https://www.codeparty.org"
- name: QUESTION_SERVICE_HOSTNAME
value: "question-service"
- name: PRISMA_DATABASE_URL
valueFrom:
secretKeyRef:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
environment:
PORT: 5002
PRISMA_DATABASE_URL: ${PRISMA_DATABASE_URL}
QUESTION_SERVICE_HOSTNAME: "question-service"

collaboration-service:
build:
Expand Down
7 changes: 6 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"lint": "next lint",
"dev:local": "dotenv -e ../.env -- yarn dev",
"dev:local": "dotenv -e ../.env -- yarnpkg dev",
"dev": "next dev",
"build": "next build",
"start": "next start -H 0.0.0.0",
Expand Down Expand Up @@ -48,6 +48,10 @@
"react-dom": "18.2.0",
"react-hook-form": "^7.47.0",
"react-icons": "^4.11.0",
"react-markdown": "^9.0.0",
"react-syntax-highlighter": "^15.5.0",
"rehype-raw": "^7.0.0",
"sanitize-html": "^2.11.0",
"sass": "^1.69.0",
"socket.io-client": "^4.7.2",
"tailwind-merge": "^1.14.0",
Expand All @@ -61,6 +65,7 @@
"@types/lodash": "^4.14.199",
"@types/react": "^18.2.31",
"@types/react-dom": "^18.2.14",
"@types/react-syntax-highlighter": "^15.5.10",
"@types/socket.io-client": "^3.0.0",
"eslint-config-next": "^13.5.6"
}
Expand Down
47 changes: 26 additions & 21 deletions frontend/src/components/common/difficulty-selector.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import Loader from "../interviews/loader";
import { Button } from "../ui/button";

type Difficulty = 'easy' | 'medium' | 'hard' | 'any';
type Difficulty = "easy" | "medium" | "hard" | "any";

interface DifficultySelectorProps {
onChange: (value: Difficulty) => void;
showAny: boolean;
value: Difficulty;
isLoading?: boolean;
}

export default function DifficultySelector({ onChange, showAny, value }: DifficultySelectorProps) {

export default function DifficultySelector({
onChange,
showAny,
value,
isLoading = false,
}: DifficultySelectorProps) {
const difficulties = [
{ label: "Easy", value: "easy" },
{ label: "Medium", value: "medium" },
Expand All @@ -22,23 +28,22 @@ export default function DifficultySelector({ onChange, showAny, value }: Difficu

return (
<div className="mt-2 mb-6 flex gap-2 bg-popover w-min rounded-lg">
{
difficulties.map((difficulty) => (
<Button
key={difficulty.value}
className="w-32"
variant={value == difficulty.value ? "outline" : "secondary"}
value={difficulty.value}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
onChange(e.currentTarget.value as Difficulty);
}}
>
{difficulty.label}
</Button>
))
}
{difficulties.map((difficulty) => (
<Button
disabled={isLoading}
key={difficulty.value}
className="w-32"
variant={value == difficulty.value ? "outline" : "secondary"}
value={difficulty.value}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
onChange(e.currentTarget.value as Difficulty);
}}
>
{difficulty.label}
</Button>
))}
</div>
)
);
}
3 changes: 2 additions & 1 deletion frontend/src/components/common/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum TabsOptions {
}

export default function Navbar() {
const { user: currentUser, authIsReady } = useContext(AuthContext);
const { user: currentUser, authIsReady, isAdmin } = useContext(AuthContext);
const [activeTab, setActiveTab] = useState<TabsOptions>(TabsOptions.NULL);

const { login } = useLogin();
Expand Down Expand Up @@ -79,6 +79,7 @@ export default function Navbar() {
</div>
)}
</div>
{isAdmin && <p>Admin Page</p>}
{!currentUser && (
<div className="grid grid-cols-2 gap-4">
<Button variant={"outline"} onClick={login}>
Expand Down
36 changes: 18 additions & 18 deletions frontend/src/components/interviews/leaderboard/columns.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";

import { ColumnDef } from "@tanstack/react-table"
import { ColumnDef } from "@tanstack/react-table";

export type PublicUser = {
displayName: string
attempts: number
photoURL: string
}
displayName: string;
attempts: number;
photoURL: string;
};

const getInitials = (name: string) => {
const names = name.split(" ");
Expand All @@ -16,38 +16,38 @@ const getInitials = (name: string) => {
initials += n[0].toUpperCase();
});
return initials;
}
};

export const columns: ColumnDef<PublicUser>[] = [
{
accessorKey: "displayName",
header: "User",
cell: ({ row }) => {
const displayName = row.getValue("displayName") as string
const photoURL = row.original.photoURL
const displayName = row.getValue("displayName") as string;
const photoURL = row.original.photoURL;

return (
<Button variant='ghost'
<Button
variant="ghost"
onClick={() => {
window.location.href = `/profile/1`;
window.location.href = `/profile/Y4sCNQ4ZBqOlHjqoXmCAFAHnBWU2`;
}}
className="w-64"
>
>
<div className="flex items-center justify-start gap-2 w-full">
<Avatar className="h-8 w-8">
<AvatarImage src={photoURL ?? ''} />
<AvatarFallback>{getInitials(displayName ?? '')}</AvatarFallback>
<AvatarImage src={photoURL ?? ""} />
<AvatarFallback>{getInitials(displayName ?? "")}</AvatarFallback>
</Avatar>
{displayName}
</div>
</Button>
)
);
},
},
{
accessorKey: "attempts",
header: "Solved",
invertSorting: true,
},
]

];
2 changes: 1 addition & 1 deletion frontend/src/components/profile/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const columns: ColumnDef<Attempt>[] = [
id: "actions",
header: "Actions",
cell: ({ row }) => {
const attemptId = row.id;
const attemptId = row.original.id;
return (
<Button
variant="outline"
Expand Down
Loading

0 comments on commit 624dc02

Please sign in to comment.