Compare commits
67 commits
feat/18-no
...
main
Author | SHA1 | Date | |
---|---|---|---|
872cfe363f | |||
168fcaa731 | |||
be00d68a68 | |||
984646dfbc | |||
ac7d0d35a6 | |||
010c7885dd | |||
a4d33bf1d0 | |||
92acd8a32b | |||
583368c1ba | |||
30b0df062f | |||
7260985de3 | |||
de1a80aed8 | |||
664c6cf283 | |||
142ac33e28 | |||
c014b77f9b | |||
9adcdc274f | |||
6ae22a23c7 | |||
83fe2c772c | |||
d7fdd5d257 | |||
9015e993a8 | |||
ab869fbc29 | |||
8dd014ead1 | |||
1ec636f3b0 | |||
b26a46274c | |||
cb793b9a38 | |||
2a95836dcb | |||
b5602bead5 | |||
dbf9809c7b | |||
e7356cada6 | |||
8e7b2eda32 | |||
a0965e1b8d | |||
a6bad556a4 | |||
9191eb3df0 | |||
3d07ca077f | |||
53cc8cb2b7 | |||
016b4371c2 | |||
ce27923118 | |||
94f89fea89 | |||
a8c52e3f54 | |||
ed6174ad34 | |||
fdc556afc0 | |||
a8eb6a7a92 | |||
4c07c0466e | |||
1c082b9eb1 | |||
9af74e4df4 | |||
331bf5edda | |||
0815440f72 | |||
1d17f7329e | |||
f6b094bbb2 | |||
a1568e455f | |||
9f0a5813be | |||
1cb2019298 | |||
6231d6cd45 | |||
2e31d935a6 | |||
e1a50b87e5 | |||
12fe9be5a5 | |||
5dd0179ac2 | |||
d2ba0bfc16 | |||
232ce7bafe | |||
f769b400c6 | |||
7f822e0e77 | |||
7775e5f0a8 | |||
a563031f91 | |||
70fad4de73 | |||
92be324186 | |||
6c734f2d19 | |||
72c3f6c17f |
67 changed files with 3764 additions and 1062 deletions
19
.env.example
19
.env.example
|
@ -6,4 +6,23 @@ AUTH_AUTHENTIK_ID=
|
||||||
AUTH_AUTHENTIK_SECRET=
|
AUTH_AUTHENTIK_SECRET=
|
||||||
AUTH_AUTHENTIK_ISSUER=
|
AUTH_AUTHENTIK_ISSUER=
|
||||||
|
|
||||||
|
AUTH_DISCORD_ID=
|
||||||
|
AUTH_DISCORD_SECRET=
|
||||||
|
|
||||||
|
AUTH_FACEBOOK_ID=
|
||||||
|
AUTH_FACEBOOK_SECRET=
|
||||||
|
|
||||||
|
AUTH_GITHUB_ID=
|
||||||
|
AUTH_GITHUB_SECRET=
|
||||||
|
|
||||||
|
AUTH_GITLAB_ID=
|
||||||
|
AUTH_GITLAB_SECRET=
|
||||||
|
|
||||||
|
AUTH_GOOGLE_ID=
|
||||||
|
AUTH_GOOGLE_SECRET=
|
||||||
|
|
||||||
|
AUTH_KEYCLOAK_ID=
|
||||||
|
AUTH_KEYCLOAK_SECRET=
|
||||||
|
AUTH_KEYCLOAK_ISSUER=
|
||||||
|
|
||||||
NEXT_PUBLIC_APP_URL=
|
NEXT_PUBLIC_APP_URL=
|
||||||
|
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
@ -10,7 +10,7 @@ jobs:
|
||||||
name: Tests
|
name: Tests
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: cypress/browsers:latest@sha256:9daea41366dfd1b72496bf3e8295eda215a6990c2dbe4f9ff4b8ba47342864fb
|
image: cypress/browsers:latest@sha256:95587c1ce688ce6f59934cc234a753a32a1782ca1c7959707a7d2332e69f6f63
|
||||||
options: --user 1001
|
options: --user 1001
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|
219
README.md
219
README.md
|
@ -1,5 +1,19 @@
|
||||||
# MeetUP
|
# MeetUP
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
- [Description](#description)
|
||||||
|
- [Project Status](#project-status)
|
||||||
|
- [Features](#features)
|
||||||
|
- [Implemented Features](#implemented-features)
|
||||||
|
- [Planned Features](#planned-features-roadmap)
|
||||||
|
- [Technologies Used](#technologies-used)
|
||||||
|
- [Development environment setup](#development-environment-setup)
|
||||||
|
- [Without Docker](#without-docker)
|
||||||
|
- [With Docker](#with-docker)
|
||||||
|
- [Production Deployment using Docker](#production-deployment-using-docker)
|
||||||
|
- [Contributing](#contributing)
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
MeetUP is a social calendar application designed to make coordinating schedules with friends seamless and intuitive. It was created because it can be a hassle coordinating meetings between multiple friends and across different friend groups. MeetUP aims to simplify the process of finding mutual availability without endless back-and-forth messaging.
|
MeetUP is a social calendar application designed to make coordinating schedules with friends seamless and intuitive. It was created because it can be a hassle coordinating meetings between multiple friends and across different friend groups. MeetUP aims to simplify the process of finding mutual availability without endless back-and-forth messaging.
|
||||||
|
@ -12,52 +26,54 @@ MeetUP is a social calendar application designed to make coordinating schedules
|
||||||
|
|
||||||
### Implemented Features
|
### Implemented Features
|
||||||
|
|
||||||
- Core infrastructure setup in progress. No user-facing features are implemented yet.
|
- Event creation, deletion, and editing
|
||||||
|
- SSO and credentials login and signup
|
||||||
|
- Participant invitation and status
|
||||||
|
- Calendar of your own events
|
||||||
|
- Calendar of other users' availability (only in event creation form)
|
||||||
|
|
||||||
### Planned Features (Roadmap)
|
### Planned Features (Roadmap)
|
||||||
|
|
||||||
- **Friendships:** Connect with friends to share calendars.
|
- Friendships
|
||||||
- **Group Calendars:** Create and manage shared calendars for groups.
|
- Group calendars
|
||||||
- **iCal Import:** Import existing calendars from iCalendar (.ics) files.
|
- iCal import and export
|
||||||
- **iCal Export:** Export personal or shared calendars in iCalendar (.ics) format.
|
- Notifications (in-app and external/mail)
|
||||||
- **Email Notifications:** Receive email alerts for event bookings, reminders, and updates.
|
|
||||||
- **View Blocked Slots:** See when friends are busy without revealing event details.
|
|
||||||
- **Book Timeslots:** Request and confirm meeting times in friends' available slots.
|
|
||||||
- **SSO Compatibility:** Planning for Single Sign-On integration.
|
|
||||||
|
|
||||||
## Technologies Used
|
## Technologies Used
|
||||||
|
|
||||||
This project is built with a modern tech stack:
|
This project is built with a modern tech stack:
|
||||||
|
|
||||||
- **Package Manager:** [Yarn](https://yarnpkg.com/)
|
- **Package Manager:** [Yarn](https://yarnpkg.com/)
|
||||||
- **Framework:** [Next.js](https://nextjs.org/) - React framework for server-side rendering and static site generation.
|
- **Framework:** [Next.js](https://nextjs.org/)
|
||||||
- **Language:** [TypeScript](https://www.typescriptlang.org/) - Superset of JavaScript that adds static typing.
|
- **Language:** [TypeScript](https://www.typescriptlang.org/)
|
||||||
- **ORM:** [Prisma](https://www.prisma.io/) - Next-generation ORM for Node.js and TypeScript.
|
- **ORM:** [Prisma](https://www.prisma.io/)
|
||||||
- **Authentication:** [Auth.js](https://authjs.dev/) (formerly NextAuth.js) - Authentication for Next.js.
|
- **Authentication:** [Auth.js](https://authjs.dev/)
|
||||||
- **Styling:** [Tailwind CSS](https://tailwindcss.com/) - A utility-first CSS framework.
|
- **Styling:** [Tailwind CSS](https://tailwindcss.com/)
|
||||||
- **UI Components:** [shadcn/ui](https://ui.shadcn.com/) - Re-usable components built using Radix UI and Tailwind CSS.
|
- **UI Components:** [shadcn/ui](https://ui.shadcn.com/)
|
||||||
- **Containerization:** [Docker](https://www.docker.com/) (for planned self-hosting option)
|
- **Containerization:** [Docker](https://www.docker.com/)
|
||||||
- _(You can also list related tools here, e.g., ESLint, Prettier, testing libraries if you plan to use them)_
|
- **API Docs:** [Swagger](https://swagger.io/)
|
||||||
|
- **React hook API client:** [orval](https://orval.dev/)
|
||||||
|
|
||||||
## Getting Started
|
## Development environment setup
|
||||||
|
|
||||||
|
### Without Docker
|
||||||
|
|
||||||
**Prerequisites:**
|
**Prerequisites:**
|
||||||
|
|
||||||
- Node.js: Version is continually upgraded. It's recommended to use the latest LTS or a recent stable version. (Check `.nvmrc` if available).
|
- **Node.js**: version 22+
|
||||||
- Yarn: Version is continually upgraded. (Check `package.json` engines field if specified).
|
- **corepack**: enable using `corepack enable`
|
||||||
- A database supported by Prisma (e.g., PostgreSQL, MySQL, SQLite). Ensure your database server is running.
|
|
||||||
|
|
||||||
**Installation & Running Locally:**
|
**Installation & Running:**
|
||||||
|
|
||||||
1. **Clone the repository:**
|
1. **Clone the repository:**
|
||||||
- Using SSH:
|
- Using HTTPS:
|
||||||
|
```bash
|
||||||
|
git clone https://git.dominikstahl.dev/DHBW-WE/MeetUp.git
|
||||||
|
```
|
||||||
|
- Or using SSH:
|
||||||
```bash
|
```bash
|
||||||
git clone ssh://git@git.dominikstahl.dev/DHBW-WE/MeetUp.git
|
git clone ssh://git@git.dominikstahl.dev/DHBW-WE/MeetUp.git
|
||||||
```
|
```
|
||||||
- Or using HTTPS (recommended for most users):
|
|
||||||
```bash
|
|
||||||
git clone [https://git.dominikstahl.dev/DHBW-WE/MeetUp.git](https://git.dominikstahl.dev/DHBW-WE/MeetUp.git)
|
|
||||||
```
|
|
||||||
```bash
|
```bash
|
||||||
cd MeetUp
|
cd MeetUp
|
||||||
```
|
```
|
||||||
|
@ -66,53 +82,44 @@ This project is built with a modern tech stack:
|
||||||
yarn install
|
yarn install
|
||||||
```
|
```
|
||||||
3. **Set up environment variables:**
|
3. **Set up environment variables:**
|
||||||
- You will need to create an `AUTH_SECRET`. You can generate one using the following command:
|
You will need to create an `AUTH_SECRET`. You can generate one using the following command:
|
||||||
```bash
|
|
||||||
npx auth secret
|
|
||||||
```
|
|
||||||
- Copy the `.env.example` file (if it exists) to `.env.local`. If not, create `.env.local`.
|
|
||||||
```bash
|
|
||||||
# If .env.example exists:
|
|
||||||
cp .env.example .env.local
|
|
||||||
# Otherwise, create .env.local and add the following:
|
|
||||||
```
|
|
||||||
- Ensure the following environment variables are set in your `.env.local` file. Adjust `DATABASE_URL` for your specific database provider and credentials.
|
|
||||||
|
|
||||||
```env
|
```bash
|
||||||
# Database Connection String (Prisma)
|
npx auth secret
|
||||||
# Example for PostgreSQL: DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=public"
|
```
|
||||||
DATABASE_URL="your_database_connection_string"
|
|
||||||
|
|
||||||
# Generated with npx auth secret
|
Add any additional needed environment variables into the generated `.env.local` file.
|
||||||
AUTH_SECRET="your_generated_auth_secret"
|
Example variables can be found in the `.env.example` file. The following variables are required:
|
||||||
|
|
||||||
# Authentik SSO Variables (if you are using this provider)
|
```env
|
||||||
AUTH_AUTHENTIK_ID=
|
# Generated with npx auth secret
|
||||||
AUTH_AUTHENTIK_SECRET=
|
AUTH_SECRET="your_generated_auth_secret"
|
||||||
AUTH_AUTHENTIK_ISSUER=
|
|
||||||
|
|
||||||
# Base URL of your application
|
DATABASE_URL="file:./dev.db"
|
||||||
NEXT_PUBLIC_APP_URL="http://localhost:3000"
|
```
|
||||||
```
|
|
||||||
|
|
||||||
4. **Apply database migrations (Prisma):**
|
4. **Apply database migrations (Prisma):**
|
||||||
- Ensure your Prisma schema (`prisma/schema.prisma`) is defined.
|
Set up/update the database with these commands:
|
||||||
- Setup/update the database with these commands:
|
|
||||||
```bash
|
|
||||||
yarn prisma:generate
|
|
||||||
```
|
|
||||||
```bash
|
|
||||||
yarn prisma:db:push
|
|
||||||
```
|
|
||||||
- Run the following command to apply migrations and generate Prisma Client:
|
|
||||||
```bash
|
|
||||||
npx prisma migrate dev
|
|
||||||
# You might be prompted to name your first migration.
|
|
||||||
```
|
|
||||||
|
|
||||||
Tipp: You can open the prisma database UI with `yarn prisma:studio`
|
```bash
|
||||||
|
yarn prisma:generate
|
||||||
|
```
|
||||||
|
|
||||||
5. **Run the development server:**
|
```bash
|
||||||
|
yarn prisma:db:push
|
||||||
|
```
|
||||||
|
|
||||||
|
Tip: You can open the Prisma database UI with `yarn prisma:studio`
|
||||||
|
|
||||||
|
5. **Generate needed TypeScript files:**
|
||||||
|
Generate the `swagger.json` file and the API client using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn swagger:generate
|
||||||
|
yarn orval:generate
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Run the development server:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn dev
|
yarn dev
|
||||||
|
@ -120,56 +127,64 @@ This project is built with a modern tech stack:
|
||||||
|
|
||||||
Open [http://localhost:3000](http://localhost:3000) in your browser to see the application.
|
Open [http://localhost:3000](http://localhost:3000) in your browser to see the application.
|
||||||
|
|
||||||
The test user for the application is:
|
### With Docker
|
||||||
|
|
||||||
```bash
|
**Prerequisites:**
|
||||||
email: test@example.com
|
|
||||||
password: password
|
|
||||||
```
|
|
||||||
|
|
||||||
**Docker Development Environment:**
|
- **Docker**
|
||||||
|
- **Docker Compose**
|
||||||
|
|
||||||
- The docker development environment can be started with the following command:
|
**Running:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn dev_container
|
yarn dev_container
|
||||||
```
|
```
|
||||||
|
|
||||||
**Self-Hosting with Docker (Planned):**
|
## Production Deployment using Docker
|
||||||
|
|
||||||
- A Docker image and `docker-compose.yml` file will be provided in the future to allow for easy self-hosting of the MeetUP application. This setup will also include database services. Instructions will be updated here once available.
|
The application can be hosted using the [Docker container](https://git.dominikstahl.dev/DHBW-WE/-/packages/container/meetup/main).
|
||||||
|
|
||||||
|
There is an example Docker Compose file provided [here](https://git.dominikstahl.dev/DHBW-WE/MeetUp/src/branch/main/docker-compose.yml).
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions are welcome! If you'd like to contribute, please:
|
Contributions are welcome! If you'd like to contribute, please follow these steps:
|
||||||
|
|
||||||
1. Fork the repository.
|
1. Fork the repository.
|
||||||
2. Create a new branch (`git checkout -b <action>/<issue#>-action_name`).
|
2. Create a new branch:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout -b <type>/<issueNum>-<short_description>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Example: `feat/42-add_login_form`
|
||||||
|
|
||||||
3. Make your changes.
|
3. Make your changes.
|
||||||
4. Commit your changes (`git commit -m '<action>: add some feature'`).
|
4. Commit your changes using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/):
|
||||||
5. Push to the branch (`git push origin <action>/<issue#>-action_name`).
|
- The commit message should be structured as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
<type>(optional scope): <short description>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Example: `feat(auth): add login form`
|
||||||
|
- Example: `fix(events): correct event time calculation`
|
||||||
|
- Example: `docs: update README with setup instructions`
|
||||||
|
|
||||||
|
- Used types:
|
||||||
|
- `feat`: Feature added
|
||||||
|
- `fix`: Bug fix
|
||||||
|
- `test`: Add or modify tests
|
||||||
|
- `docs`: Documentation changes
|
||||||
|
- `chore`: Changes to non-code files (workflows, lock files, etc.)
|
||||||
|
- `refactor`: Code refactoring without changing functionality
|
||||||
|
- `style`: Code style changes (formatting, etc.)
|
||||||
|
- `revert`: Revert a previous commit
|
||||||
|
|
||||||
|
5. Push to your branch:
|
||||||
|
```bash
|
||||||
|
git push origin <type>/<issue#>-<short_description>
|
||||||
|
```
|
||||||
6. Open a Pull Request against the `main` branch.
|
6. Open a Pull Request against the `main` branch.
|
||||||
|
|
||||||
Possible actions are:
|
Please ensure your code adheres to the project's coding standards (run `yarn format`) and that any database schema changes are accompanied by a Prisma migration.
|
||||||
|
|
||||||
*feat* -> Feature added
|
|
||||||
*fix* -> Fixed a bug
|
|
||||||
*test* -> Modified or added tests
|
|
||||||
*docs* -> Modified documentation
|
|
||||||
*chore* -> changes to non code files (workflows, lock files, ...)
|
|
||||||
*refactor* -> rewritten code without changing functionality
|
|
||||||
*style* -> code style (yarn format)
|
|
||||||
*revert* -> reverts a previous commit
|
|
||||||
|
|
||||||
Please ensure your code adheres to the project's coding standards (e.g., run linters/formatters if configured) and that any database schema changes are accompanied by a Prisma migration.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**(Optional Sections You Might Want to Add Later):**
|
|
||||||
|
|
||||||
- **Screenshots/Demo:** (Once you have UI to show)
|
|
||||||
- **API Reference:** (If you plan to expose an API)
|
|
||||||
- **Detailed Deployment Guides:** (For various platforms beyond Docker)
|
|
||||||
- **License:** (e.g., MIT, GPL - Important for open source projects)
|
|
||||||
- **Contact:** (How to get in touch with the maintainers)
|
|
||||||
- **Acknowledgements:** (Credit to any libraries, inspirations, or contributors)
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
export default function authUser() {
|
|
||||||
cy.visit('http://127.0.0.1:3000/login');
|
|
||||||
cy.getBySel('login-header').should('exist');
|
|
||||||
cy.getBySel('login-form').should('exist');
|
|
||||||
cy.getBySel('email-input').should('exist');
|
|
||||||
cy.getBySel('password-input').should('exist');
|
|
||||||
cy.getBySel('login-button').should('exist');
|
|
||||||
cy.getBySel('email-input').type('cypress@example.com');
|
|
||||||
cy.getBySel('password-input').type('Password123!');
|
|
||||||
cy.getBySel('login-button').click();
|
|
||||||
cy.url().should('include', '/home');
|
|
||||||
}
|
|
|
@ -1,9 +1,40 @@
|
||||||
import authUser from './auth-user';
|
|
||||||
|
|
||||||
describe('event creation', () => {
|
describe('event creation', () => {
|
||||||
it('loads', () => {
|
it('loads', () => {
|
||||||
authUser();
|
cy.login();
|
||||||
|
|
||||||
// cy.visit('http://127.0.0.1:3000/events/new'); // TODO: Add event creation tests
|
cy.visit('http://127.0.0.1:3000/events/new');
|
||||||
|
cy.getBySel('event-form').should('exist');
|
||||||
|
cy.getBySel('event-form').within(() => {
|
||||||
|
cy.getBySel('event-name-input').should('exist');
|
||||||
|
cy.getBySel('event-start-time-picker').should('exist');
|
||||||
|
cy.getBySel('event-end-time-picker').should('exist');
|
||||||
|
cy.getBySel('event-location-input').should('exist');
|
||||||
|
cy.getBySel('event-description-input').should('exist');
|
||||||
|
cy.getBySel('event-save-button').should('exist');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates an event', () => {
|
||||||
|
cy.login();
|
||||||
|
cy.visit(
|
||||||
|
'http://127.0.0.1:3000/events/new?start=2025-07-01T01:00:00.000Z&end=2025-07-01T04:30:00.000Z',
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.getBySel('event-form').should('exist');
|
||||||
|
cy.getBySel('event-form').within(() => {
|
||||||
|
cy.getBySel('event-name-input').type('Cypress Test Event');
|
||||||
|
cy.getBySel('event-location-input').type('Cypress Park');
|
||||||
|
cy.getBySel('event-description-input').type(
|
||||||
|
'This is a test event created by Cypress.',
|
||||||
|
);
|
||||||
|
cy.getBySel('event-save-button').click();
|
||||||
|
});
|
||||||
|
cy.wait(1000);
|
||||||
|
cy.visit('http://127.0.0.1:3000/events');
|
||||||
|
cy.getBySel('event-list-entry').should('exist');
|
||||||
|
cy.getBySel('event-list-entry')
|
||||||
|
.contains('Cypress Test Event')
|
||||||
|
.should('exist');
|
||||||
|
cy.getBySel('event-list-entry').contains('Cypress Park').should('exist');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
/* eslint-disable @typescript-eslint/no-namespace */
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
// ***********************************************
|
// ***********************************************
|
||||||
// This example commands.ts shows you how to
|
// This example commands.ts shows you how to
|
||||||
|
@ -44,6 +46,22 @@ Cypress.Commands.add('getBySelLike', (selector, ...args) => {
|
||||||
return cy.get(`[data-cy*=${selector}]`, ...args);
|
return cy.get(`[data-cy*=${selector}]`, ...args);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('login', () => {
|
||||||
|
cy.session('auth', () => {
|
||||||
|
cy.visit('http://127.0.0.1:3000/login');
|
||||||
|
cy.getBySel('login-header').should('exist');
|
||||||
|
cy.getBySel('login-form').should('exist');
|
||||||
|
cy.getBySel('email-input').should('exist');
|
||||||
|
cy.getBySel('password-input').should('exist');
|
||||||
|
cy.getBySel('login-button').should('exist');
|
||||||
|
cy.getBySel('email-input').type('cypress@example.com');
|
||||||
|
cy.getBySel('password-input').type('Password123!');
|
||||||
|
cy.getBySel('login-button').click();
|
||||||
|
cy.url().should('include', '/home');
|
||||||
|
cy.getBySel('header').should('exist');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace Cypress {
|
namespace Cypress {
|
||||||
interface Chainable {
|
interface Chainable {
|
||||||
|
@ -55,6 +73,7 @@ declare global {
|
||||||
selector: string,
|
selector: string,
|
||||||
...args: any[]
|
...args: any[]
|
||||||
): Chainable<JQuery<HTMLElement>>;
|
): Chainable<JQuery<HTMLElement>>;
|
||||||
|
login(): Chainable<void>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ const nextConfig: NextConfig = {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
protocol: 'https',
|
protocol: 'https',
|
||||||
hostname: 'img1.wikia.nocookie.net',
|
hostname: 'i.gifer.com',
|
||||||
port: '',
|
port: '',
|
||||||
pathname: '/**',
|
pathname: '/**',
|
||||||
},
|
},
|
||||||
|
|
11
package.json
11
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "meetup",
|
"name": "meetup",
|
||||||
"version": "0.1.0",
|
"version": "0.1.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --turbopack",
|
"dev": "next dev --turbopack",
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
||||||
"@fortawesome/react-fontawesome": "^0.2.2",
|
"@fortawesome/react-fontawesome": "^0.2.2",
|
||||||
"@hookform/resolvers": "^5.0.1",
|
"@hookform/resolvers": "^5.0.1",
|
||||||
|
"@marko19907/string-to-color": "^1.0.0",
|
||||||
"@prisma/client": "^6.9.0",
|
"@prisma/client": "^6.9.0",
|
||||||
"@radix-ui/react-avatar": "^1.1.10",
|
"@radix-ui/react-avatar": "^1.1.10",
|
||||||
"@radix-ui/react-collapsible": "^1.1.11",
|
"@radix-ui/react-collapsible": "^1.1.11",
|
||||||
|
@ -51,7 +52,7 @@
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"lucide-react": "^0.523.0",
|
"lucide-react": "^0.525.0",
|
||||||
"next": "15.3.4",
|
"next": "15.3.4",
|
||||||
"next-auth": "^5.0.0-beta.25",
|
"next-auth": "^5.0.0-beta.25",
|
||||||
"next-swagger-doc": "^0.4.1",
|
"next-swagger-doc": "^0.4.1",
|
||||||
|
@ -72,15 +73,15 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "3.3.1",
|
"@eslint/eslintrc": "3.3.1",
|
||||||
"@tailwindcss/postcss": "4.1.11",
|
"@tailwindcss/postcss": "4.1.11",
|
||||||
"@types/node": "22.15.33",
|
"@types/node": "22.16.0",
|
||||||
"@types/react": "19.1.8",
|
"@types/react": "19.1.8",
|
||||||
"@types/react-big-calendar": "1.16.2",
|
"@types/react-big-calendar": "1.16.2",
|
||||||
"@types/react-dom": "19.1.6",
|
"@types/react-dom": "19.1.6",
|
||||||
"@types/swagger-ui-react": "5.18.0",
|
"@types/swagger-ui-react": "5.18.0",
|
||||||
"@types/webpack-env": "1.18.8",
|
"@types/webpack-env": "1.18.8",
|
||||||
"cypress": "14.5.0",
|
"cypress": "14.5.1",
|
||||||
"dotenv-cli": "8.0.0",
|
"dotenv-cli": "8.0.0",
|
||||||
"eslint": "9.29.0",
|
"eslint": "9.30.1",
|
||||||
"eslint-config-next": "15.3.4",
|
"eslint-config-next": "15.3.4",
|
||||||
"eslint-config-prettier": "10.1.5",
|
"eslint-config-prettier": "10.1.5",
|
||||||
"orval": "7.10.0",
|
"orval": "7.10.0",
|
||||||
|
|
170
prisma/migrations/20250701092705_v0_1_3/migration.sql
Normal file
170
prisma/migrations/20250701092705_v0_1_3/migration.sql
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
-- RedefineTables
|
||||||
|
PRAGMA defer_foreign_keys=ON;
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_blocked_slots" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"start_time" DATETIME NOT NULL,
|
||||||
|
"end_time" DATETIME NOT NULL,
|
||||||
|
"reason" TEXT,
|
||||||
|
"is_recurring" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"rrule" TEXT,
|
||||||
|
"recurrence_end_date" DATETIME,
|
||||||
|
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "blocked_slots_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_blocked_slots" ("created_at", "end_time", "id", "is_recurring", "reason", "recurrence_end_date", "rrule", "start_time", "updated_at", "user_id") SELECT "created_at", "end_time", "id", "is_recurring", "reason", "recurrence_end_date", "rrule", "start_time", "updated_at", "user_id" FROM "blocked_slots";
|
||||||
|
DROP TABLE "blocked_slots";
|
||||||
|
ALTER TABLE "new_blocked_slots" RENAME TO "blocked_slots";
|
||||||
|
CREATE INDEX "blocked_slots_user_id_start_time_end_time_idx" ON "blocked_slots"("user_id", "start_time", "end_time");
|
||||||
|
CREATE INDEX "blocked_slots_user_id_is_recurring_idx" ON "blocked_slots"("user_id", "is_recurring");
|
||||||
|
CREATE TABLE "new_calendar_export_tokens" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"token" TEXT NOT NULL,
|
||||||
|
"scope" TEXT NOT NULL DEFAULT 'MEETINGS_ONLY',
|
||||||
|
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"last_accessed_at" DATETIME,
|
||||||
|
CONSTRAINT "calendar_export_tokens_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_calendar_export_tokens" ("created_at", "id", "is_active", "last_accessed_at", "scope", "token", "user_id") SELECT "created_at", "id", "is_active", "last_accessed_at", "scope", "token", "user_id" FROM "calendar_export_tokens";
|
||||||
|
DROP TABLE "calendar_export_tokens";
|
||||||
|
ALTER TABLE "new_calendar_export_tokens" RENAME TO "calendar_export_tokens";
|
||||||
|
CREATE UNIQUE INDEX "calendar_export_tokens_token_key" ON "calendar_export_tokens"("token");
|
||||||
|
CREATE INDEX "calendar_export_tokens_user_id_idx" ON "calendar_export_tokens"("user_id");
|
||||||
|
CREATE TABLE "new_calendar_subscriptions" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"feed_url" TEXT NOT NULL,
|
||||||
|
"name" TEXT,
|
||||||
|
"color" TEXT,
|
||||||
|
"is_enabled" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"last_synced_at" DATETIME,
|
||||||
|
"last_sync_error" TEXT,
|
||||||
|
"sync_frequency_minutes" INTEGER DEFAULT 60,
|
||||||
|
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "calendar_subscriptions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_calendar_subscriptions" ("color", "created_at", "feed_url", "id", "is_enabled", "last_sync_error", "last_synced_at", "name", "sync_frequency_minutes", "updated_at", "user_id") SELECT "color", "created_at", "feed_url", "id", "is_enabled", "last_sync_error", "last_synced_at", "name", "sync_frequency_minutes", "updated_at", "user_id" FROM "calendar_subscriptions";
|
||||||
|
DROP TABLE "calendar_subscriptions";
|
||||||
|
ALTER TABLE "new_calendar_subscriptions" RENAME TO "calendar_subscriptions";
|
||||||
|
CREATE INDEX "calendar_subscriptions_user_id_is_enabled_idx" ON "calendar_subscriptions"("user_id", "is_enabled");
|
||||||
|
CREATE TABLE "new_email_queue" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"subject" TEXT NOT NULL,
|
||||||
|
"body_html" TEXT NOT NULL,
|
||||||
|
"body_text" TEXT,
|
||||||
|
"status" TEXT NOT NULL DEFAULT 'PENDING',
|
||||||
|
"scheduled_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"attempts" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"last_attempt_at" DATETIME,
|
||||||
|
"sent_at" DATETIME,
|
||||||
|
"error_message" TEXT,
|
||||||
|
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "email_queue_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_email_queue" ("attempts", "body_html", "body_text", "created_at", "error_message", "id", "last_attempt_at", "scheduled_at", "sent_at", "status", "subject", "updated_at", "user_id") SELECT "attempts", "body_html", "body_text", "created_at", "error_message", "id", "last_attempt_at", "scheduled_at", "sent_at", "status", "subject", "updated_at", "user_id" FROM "email_queue";
|
||||||
|
DROP TABLE "email_queue";
|
||||||
|
ALTER TABLE "new_email_queue" RENAME TO "email_queue";
|
||||||
|
CREATE INDEX "idx_email_queue_pending_jobs" ON "email_queue"("status", "scheduled_at");
|
||||||
|
CREATE INDEX "idx_email_queue_user_history" ON "email_queue"("user_id", "created_at");
|
||||||
|
CREATE TABLE "new_external_events" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"subscription_id" TEXT NOT NULL,
|
||||||
|
"ical_uid" TEXT NOT NULL,
|
||||||
|
"summary" TEXT,
|
||||||
|
"description" TEXT,
|
||||||
|
"start_time" DATETIME NOT NULL,
|
||||||
|
"end_time" DATETIME NOT NULL,
|
||||||
|
"is_all_day" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"location" TEXT,
|
||||||
|
"rrule" TEXT,
|
||||||
|
"dtstamp" DATETIME,
|
||||||
|
"sequence" INTEGER,
|
||||||
|
"show_as_free" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"last_fetched_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
CONSTRAINT "external_events_subscription_id_fkey" FOREIGN KEY ("subscription_id") REFERENCES "calendar_subscriptions" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_external_events" ("description", "dtstamp", "end_time", "ical_uid", "id", "is_all_day", "last_fetched_at", "location", "rrule", "sequence", "show_as_free", "start_time", "subscription_id", "summary") SELECT "description", "dtstamp", "end_time", "ical_uid", "id", "is_all_day", "last_fetched_at", "location", "rrule", "sequence", "show_as_free", "start_time", "subscription_id", "summary" FROM "external_events";
|
||||||
|
DROP TABLE "external_events";
|
||||||
|
ALTER TABLE "new_external_events" RENAME TO "external_events";
|
||||||
|
CREATE INDEX "external_events_subscription_id_start_time_end_time_idx" ON "external_events"("subscription_id", "start_time", "end_time");
|
||||||
|
CREATE INDEX "external_events_subscription_id_show_as_free_idx" ON "external_events"("subscription_id", "show_as_free");
|
||||||
|
CREATE UNIQUE INDEX "external_events_subscription_id_ical_uid_key" ON "external_events"("subscription_id", "ical_uid");
|
||||||
|
CREATE TABLE "new_friendships" (
|
||||||
|
"user_id_1" TEXT NOT NULL,
|
||||||
|
"user_id_2" TEXT NOT NULL,
|
||||||
|
"status" TEXT NOT NULL DEFAULT 'PENDING',
|
||||||
|
"requested_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"accepted_at" DATETIME,
|
||||||
|
|
||||||
|
PRIMARY KEY ("user_id_1", "user_id_2"),
|
||||||
|
CONSTRAINT "friendships_user_id_1_fkey" FOREIGN KEY ("user_id_1") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "friendships_user_id_2_fkey" FOREIGN KEY ("user_id_2") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_friendships" ("accepted_at", "requested_at", "status", "user_id_1", "user_id_2") SELECT "accepted_at", "requested_at", "status", "user_id_1", "user_id_2" FROM "friendships";
|
||||||
|
DROP TABLE "friendships";
|
||||||
|
ALTER TABLE "new_friendships" RENAME TO "friendships";
|
||||||
|
CREATE INDEX "idx_friendships_user2_status" ON "friendships"("user_id_2", "status");
|
||||||
|
CREATE TABLE "new_group_members" (
|
||||||
|
"group_id" TEXT NOT NULL,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"role" TEXT NOT NULL DEFAULT 'MEMBER',
|
||||||
|
"added_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
PRIMARY KEY ("group_id", "user_id"),
|
||||||
|
CONSTRAINT "group_members_group_id_fkey" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "group_members_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_group_members" ("added_at", "group_id", "role", "user_id") SELECT "added_at", "group_id", "role", "user_id" FROM "group_members";
|
||||||
|
DROP TABLE "group_members";
|
||||||
|
ALTER TABLE "new_group_members" RENAME TO "group_members";
|
||||||
|
CREATE INDEX "group_members_user_id_idx" ON "group_members"("user_id");
|
||||||
|
CREATE TABLE "new_meeting_participants" (
|
||||||
|
"meeting_id" TEXT NOT NULL,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"status" TEXT NOT NULL DEFAULT 'PENDING',
|
||||||
|
"added_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
PRIMARY KEY ("meeting_id", "user_id"),
|
||||||
|
CONSTRAINT "meeting_participants_meeting_id_fkey" FOREIGN KEY ("meeting_id") REFERENCES "meetings" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "meeting_participants_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_meeting_participants" ("added_at", "meeting_id", "status", "user_id") SELECT "added_at", "meeting_id", "status", "user_id" FROM "meeting_participants";
|
||||||
|
DROP TABLE "meeting_participants";
|
||||||
|
ALTER TABLE "new_meeting_participants" RENAME TO "meeting_participants";
|
||||||
|
CREATE INDEX "idx_participants_user_status" ON "meeting_participants"("user_id", "status");
|
||||||
|
CREATE TABLE "new_notifications" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"type" TEXT NOT NULL,
|
||||||
|
"related_entity_type" TEXT,
|
||||||
|
"related_entity_id" TEXT,
|
||||||
|
"message" TEXT NOT NULL,
|
||||||
|
"is_read" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
CONSTRAINT "notifications_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_notifications" ("created_at", "id", "is_read", "message", "related_entity_id", "related_entity_type", "type", "user_id") SELECT "created_at", "id", "is_read", "message", "related_entity_id", "related_entity_type", "type", "user_id" FROM "notifications";
|
||||||
|
DROP TABLE "notifications";
|
||||||
|
ALTER TABLE "new_notifications" RENAME TO "notifications";
|
||||||
|
CREATE INDEX "idx_notifications_user_read_time" ON "notifications"("user_id", "is_read", "created_at");
|
||||||
|
CREATE TABLE "new_user_notification_preferences" (
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"notification_type" TEXT NOT NULL,
|
||||||
|
"email_enabled" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"updated_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
PRIMARY KEY ("user_id", "notification_type"),
|
||||||
|
CONSTRAINT "user_notification_preferences_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_user_notification_preferences" ("email_enabled", "notification_type", "updated_at", "user_id") SELECT "email_enabled", "notification_type", "updated_at", "user_id" FROM "user_notification_preferences";
|
||||||
|
DROP TABLE "user_notification_preferences";
|
||||||
|
ALTER TABLE "new_user_notification_preferences" RENAME TO "user_notification_preferences";
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
|
PRAGMA defer_foreign_keys=OFF;
|
10
src/app/(main)/blocker/[slotId]/page.tsx
Normal file
10
src/app/(main)/blocker/[slotId]/page.tsx
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import BlockedSlotForm from '@/components/forms/blocked-slot-form';
|
||||||
|
|
||||||
|
export default async function NewBlockedSlotPage({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ slotId?: string }>;
|
||||||
|
}) {
|
||||||
|
const resolvedParams = await params;
|
||||||
|
return <BlockedSlotForm existingBlockedSlotId={resolvedParams.slotId} />;
|
||||||
|
}
|
5
src/app/(main)/blocker/new/page.tsx
Normal file
5
src/app/(main)/blocker/new/page.tsx
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import BlockedSlotForm from '@/components/forms/blocked-slot-form';
|
||||||
|
|
||||||
|
export default function NewBlockedSlotPage() {
|
||||||
|
return <BlockedSlotForm />;
|
||||||
|
}
|
56
src/app/(main)/blocker/page.tsx
Normal file
56
src/app/(main)/blocker/page.tsx
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { RedirectButton } from '@/components/buttons/redirect-button';
|
||||||
|
import BlockedSlotListEntry from '@/components/custom-ui/blocked-slot-list-entry';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { useGetApiBlockedSlots } from '@/generated/api/blocked-slots/blocked-slots';
|
||||||
|
|
||||||
|
export default function BlockedSlots() {
|
||||||
|
const { data: blockedSlotsData, isLoading, error } = useGetApiBlockedSlots();
|
||||||
|
|
||||||
|
if (isLoading) return <div className='text-center mt-10'>Loading...</div>;
|
||||||
|
if (error)
|
||||||
|
return (
|
||||||
|
<div className='text-center mt-10 text-red-500'>
|
||||||
|
Error loading blocked slots
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const blockedSlots = blockedSlotsData?.data?.blocked_slots || [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='relative h-full flex flex-col items-center'>
|
||||||
|
{/* Heading */}
|
||||||
|
<h1 className='text-3xl font-bold mt-8 mb-4 text-center z-10'>
|
||||||
|
My Blockers
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
{/* Scrollable blocked slot list */}
|
||||||
|
<div className='w-full flex justify-center overflow-hidden'>
|
||||||
|
<div className='grid gap-8 p-6 overflow-y-auto'>
|
||||||
|
{blockedSlots.length > 0 ? (
|
||||||
|
blockedSlots.map((slot) => (
|
||||||
|
<BlockedSlotListEntry
|
||||||
|
key={slot.id}
|
||||||
|
{...slot}
|
||||||
|
updated_at={new Date(slot.updated_at)}
|
||||||
|
created_at={new Date(slot.created_at)}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<div className='flex flex-1 flex-col items-center justify-center min-h-[300px]'>
|
||||||
|
<Label size='large' className='justify-center text-center'>
|
||||||
|
You don't have any blockers right now
|
||||||
|
</Label>
|
||||||
|
<RedirectButton
|
||||||
|
redirectUrl='/blocker/new'
|
||||||
|
buttonText='Create New Blocker'
|
||||||
|
className='mt-4'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import {
|
||||||
useDeleteApiEventEventID,
|
useDeleteApiEventEventID,
|
||||||
useGetApiEventEventID,
|
useGetApiEventEventID,
|
||||||
} from '@/generated/api/event/event';
|
} from '@/generated/api/event/event';
|
||||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
|
||||||
import { RedirectButton } from '@/components/buttons/redirect-button';
|
import { RedirectButton } from '@/components/buttons/redirect-button';
|
||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
import ParticipantListEntry from '@/components/custom-ui/participant-list-entry';
|
import ParticipantListEntry from '@/components/custom-ui/participant-list-entry';
|
||||||
|
@ -35,27 +34,21 @@ export default function ShowEvent() {
|
||||||
|
|
||||||
// Fetch event data
|
// Fetch event data
|
||||||
const { data: eventData, isLoading, error } = useGetApiEventEventID(eventID);
|
const { data: eventData, isLoading, error } = useGetApiEventEventID(eventID);
|
||||||
const { data: userData, isLoading: userLoading } = useGetApiUserMe();
|
|
||||||
const deleteEvent = useDeleteApiEventEventID();
|
const deleteEvent = useDeleteApiEventEventID();
|
||||||
|
|
||||||
if (isLoading || userLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className='flex justify-center items-center h-screen'>
|
<div className='flex justify-center items-center h-full'>Loading...</div>
|
||||||
Loading...
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (error || !eventData?.data?.event) {
|
if (error || !eventData?.data?.event) {
|
||||||
return (
|
return (
|
||||||
<div className='flex justify-center items-center h-screen'>
|
<div className='flex justify-center items-center h-full'>
|
||||||
Error loading event.
|
Error loading event.
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const event = eventData.data.event;
|
|
||||||
const organiserName = userData?.data.user?.name || 'Unknown User';
|
|
||||||
|
|
||||||
// Format dates & times for display
|
// Format dates & times for display
|
||||||
const formatDate = (isoString?: string) => {
|
const formatDate = (isoString?: string) => {
|
||||||
if (!isoString) return '-';
|
if (!isoString) return '-';
|
||||||
|
@ -70,8 +63,8 @@ export default function ShowEvent() {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col items-center justify-center h-screen'>
|
<div>
|
||||||
<Card className='w-[80%] max-w-screen p-0 gap-0 max-xl:w-[95%] max-h-[90vh] overflow-auto'>
|
<Card className='w-[80%] max-w-screen p-0 gap-0 max-xl:w-[95%] mx-auto'>
|
||||||
<CardHeader className='p-0 m-0 gap-0' />
|
<CardHeader className='p-0 m-0 gap-0' />
|
||||||
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
|
@ -83,7 +76,7 @@ export default function ShowEvent() {
|
||||||
</div>
|
</div>
|
||||||
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full max-sm:flex max-sm:justify-center'>
|
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||||
<h1 className='text-center'>
|
<h1 className='text-center'>
|
||||||
{event.title || 'Untitled Event'}
|
{eventData.data.event.title || 'Untitled Event'}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className='w-0 sm:w-[100px]'></div>
|
<div className='w-0 sm:w-[100px]'></div>
|
||||||
|
@ -94,8 +87,8 @@ export default function ShowEvent() {
|
||||||
start Time
|
start Time
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>
|
<Label size='large'>
|
||||||
{event.start_time
|
{eventData.data.event.start_time
|
||||||
? `${formatDate(event.start_time)} ${formatTime(event.start_time)}`
|
? `${formatDate(eventData.data.event.start_time)} ${formatTime(eventData.data.event.start_time)}`
|
||||||
: '-'}
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -104,8 +97,8 @@ export default function ShowEvent() {
|
||||||
end Time
|
end Time
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>
|
<Label size='large'>
|
||||||
{event.end_time
|
{eventData.data.event.end_time
|
||||||
? `${formatDate(event.end_time)} ${formatTime(event.end_time)}`
|
? `${formatDate(eventData.data.event.end_time)} ${formatTime(eventData.data.event.end_time)}`
|
||||||
: '-'}
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -113,7 +106,9 @@ export default function ShowEvent() {
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
Location
|
Location
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>{event.location || '-'}</Label>
|
<Label size='large'>
|
||||||
|
{eventData.data.event.location || '-'}
|
||||||
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col gap-4'>
|
<div className='flex flex-col gap-4'>
|
||||||
<div className='flex flex-row gap-2'>
|
<div className='flex flex-row gap-2'>
|
||||||
|
@ -121,7 +116,9 @@ export default function ShowEvent() {
|
||||||
created:
|
created:
|
||||||
</Label>
|
</Label>
|
||||||
<Label>
|
<Label>
|
||||||
{event.created_at ? formatDate(event.created_at) : '-'}
|
{eventData.data.event.created_at
|
||||||
|
? formatDate(eventData.data.event.created_at)
|
||||||
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-row gap-2'>
|
<div className='flex flex-row gap-2'>
|
||||||
|
@ -129,7 +126,9 @@ export default function ShowEvent() {
|
||||||
updated:
|
updated:
|
||||||
</Label>
|
</Label>
|
||||||
<Label>
|
<Label>
|
||||||
{event.updated_at ? formatDate(event.updated_at) : '-'}
|
{eventData.data.event.updated_at
|
||||||
|
? formatDate(eventData.data.event.updated_at)
|
||||||
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -141,23 +140,31 @@ export default function ShowEvent() {
|
||||||
<Label className='text-[var(--color-neutral-300)]'>
|
<Label className='text-[var(--color-neutral-300)]'>
|
||||||
Organiser:
|
Organiser:
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>{organiserName}</Label>
|
<Label size='large'>
|
||||||
|
{eventData.data.event.organizer.name || 'Unknown User'}
|
||||||
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-full w-full'>
|
<div className='h-full w-full'>
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
Description
|
Description
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>{event.description || '-'}</Label>
|
<Label size='large'>
|
||||||
|
{eventData.data.event.description || '-'}
|
||||||
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-full w-full mt-2'>
|
<div className='h-full w-full mt-2'>
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
Participants
|
Participants
|
||||||
</Label>{' '}
|
</Label>{' '}
|
||||||
<div className='grid grid-cols-1 mt-3 sm:max-h-60 sm:grid-cols-2 sm:overflow-y-auto sm:mb-0'>
|
<div className='grid grid-cols-1 mt-3'>
|
||||||
{event.participants?.map((user) => (
|
{eventData.data.event.participants?.map((user) => (
|
||||||
<ParticipantListEntry key={user.user.id} {...user} />
|
<ParticipantListEntry
|
||||||
|
key={user.user.id}
|
||||||
|
{...user}
|
||||||
|
eventID={eventData.data.event.id}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -165,7 +172,8 @@ export default function ShowEvent() {
|
||||||
|
|
||||||
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
||||||
<div className='w-[20%] grid max-sm:w-full'>
|
<div className='w-[20%] grid max-sm:w-full'>
|
||||||
{session.data?.user?.id === event.organizer.id ? (
|
{session.data?.user?.id ===
|
||||||
|
eventData.data.event.organizer.id ? (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={deleteDialogOpen}
|
open={deleteDialogOpen}
|
||||||
onOpenChange={setDeleteDialogOpen}
|
onOpenChange={setDeleteDialogOpen}
|
||||||
|
@ -180,7 +188,8 @@ export default function ShowEvent() {
|
||||||
<DialogTitle>Delete Event</DialogTitle>
|
<DialogTitle>Delete Event</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Are you sure you want to delete the event “
|
Are you sure you want to delete the event “
|
||||||
{event.title}”? This action cannot be undone.
|
{eventData.data.event.title}”? This action
|
||||||
|
cannot be undone.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
|
@ -194,7 +203,7 @@ export default function ShowEvent() {
|
||||||
variant='muted'
|
variant='muted'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
deleteEvent.mutate(
|
deleteEvent.mutate(
|
||||||
{ eventID: event.id },
|
{ eventID: eventData.data.event.id },
|
||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
router.push('/home');
|
router.push('/home');
|
||||||
|
@ -202,7 +211,7 @@ export default function ShowEvent() {
|
||||||
<ToastInner
|
<ToastInner
|
||||||
toastId={t}
|
toastId={t}
|
||||||
title='Event deleted'
|
title='Event deleted'
|
||||||
description={event?.title}
|
description={eventData.data.event.title}
|
||||||
variant='success'
|
variant='success'
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
@ -220,7 +229,8 @@ export default function ShowEvent() {
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div className='w-[20%] grid max-sm:w-full'>
|
<div className='w-[20%] grid max-sm:w-full'>
|
||||||
{session.data?.user?.id === event.organizer.id ? (
|
{session.data?.user?.id ===
|
||||||
|
eventData.data.event.organizer.id ? (
|
||||||
<RedirectButton
|
<RedirectButton
|
||||||
redirectUrl={`/events/edit/${eventID}`}
|
redirectUrl={`/events/edit/${eventID}`}
|
||||||
buttonText='edit'
|
buttonText='edit'
|
||||||
|
|
|
@ -9,16 +9,14 @@ export default async function Page({
|
||||||
}) {
|
}) {
|
||||||
const eventID = (await params).eventID;
|
const eventID = (await params).eventID;
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col items-center justify-center h-screen'>
|
<Card className='w-[80%] max-w-screen p-0 gap-0 max-xl:w-[95%] mx-auto'>
|
||||||
<Card className='w-[80%] max-w-screen p-0 gap-0 max-xl:w-[95%] max-h-[90vh] overflow-auto'>
|
<CardHeader className='p-0 m-0 gap-0' />
|
||||||
<CardHeader className='p-0 m-0 gap-0' />
|
|
||||||
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<EventForm type='edit' eventId={eventID} />
|
<EventForm type='edit' eventId={eventID} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
import { ThemePicker } from '@/components/misc/theme-picker';
|
|
||||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||||
import EventForm from '@/components/forms/event-form';
|
import EventForm from '@/components/forms/event-form';
|
||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
export default function NewEvent() {
|
export default function NewEvent() {
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col items-center justify-center h-screen'>
|
<div className='flex flex-col items-center justify-center h-full'>
|
||||||
<div className='absolute top-4 right-4'>{<ThemePicker />}</div>
|
|
||||||
<Card className='w-[80%] max-w-screen p-0 gap-0 max-xl:w-[95%] max-h-[90vh] overflow-auto'>
|
<Card className='w-[80%] max-w-screen p-0 gap-0 max-xl:w-[95%] max-h-[90vh] overflow-auto'>
|
||||||
<CardHeader className='p-0 m-0 gap-0' />
|
<CardHeader className='p-0 m-0 gap-0' />
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,10 @@ export default function Events() {
|
||||||
const events = eventsData?.data?.events || [];
|
const events = eventsData?.data?.events || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='relative h-screen flex flex-col items-center'>
|
<div
|
||||||
|
className='relative h-full flex flex-col items-center'
|
||||||
|
data-cy='events-page'
|
||||||
|
>
|
||||||
{/* Heading */}
|
{/* Heading */}
|
||||||
<h1 className='text-3xl font-bold mt-8 mb-4 text-center z-10'>
|
<h1 className='text-3xl font-bold mt-8 mb-4 text-center z-10'>
|
||||||
My Events
|
My Events
|
||||||
|
@ -25,7 +28,7 @@ export default function Events() {
|
||||||
|
|
||||||
{/* Scrollable event list */}
|
{/* Scrollable event list */}
|
||||||
<div className='w-full flex justify-center overflow-hidden'>
|
<div className='w-full flex justify-center overflow-hidden'>
|
||||||
<div className='grid gap-8 w-[90%] sm:w-[80%] lg:w-[60%] xl:w-[50%] p-6 overflow-y-auto'>
|
<div className='grid gap-8 not-visited:p-6 overflow-y-auto'>
|
||||||
{events.length > 0 ? (
|
{events.length > 0 ? (
|
||||||
events.map((event) => (
|
events.map((event) => (
|
||||||
<EventListEntry
|
<EventListEntry
|
||||||
|
|
|
@ -4,14 +4,29 @@ import Calendar from '@/components/calendar';
|
||||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const { data } = useGetApiUserMe();
|
const { data, isLoading } = useGetApiUserMe();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='max-h-full'>
|
<div className='grid grid-cols-1 w-full place-items-center'>
|
||||||
<Calendar
|
<div className='w-full sm:w-[90%] mb-4'>
|
||||||
userId={data?.data.user?.id}
|
<h1 className='text-2xl font-bold text-center'>
|
||||||
height='calc(100svh - 50px - (var(--spacing) * 2 * 5))'
|
Welcome, <wbr />
|
||||||
/>
|
<span style={{ whiteSpace: 'nowrap' }}>
|
||||||
|
{isLoading
|
||||||
|
? 'Loading...'
|
||||||
|
: data?.data.user?.first_name ||
|
||||||
|
data?.data.user?.name ||
|
||||||
|
'Unknown User'}{' '}
|
||||||
|
👋
|
||||||
|
</span>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className='w-full sm:w-[90%]'>
|
||||||
|
<Calendar
|
||||||
|
userId={data?.data.user?.id}
|
||||||
|
height='calc(100svh - 115px - (var(--spacing) * 2 * 5))'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
165
src/app/api/blocked_slots/[slotID]/route.ts
Normal file
165
src/app/api/blocked_slots/[slotID]/route.ts
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
import { auth } from '@/auth';
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import {
|
||||||
|
returnZodTypeCheckedResponse,
|
||||||
|
userAuthenticated,
|
||||||
|
} from '@/lib/apiHelpers';
|
||||||
|
import {
|
||||||
|
updateBlockedSlotSchema,
|
||||||
|
BlockedSlotResponseSchema,
|
||||||
|
} from '@/app/api/blocked_slots/validation';
|
||||||
|
import {
|
||||||
|
ErrorResponseSchema,
|
||||||
|
SuccessResponseSchema,
|
||||||
|
ZodErrorResponseSchema,
|
||||||
|
} from '@/app/api/validation';
|
||||||
|
|
||||||
|
export const GET = auth(async function GET(req, { params }) {
|
||||||
|
const authCheck = userAuthenticated(req);
|
||||||
|
if (!authCheck.continue)
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
authCheck.response,
|
||||||
|
authCheck.metadata,
|
||||||
|
);
|
||||||
|
|
||||||
|
const slotID = (await params).slotID;
|
||||||
|
|
||||||
|
const blockedSlot = await prisma.blockedSlot.findUnique({
|
||||||
|
where: {
|
||||||
|
id: slotID,
|
||||||
|
user_id: authCheck.user.id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
start_time: true,
|
||||||
|
end_time: true,
|
||||||
|
reason: true,
|
||||||
|
created_at: true,
|
||||||
|
updated_at: true,
|
||||||
|
is_recurring: true,
|
||||||
|
recurrence_end_date: true,
|
||||||
|
rrule: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!blockedSlot) {
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'Blocked slot not found or not owned by user',
|
||||||
|
},
|
||||||
|
{ status: 404 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
BlockedSlotResponseSchema,
|
||||||
|
{
|
||||||
|
blocked_slot: blockedSlot,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const PATCH = auth(async function PATCH(req, { params }) {
|
||||||
|
const authCheck = userAuthenticated(req);
|
||||||
|
if (!authCheck.continue)
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
authCheck.response,
|
||||||
|
authCheck.metadata,
|
||||||
|
);
|
||||||
|
|
||||||
|
const slotID = (await params).slotID;
|
||||||
|
|
||||||
|
const dataRaw = await req.json();
|
||||||
|
const data = await updateBlockedSlotSchema.safeParseAsync(dataRaw);
|
||||||
|
if (!data.success)
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ZodErrorResponseSchema,
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'Invalid request data',
|
||||||
|
errors: data.error.issues,
|
||||||
|
},
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
|
||||||
|
const blockedSlot = await prisma.blockedSlot.update({
|
||||||
|
where: {
|
||||||
|
id: slotID,
|
||||||
|
user_id: authCheck.user.id,
|
||||||
|
},
|
||||||
|
data: data.data,
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
start_time: true,
|
||||||
|
end_time: true,
|
||||||
|
reason: true,
|
||||||
|
created_at: true,
|
||||||
|
updated_at: true,
|
||||||
|
is_recurring: true,
|
||||||
|
recurrence_end_date: true,
|
||||||
|
rrule: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!blockedSlot) {
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'Blocked slot not found or not owned by user',
|
||||||
|
},
|
||||||
|
{ status: 404 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
BlockedSlotResponseSchema,
|
||||||
|
{ success: true, blocked_slot: blockedSlot },
|
||||||
|
{ status: 200 },
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const DELETE = auth(async function DELETE(req, { params }) {
|
||||||
|
const authCheck = userAuthenticated(req);
|
||||||
|
if (!authCheck.continue)
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
authCheck.response,
|
||||||
|
authCheck.metadata,
|
||||||
|
);
|
||||||
|
|
||||||
|
const slotID = (await params).slotID;
|
||||||
|
|
||||||
|
const deletedSlot = await prisma.blockedSlot.delete({
|
||||||
|
where: {
|
||||||
|
id: slotID,
|
||||||
|
user_id: authCheck.user.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!deletedSlot) {
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'Blocked slot not found or not owned by user',
|
||||||
|
},
|
||||||
|
{ status: 404 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
SuccessResponseSchema,
|
||||||
|
{ success: true },
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
90
src/app/api/blocked_slots/[slotID]/swagger.ts
Normal file
90
src/app/api/blocked_slots/[slotID]/swagger.ts
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
import {
|
||||||
|
updateBlockedSlotSchema,
|
||||||
|
BlockedSlotResponseSchema,
|
||||||
|
} from '@/app/api/blocked_slots/validation';
|
||||||
|
import {
|
||||||
|
notAuthenticatedResponse,
|
||||||
|
serverReturnedDataValidationErrorResponse,
|
||||||
|
userNotFoundResponse,
|
||||||
|
invalidRequestDataResponse,
|
||||||
|
} from '@/lib/defaultApiResponses';
|
||||||
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
|
import { SlotIdParamSchema } from '@/app/api/validation';
|
||||||
|
import zod from 'zod/v4';
|
||||||
|
|
||||||
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
|
registry.registerPath({
|
||||||
|
method: 'get',
|
||||||
|
path: '/api/blocked_slots/{slotID}',
|
||||||
|
request: {
|
||||||
|
params: zod.object({
|
||||||
|
slotID: SlotIdParamSchema,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Blocked slot retrieved successfully',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: BlockedSlotResponseSchema,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...userNotFoundResponse,
|
||||||
|
...notAuthenticatedResponse,
|
||||||
|
...serverReturnedDataValidationErrorResponse,
|
||||||
|
},
|
||||||
|
tags: ['Blocked Slots'],
|
||||||
|
});
|
||||||
|
|
||||||
|
registry.registerPath({
|
||||||
|
method: 'delete',
|
||||||
|
path: '/api/blocked_slots/{slotID}',
|
||||||
|
request: {
|
||||||
|
params: zod.object({
|
||||||
|
slotID: SlotIdParamSchema,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
204: {
|
||||||
|
description: 'Blocked slot deleted successfully',
|
||||||
|
},
|
||||||
|
...userNotFoundResponse,
|
||||||
|
...notAuthenticatedResponse,
|
||||||
|
...serverReturnedDataValidationErrorResponse,
|
||||||
|
},
|
||||||
|
tags: ['Blocked Slots'],
|
||||||
|
});
|
||||||
|
|
||||||
|
registry.registerPath({
|
||||||
|
method: 'patch',
|
||||||
|
path: '/api/blocked_slots/{slotID}',
|
||||||
|
request: {
|
||||||
|
params: zod.object({
|
||||||
|
slotID: SlotIdParamSchema,
|
||||||
|
}),
|
||||||
|
body: {
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: updateBlockedSlotSchema,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Blocked slot updated successfully',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: BlockedSlotResponseSchema,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...userNotFoundResponse,
|
||||||
|
...notAuthenticatedResponse,
|
||||||
|
...serverReturnedDataValidationErrorResponse,
|
||||||
|
...invalidRequestDataResponse,
|
||||||
|
},
|
||||||
|
tags: ['Blocked Slots'],
|
||||||
|
});
|
||||||
|
}
|
127
src/app/api/blocked_slots/route.ts
Normal file
127
src/app/api/blocked_slots/route.ts
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
import { auth } from '@/auth';
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import {
|
||||||
|
returnZodTypeCheckedResponse,
|
||||||
|
userAuthenticated,
|
||||||
|
} from '@/lib/apiHelpers';
|
||||||
|
import {
|
||||||
|
blockedSlotsQuerySchema,
|
||||||
|
BlockedSlotsResponseSchema,
|
||||||
|
BlockedSlotsSchema,
|
||||||
|
createBlockedSlotSchema,
|
||||||
|
} from './validation';
|
||||||
|
import {
|
||||||
|
ErrorResponseSchema,
|
||||||
|
ZodErrorResponseSchema,
|
||||||
|
} from '@/app/api/validation';
|
||||||
|
|
||||||
|
export const GET = auth(async function GET(req) {
|
||||||
|
const authCheck = userAuthenticated(req);
|
||||||
|
if (!authCheck.continue)
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
authCheck.response,
|
||||||
|
authCheck.metadata,
|
||||||
|
);
|
||||||
|
|
||||||
|
const dataRaw: Record<string, string | string[]> = {};
|
||||||
|
for (const [key, value] of req.nextUrl.searchParams.entries()) {
|
||||||
|
if (key.endsWith('[]')) {
|
||||||
|
const cleanKey = key.slice(0, -2);
|
||||||
|
if (!dataRaw[cleanKey]) {
|
||||||
|
dataRaw[cleanKey] = [];
|
||||||
|
}
|
||||||
|
if (Array.isArray(dataRaw[cleanKey])) {
|
||||||
|
(dataRaw[cleanKey] as string[]).push(value);
|
||||||
|
} else {
|
||||||
|
dataRaw[cleanKey] = [dataRaw[cleanKey] as string, value];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dataRaw[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const data = await blockedSlotsQuerySchema.safeParseAsync(dataRaw);
|
||||||
|
if (!data.success)
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ZodErrorResponseSchema,
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'Invalid request data',
|
||||||
|
errors: data.error.issues,
|
||||||
|
},
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
const { start, end } = data.data;
|
||||||
|
|
||||||
|
const requestUserId = authCheck.user.id;
|
||||||
|
|
||||||
|
const blockedSlots = await prisma.blockedSlot.findMany({
|
||||||
|
where: {
|
||||||
|
user_id: requestUserId,
|
||||||
|
start_time: { gte: start },
|
||||||
|
end_time: { lte: end },
|
||||||
|
},
|
||||||
|
orderBy: { start_time: 'asc' },
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
start_time: true,
|
||||||
|
end_time: true,
|
||||||
|
reason: true,
|
||||||
|
created_at: true,
|
||||||
|
updated_at: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
BlockedSlotsResponseSchema,
|
||||||
|
{ success: true, blocked_slots: blockedSlots },
|
||||||
|
{ status: 200 },
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const POST = auth(async function POST(req) {
|
||||||
|
const authCheck = userAuthenticated(req);
|
||||||
|
if (!authCheck.continue)
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
authCheck.response,
|
||||||
|
authCheck.metadata,
|
||||||
|
);
|
||||||
|
|
||||||
|
const dataRaw = await req.json();
|
||||||
|
const data = await createBlockedSlotSchema.safeParseAsync(dataRaw);
|
||||||
|
if (!data.success)
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ZodErrorResponseSchema,
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'Invalid request data',
|
||||||
|
errors: data.error.issues,
|
||||||
|
},
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
|
||||||
|
const requestUserId = authCheck.user.id;
|
||||||
|
|
||||||
|
if (!requestUserId) {
|
||||||
|
return returnZodTypeCheckedResponse(
|
||||||
|
ErrorResponseSchema,
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'User not authenticated',
|
||||||
|
},
|
||||||
|
{ status: 401 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const blockedSlot = await prisma.blockedSlot.create({
|
||||||
|
data: {
|
||||||
|
...data.data,
|
||||||
|
user_id: requestUserId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return returnZodTypeCheckedResponse(BlockedSlotsSchema, blockedSlot, {
|
||||||
|
status: 201,
|
||||||
|
});
|
||||||
|
});
|
66
src/app/api/blocked_slots/swagger.ts
Normal file
66
src/app/api/blocked_slots/swagger.ts
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
import {
|
||||||
|
BlockedSlotResponseSchema,
|
||||||
|
BlockedSlotsResponseSchema,
|
||||||
|
blockedSlotsQuerySchema,
|
||||||
|
createBlockedSlotSchema,
|
||||||
|
} from './validation';
|
||||||
|
import {
|
||||||
|
invalidRequestDataResponse,
|
||||||
|
notAuthenticatedResponse,
|
||||||
|
serverReturnedDataValidationErrorResponse,
|
||||||
|
userNotFoundResponse,
|
||||||
|
} from '@/lib/defaultApiResponses';
|
||||||
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
|
|
||||||
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
|
registry.registerPath({
|
||||||
|
method: 'get',
|
||||||
|
path: '/api/blocked_slots',
|
||||||
|
request: {
|
||||||
|
query: blockedSlotsQuerySchema,
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Blocked slots retrieved successfully.',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: BlockedSlotsResponseSchema,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...notAuthenticatedResponse,
|
||||||
|
...userNotFoundResponse,
|
||||||
|
...serverReturnedDataValidationErrorResponse,
|
||||||
|
},
|
||||||
|
tags: ['Blocked Slots'],
|
||||||
|
});
|
||||||
|
|
||||||
|
registry.registerPath({
|
||||||
|
method: 'post',
|
||||||
|
path: '/api/blocked_slots',
|
||||||
|
request: {
|
||||||
|
body: {
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: createBlockedSlotSchema,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
201: {
|
||||||
|
description: 'Blocked slot created successfully.',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: BlockedSlotResponseSchema,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...notAuthenticatedResponse,
|
||||||
|
...userNotFoundResponse,
|
||||||
|
...serverReturnedDataValidationErrorResponse,
|
||||||
|
...invalidRequestDataResponse,
|
||||||
|
},
|
||||||
|
tags: ['Blocked Slots'],
|
||||||
|
});
|
||||||
|
}
|
78
src/app/api/blocked_slots/validation.ts
Normal file
78
src/app/api/blocked_slots/validation.ts
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||||
|
import zod from 'zod/v4';
|
||||||
|
import {
|
||||||
|
eventEndTimeSchema,
|
||||||
|
eventStartTimeSchema,
|
||||||
|
} from '@/app/api/event/validation';
|
||||||
|
|
||||||
|
extendZodWithOpenApi(zod);
|
||||||
|
|
||||||
|
export const blockedSlotsQuerySchema = zod.object({
|
||||||
|
start: eventStartTimeSchema.optional(),
|
||||||
|
end: eventEndTimeSchema.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const blockedSlotRecurrenceEndDateSchema = zod.iso
|
||||||
|
.datetime()
|
||||||
|
.or(zod.date().transform((date) => date.toISOString()));
|
||||||
|
|
||||||
|
export const BlockedSlotsSchema = zod
|
||||||
|
.object({
|
||||||
|
start_time: eventStartTimeSchema,
|
||||||
|
end_time: eventEndTimeSchema,
|
||||||
|
id: zod.string(),
|
||||||
|
reason: zod.string().nullish(),
|
||||||
|
created_at: zod.date(),
|
||||||
|
updated_at: zod.date(),
|
||||||
|
})
|
||||||
|
.openapi('BlockedSlotsSchema', {
|
||||||
|
description: 'Blocked time slot in the user calendar',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const BlockedSlotsResponseSchema = zod.object({
|
||||||
|
success: zod.boolean().default(true),
|
||||||
|
blocked_slots: zod.array(BlockedSlotsSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const BlockedSlotResponseSchema = zod.object({
|
||||||
|
success: zod.boolean().default(true),
|
||||||
|
blocked_slot: BlockedSlotsSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const createBlockedSlotSchema = zod
|
||||||
|
.object({
|
||||||
|
start_time: eventStartTimeSchema,
|
||||||
|
end_time: eventEndTimeSchema,
|
||||||
|
reason: zod.string().nullish(),
|
||||||
|
})
|
||||||
|
.refine(
|
||||||
|
(data) => {
|
||||||
|
return new Date(data.start_time) < new Date(data.end_time);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: 'Start time must be before end time',
|
||||||
|
path: ['end_time'],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const createBlockedSlotClientSchema = zod
|
||||||
|
.object({
|
||||||
|
start_time: zod.iso.datetime({ local: true }),
|
||||||
|
end_time: zod.iso.datetime({ local: true }),
|
||||||
|
reason: zod.string().nullish(),
|
||||||
|
})
|
||||||
|
.refine(
|
||||||
|
(data) => {
|
||||||
|
return new Date(data.start_time) < new Date(data.end_time);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: 'Start time must be before end time',
|
||||||
|
path: ['end_time'],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const updateBlockedSlotSchema = zod.object({
|
||||||
|
start_time: eventStartTimeSchema.optional(),
|
||||||
|
end_time: eventEndTimeSchema.optional(),
|
||||||
|
reason: zod.string().optional(),
|
||||||
|
});
|
|
@ -15,7 +15,7 @@ import {
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
import { z } from 'zod/v4';
|
import { z } from 'zod/v4';
|
||||||
|
|
||||||
export const GET = auth(async function GET(req, { params }) {
|
export const GET = auth(async function GET(req) {
|
||||||
const authCheck = userAuthenticated(req);
|
const authCheck = userAuthenticated(req);
|
||||||
if (!authCheck.continue)
|
if (!authCheck.continue)
|
||||||
return returnZodTypeCheckedResponse(
|
return returnZodTypeCheckedResponse(
|
||||||
|
@ -24,7 +24,22 @@ export const GET = auth(async function GET(req, { params }) {
|
||||||
authCheck.metadata,
|
authCheck.metadata,
|
||||||
);
|
);
|
||||||
|
|
||||||
const dataRaw = Object.fromEntries(new URL(req.url).searchParams);
|
const dataRaw: Record<string, string | string[]> = {};
|
||||||
|
for (const [key, value] of req.nextUrl.searchParams.entries()) {
|
||||||
|
if (key.endsWith('[]')) {
|
||||||
|
const cleanKey = key.slice(0, -2);
|
||||||
|
if (!dataRaw[cleanKey]) {
|
||||||
|
dataRaw[cleanKey] = [];
|
||||||
|
}
|
||||||
|
if (Array.isArray(dataRaw[cleanKey])) {
|
||||||
|
(dataRaw[cleanKey] as string[]).push(value);
|
||||||
|
} else {
|
||||||
|
dataRaw[cleanKey] = [dataRaw[cleanKey] as string, value];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dataRaw[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
const data = await userCalendarQuerySchema.safeParseAsync(dataRaw);
|
const data = await userCalendarQuerySchema.safeParseAsync(dataRaw);
|
||||||
if (!data.success)
|
if (!data.success)
|
||||||
return returnZodTypeCheckedResponse(
|
return returnZodTypeCheckedResponse(
|
||||||
|
@ -36,15 +51,15 @@ export const GET = auth(async function GET(req, { params }) {
|
||||||
},
|
},
|
||||||
{ status: 400 },
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
const { end, start } = data.data;
|
const { end, start, userIds } = data.data;
|
||||||
|
|
||||||
const requestUserId = authCheck.user.id;
|
const requestUserId = authCheck.user.id;
|
||||||
|
|
||||||
const requestedUserId = (await params).user;
|
const requestedUser = await prisma.user.findMany({
|
||||||
|
|
||||||
const requestedUser = await prisma.user.findFirst({
|
|
||||||
where: {
|
where: {
|
||||||
id: requestedUserId,
|
id: {
|
||||||
|
in: userIds,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
meetingParts: {
|
meetingParts: {
|
||||||
|
@ -57,6 +72,9 @@ export const GET = auth(async function GET(req, { params }) {
|
||||||
gte: start,
|
gte: start,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
status: {
|
||||||
|
not: 'DECLINED',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
meeting: {
|
meeting: {
|
||||||
|
@ -64,6 +82,7 @@ export const GET = auth(async function GET(req, { params }) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
|
user_id: true,
|
||||||
meeting: {
|
meeting: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
@ -136,6 +155,7 @@ export const GET = auth(async function GET(req, { params }) {
|
||||||
start_time: 'asc',
|
start_time: 'asc',
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
|
user_id: true,
|
||||||
id: true,
|
id: true,
|
||||||
reason: true,
|
reason: true,
|
||||||
start_time: true,
|
start_time: true,
|
||||||
|
@ -153,46 +173,64 @@ export const GET = auth(async function GET(req, { params }) {
|
||||||
if (!requestedUser)
|
if (!requestedUser)
|
||||||
return returnZodTypeCheckedResponse(
|
return returnZodTypeCheckedResponse(
|
||||||
ErrorResponseSchema,
|
ErrorResponseSchema,
|
||||||
{ success: false, message: 'User not found' },
|
{ success: false, message: 'User/s not found' },
|
||||||
{ status: 404 },
|
{ status: 404 },
|
||||||
);
|
);
|
||||||
|
|
||||||
const calendar: z.input<typeof UserCalendarSchema> = [];
|
const calendar: z.input<typeof UserCalendarSchema> = [];
|
||||||
|
|
||||||
for (const event of requestedUser.meetingParts) {
|
for (const event of requestedUser.map((r) => r.meetingParts).flat()) {
|
||||||
if (
|
if (
|
||||||
event.meeting.participants.some((p) => p.user.id === requestUserId) ||
|
event.meeting.participants.some((p) => p.user.id === requestUserId) ||
|
||||||
event.meeting.organizer_id === requestUserId
|
event.meeting.organizer_id === requestUserId
|
||||||
) {
|
) {
|
||||||
calendar.push({ ...event.meeting, type: 'event' });
|
calendar.push({
|
||||||
|
...event.meeting,
|
||||||
|
type: 'event',
|
||||||
|
users: event.meeting.participants
|
||||||
|
.map((p) => p.user.id)
|
||||||
|
.filter((id) => userIds.includes(id)),
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
calendar.push({
|
calendar.push({
|
||||||
id: event.meeting.id,
|
id: event.meeting.id,
|
||||||
start_time: event.meeting.start_time,
|
start_time: event.meeting.start_time,
|
||||||
end_time: event.meeting.end_time,
|
end_time: event.meeting.end_time,
|
||||||
type: 'blocked_private',
|
type: 'blocked_private',
|
||||||
|
users: event.meeting.participants
|
||||||
|
.map((p) => p.user.id)
|
||||||
|
.filter((id) => userIds.includes(id)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const event of requestedUser.meetingsOrg) {
|
for (const event of requestedUser.map((r) => r.meetingsOrg).flat()) {
|
||||||
if (
|
if (
|
||||||
event.participants.some((p) => p.user.id === requestUserId) ||
|
event.participants.some((p) => p.user.id === requestUserId) ||
|
||||||
event.organizer_id === requestUserId
|
event.organizer_id === requestUserId
|
||||||
) {
|
) {
|
||||||
calendar.push({ ...event, type: 'event' });
|
calendar.push({
|
||||||
|
...event,
|
||||||
|
type: 'event',
|
||||||
|
users: event.participants
|
||||||
|
.map((p) => p.user.id)
|
||||||
|
.filter((id) => userIds.includes(id)),
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
calendar.push({
|
calendar.push({
|
||||||
id: event.id,
|
id: event.id,
|
||||||
start_time: event.start_time,
|
start_time: event.start_time,
|
||||||
end_time: event.end_time,
|
end_time: event.end_time,
|
||||||
type: 'blocked_private',
|
type: 'blocked_private',
|
||||||
|
users: event.participants
|
||||||
|
.map((p) => p.user.id)
|
||||||
|
.filter((id) => userIds.includes(id)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const slot of requestedUser.blockedSlots) {
|
for (const slot of requestedUser.map((r) => r.blockedSlots).flat()) {
|
||||||
if (requestUserId === requestedUserId) {
|
if (requestUserId === userIds[0] && userIds.length === 1) {
|
||||||
calendar.push({
|
calendar.push({
|
||||||
start_time: slot.start_time,
|
start_time: slot.start_time,
|
||||||
end_time: slot.end_time,
|
end_time: slot.end_time,
|
||||||
|
@ -204,6 +242,7 @@ export const GET = auth(async function GET(req, { params }) {
|
||||||
created_at: slot.created_at,
|
created_at: slot.created_at,
|
||||||
updated_at: slot.updated_at,
|
updated_at: slot.updated_at,
|
||||||
type: 'blocked_owned',
|
type: 'blocked_owned',
|
||||||
|
users: [requestUserId],
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
calendar.push({
|
calendar.push({
|
||||||
|
@ -211,6 +250,7 @@ export const GET = auth(async function GET(req, { params }) {
|
||||||
end_time: slot.end_time,
|
end_time: slot.end_time,
|
||||||
id: slot.id,
|
id: slot.id,
|
||||||
type: 'blocked_private',
|
type: 'blocked_private',
|
||||||
|
users: [slot.user_id],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,17 +7,12 @@ import {
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
|
||||||
import { UserIdParamSchema } from '@/app/api/validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
path: '/api/user/{user}/calendar',
|
path: '/api/calendar',
|
||||||
request: {
|
request: {
|
||||||
params: zod.object({
|
|
||||||
user: UserIdParamSchema,
|
|
||||||
}),
|
|
||||||
query: userCalendarQuerySchema,
|
query: userCalendarQuerySchema,
|
||||||
},
|
},
|
||||||
responses: {
|
responses: {
|
||||||
|
@ -32,6 +27,6 @@ export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
...notAuthenticatedResponse,
|
...notAuthenticatedResponse,
|
||||||
...userNotFoundResponse,
|
...userNotFoundResponse,
|
||||||
},
|
},
|
||||||
tags: ['User'],
|
tags: ['Calendar'],
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -14,6 +14,8 @@ export const BlockedSlotSchema = zod
|
||||||
end_time: eventEndTimeSchema,
|
end_time: eventEndTimeSchema,
|
||||||
type: zod.literal('blocked_private'),
|
type: zod.literal('blocked_private'),
|
||||||
id: zod.string(),
|
id: zod.string(),
|
||||||
|
users: zod.string().array(),
|
||||||
|
user_id: zod.string().optional(),
|
||||||
})
|
})
|
||||||
.openapi('BlockedSlotSchema', {
|
.openapi('BlockedSlotSchema', {
|
||||||
description: 'Blocked time slot in the user calendar',
|
description: 'Blocked time slot in the user calendar',
|
||||||
|
@ -31,17 +33,22 @@ export const OwnedBlockedSlotSchema = zod
|
||||||
created_at: zod.date().nullish(),
|
created_at: zod.date().nullish(),
|
||||||
updated_at: zod.date().nullish(),
|
updated_at: zod.date().nullish(),
|
||||||
type: zod.literal('blocked_owned'),
|
type: zod.literal('blocked_owned'),
|
||||||
|
users: zod.string().array(),
|
||||||
|
user_id: zod.string().optional(),
|
||||||
})
|
})
|
||||||
.openapi('OwnedBlockedSlotSchema', {
|
.openapi('OwnedBlockedSlotSchema', {
|
||||||
description: 'Blocked slot owned by the user',
|
description: 'Blocked slot owned by the user',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const VisibleSlotSchema = EventSchema.omit({
|
export const VisibleSlotSchema = EventSchema.omit({
|
||||||
organizer: true,
|
|
||||||
participants: true,
|
participants: true,
|
||||||
|
organizer: true,
|
||||||
})
|
})
|
||||||
.extend({
|
.extend({
|
||||||
type: zod.literal('event'),
|
type: zod.literal('event'),
|
||||||
|
users: zod.string().array(),
|
||||||
|
user_id: zod.string().optional(),
|
||||||
|
organizer_id: zod.string().optional(),
|
||||||
})
|
})
|
||||||
.openapi('VisibleSlotSchema', {
|
.openapi('VisibleSlotSchema', {
|
||||||
description: 'Visible time slot in the user calendar',
|
description: 'Visible time slot in the user calendar',
|
||||||
|
@ -86,6 +93,7 @@ export const userCalendarQuerySchema = zod
|
||||||
);
|
);
|
||||||
return endOfWeek;
|
return endOfWeek;
|
||||||
}),
|
}),
|
||||||
|
userIds: zod.string().array(),
|
||||||
})
|
})
|
||||||
.openapi('UserCalendarQuerySchema', {
|
.openapi('UserCalendarQuerySchema', {
|
||||||
description: 'Query parameters for filtering the user calendar',
|
description: 'Query parameters for filtering the user calendar',
|
8
src/app/api/logout/route.ts
Normal file
8
src/app/api/logout/route.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { signOut } from '@/auth';
|
||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export const GET = async () => {
|
||||||
|
await signOut();
|
||||||
|
|
||||||
|
return NextResponse.redirect('/login');
|
||||||
|
};
|
|
@ -19,7 +19,7 @@ export const GET = auth(async function GET(req) {
|
||||||
authCheck.metadata,
|
authCheck.metadata,
|
||||||
);
|
);
|
||||||
|
|
||||||
const dataRaw = Object.fromEntries(new URL(req.url).searchParams);
|
const dataRaw = Object.fromEntries(req.nextUrl.searchParams);
|
||||||
const data = await searchUserSchema.safeParseAsync(dataRaw);
|
const data = await searchUserSchema.safeParseAsync(dataRaw);
|
||||||
if (!data.success)
|
if (!data.success)
|
||||||
return returnZodTypeCheckedResponse(
|
return returnZodTypeCheckedResponse(
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
import {
|
import {
|
||||||
|
emailSchema,
|
||||||
firstNameSchema,
|
firstNameSchema,
|
||||||
lastNameSchema,
|
lastNameSchema,
|
||||||
newUserEmailServerSchema,
|
newUserEmailServerSchema,
|
||||||
newUserNameServerSchema,
|
newUserNameServerSchema,
|
||||||
passwordSchema,
|
passwordSchema,
|
||||||
timezoneSchema,
|
timezoneSchema,
|
||||||
|
userNameSchema,
|
||||||
} from '@/app/api/user/validation';
|
} from '@/app/api/user/validation';
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
@ -22,6 +24,15 @@ export const updateUserServerSchema = zod.object({
|
||||||
timezone: timezoneSchema.optional(),
|
timezone: timezoneSchema.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const updateUserClientSchema = zod.object({
|
||||||
|
name: userNameSchema.optional(),
|
||||||
|
first_name: firstNameSchema.optional(),
|
||||||
|
last_name: lastNameSchema.optional(),
|
||||||
|
email: emailSchema.optional(),
|
||||||
|
image: zod.url().optional(),
|
||||||
|
timezone: timezoneSchema.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
export const updateUserPasswordServerSchema = zod
|
export const updateUserPasswordServerSchema = zod
|
||||||
.object({
|
.object({
|
||||||
current_password: zod.string().min(1, 'Current password is required'),
|
current_password: zod.string().min(1, 'Current password is required'),
|
||||||
|
|
|
@ -85,3 +85,14 @@ export const EventIdParamSchema = registry.registerParameter(
|
||||||
example: '67890',
|
example: '67890',
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const SlotIdParamSchema = registry.registerParameter(
|
||||||
|
'SlotIdParam',
|
||||||
|
zod.string().openapi({
|
||||||
|
param: {
|
||||||
|
name: 'slotID',
|
||||||
|
in: 'path',
|
||||||
|
},
|
||||||
|
example: 'abcde12345',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
|
@ -42,7 +42,9 @@ export default async function LoginPage() {
|
||||||
<CardContent className='gap-6 flex flex-col items-center'>
|
<CardContent className='gap-6 flex flex-col items-center'>
|
||||||
<LoginForm />
|
<LoginForm />
|
||||||
|
|
||||||
<Separator className='h-[1px] rounded-sm w-[60%] bg-border' />
|
{providerMap.length > 0 && !process.env.DISABLE_PASSWORD_LOGIN ? (
|
||||||
|
<Separator className='h-[1px] rounded-sm w-[60%] bg-border' />
|
||||||
|
) : null}
|
||||||
|
|
||||||
{providerMap.map((provider) => (
|
{providerMap.map((provider) => (
|
||||||
<SSOLogin
|
<SSOLogin
|
||||||
|
@ -61,10 +63,11 @@ export default async function LoginPage() {
|
||||||
</HoverCardTrigger>
|
</HoverCardTrigger>
|
||||||
<HoverCardContent className='flex items-center justify-center'>
|
<HoverCardContent className='flex items-center justify-center'>
|
||||||
<Image
|
<Image
|
||||||
src='https://img1.wikia.nocookie.net/__cb20140808110649/clubpenguin/images/a/a1/Action_Dance_Light_Blue.gif'
|
src='https://i.gifer.com/22CU.gif'
|
||||||
width='150'
|
width='150'
|
||||||
height='150'
|
height='150'
|
||||||
alt='dancing penguin'
|
alt='cat gif'
|
||||||
|
unoptimized
|
||||||
></Image>
|
></Image>
|
||||||
</HoverCardContent>
|
</HoverCardContent>
|
||||||
</HoverCard>
|
</HoverCard>
|
||||||
|
|
28
src/app/not-found.tsx
Normal file
28
src/app/not-found.tsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
|
||||||
|
export default function NotFound() {
|
||||||
|
return (
|
||||||
|
<div className='min-h-screen flex items-center justify-center bg-background'>
|
||||||
|
<div className='text-center space-y-6 px-4'>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<h1 className='text-9xl font-bold text-primary'>404</h1>
|
||||||
|
<h2 className='text-3xl font-semibold text-text'>Page Not Found</h2>
|
||||||
|
<p className='text-lg text-text-muted max-w-md mx-auto'>
|
||||||
|
Sorry, we couldn't find the page you're looking for. It
|
||||||
|
might have been moved, deleted, or doesn't exist.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex flex-col sm:flex-row gap-4 justify-center items-center'>
|
||||||
|
<Button asChild className='px-8'>
|
||||||
|
<Link href='/'>Go Home</Link>
|
||||||
|
</Button>
|
||||||
|
<Button variant='outline_primary' asChild className='px-8'>
|
||||||
|
<Link href='/events'>Browse Events</Link>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,482 +1,5 @@
|
||||||
import { Button } from '@/components/ui/button';
|
import SettingsPage from '@/components/settings/settings-page';
|
||||||
import {
|
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardFooter,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from '@/components/ui/card';
|
|
||||||
import { Input } from '@/components/ui/input';
|
|
||||||
import { Label } from '@/components/ui/label';
|
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
||||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
|
||||||
import { Switch } from '@/components/ui/switch';
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from '@/components/ui/select';
|
|
||||||
|
|
||||||
export default function SettingsPage() {
|
export default function Page() {
|
||||||
return (
|
return <SettingsPage />;
|
||||||
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
|
||||||
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full h-auto max-h-[calc(100vh-2rem)] flex flex-col'>
|
|
||||||
<Tabs
|
|
||||||
defaultValue='general'
|
|
||||||
className='w-full flex flex-col flex-grow min-h-0'
|
|
||||||
>
|
|
||||||
<TabsList className='grid w-full grid-cols-3 sm:grid-cols-5'>
|
|
||||||
<TabsTrigger value='general'>Account</TabsTrigger>
|
|
||||||
<TabsTrigger value='notifications'>Notifications</TabsTrigger>
|
|
||||||
<TabsTrigger value='calendarAvailability'>Calendar</TabsTrigger>
|
|
||||||
<TabsTrigger value='sharingPrivacy'>Privacy</TabsTrigger>
|
|
||||||
<TabsTrigger value='appearance'>Appearance</TabsTrigger>
|
|
||||||
</TabsList>
|
|
||||||
|
|
||||||
<TabsContent value='general' className='flex-grow overflow-hidden'>
|
|
||||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
|
||||||
<ScrollableSettingsWrapper>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>Account Settings</CardTitle>
|
|
||||||
<CardDescription>
|
|
||||||
Manage your account details and preferences.
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className='space-y-6'>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='displayName'>Display Name</Label>
|
|
||||||
<Input id='displayName' placeholder='Your Name' />
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='email'>Email Address</Label>
|
|
||||||
<Input
|
|
||||||
id='email'
|
|
||||||
type='email'
|
|
||||||
placeholder='your.email@example.com'
|
|
||||||
readOnly
|
|
||||||
value='user-email@example.com'
|
|
||||||
/>
|
|
||||||
<p className='text-sm text-muted-foreground'>
|
|
||||||
Email is managed by your SSO provider.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='profilePicture'>Profile Picture</Label>
|
|
||||||
<Input id='profilePicture' type='file' />
|
|
||||||
<p className='text-sm text-muted-foreground'>
|
|
||||||
Upload a new profile picture.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='timezone'>Timezone</Label>
|
|
||||||
<Input id='displayName' placeholder='Europe/Berlin' />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='language'>Language</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='language'>
|
|
||||||
<SelectValue placeholder='Select language' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='en'>English</SelectItem>
|
|
||||||
<SelectItem value='de'>German</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='pt-4'>
|
|
||||||
<Button variant='secondary'>Delete Account</Button>
|
|
||||||
<p className='text-sm text-muted-foreground pt-1'>
|
|
||||||
Permanently delete your account and all associated data.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</ScrollableSettingsWrapper>
|
|
||||||
<CardFooter className='mt-auto border-t pt-4 flex justify-between'>
|
|
||||||
<Button variant='secondary'>Exit</Button>
|
|
||||||
<Button>Save Changes</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent
|
|
||||||
value='notifications'
|
|
||||||
className='flex-grow overflow-hidden'
|
|
||||||
>
|
|
||||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
|
||||||
<ScrollableSettingsWrapper>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>Notification Preferences</CardTitle>
|
|
||||||
<CardDescription>
|
|
||||||
Choose how you want to be notified.
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className='space-y-6'>
|
|
||||||
<div className='flex items-center justify-between space-x-2 p-3 rounded-md border'>
|
|
||||||
<Label
|
|
||||||
htmlFor='masterEmailNotifications'
|
|
||||||
className='font-normal'
|
|
||||||
>
|
|
||||||
Enable All Email Notifications
|
|
||||||
</Label>
|
|
||||||
<Switch id='masterEmailNotifications' />
|
|
||||||
</div>
|
|
||||||
<div className='space-y-4 pl-2 border-l-2 ml-2'>
|
|
||||||
<div className='flex items-center justify-between space-x-2'>
|
|
||||||
<Label
|
|
||||||
htmlFor='newMeetingBookings'
|
|
||||||
className='font-normal'
|
|
||||||
>
|
|
||||||
New Meeting Bookings
|
|
||||||
</Label>
|
|
||||||
<Switch id='newMeetingBookings' />
|
|
||||||
</div>
|
|
||||||
<div className='flex items-center justify-between space-x-2'>
|
|
||||||
<Label
|
|
||||||
htmlFor='meetingConfirmations'
|
|
||||||
className='font-normal'
|
|
||||||
>
|
|
||||||
Meeting Confirmations/Cancellations
|
|
||||||
</Label>
|
|
||||||
<Switch id='meetingConfirmations' />
|
|
||||||
</div>
|
|
||||||
<div className='flex items-center justify-between space-x-2'>
|
|
||||||
<Label
|
|
||||||
htmlFor='enableMeetingReminders'
|
|
||||||
className='font-normal'
|
|
||||||
>
|
|
||||||
Meeting Reminders
|
|
||||||
</Label>
|
|
||||||
<Switch id='enableMeetingReminders' />
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2 pl-6'>
|
|
||||||
<Label htmlFor='remindBefore'>Remind me before</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='remindBefore'>
|
|
||||||
<SelectValue placeholder='Select reminder time' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='15m'>15 minutes</SelectItem>
|
|
||||||
<SelectItem value='30m'>30 minutes</SelectItem>
|
|
||||||
<SelectItem value='1h'>1 hour</SelectItem>
|
|
||||||
<SelectItem value='1d'>1 day</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='flex items-center justify-between space-x-2'>
|
|
||||||
<Label htmlFor='friendRequests' className='font-normal'>
|
|
||||||
Friend Requests
|
|
||||||
</Label>
|
|
||||||
<Switch id='friendRequests' />
|
|
||||||
</div>
|
|
||||||
<div className='flex items-center justify-between space-x-2'>
|
|
||||||
<Label htmlFor='groupUpdates' className='font-normal'>
|
|
||||||
Group Invitations/Updates
|
|
||||||
</Label>
|
|
||||||
<Switch id='groupUpdates' />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</ScrollableSettingsWrapper>
|
|
||||||
<CardFooter className='mt-auto border-t pt-4 flex justify-between'>
|
|
||||||
<Button variant='secondary'>Exit</Button>
|
|
||||||
<Button>Save Changes</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent
|
|
||||||
value='calendarAvailability'
|
|
||||||
className='flex-grow overflow-hidden'
|
|
||||||
>
|
|
||||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
|
||||||
<ScrollableSettingsWrapper>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>Calendar & Availability</CardTitle>
|
|
||||||
<CardDescription>
|
|
||||||
Manage your calendar display, default availability, and iCal
|
|
||||||
integrations.
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className='space-y-6'>
|
|
||||||
<fieldset className='space-y-4 p-4 border rounded-md'>
|
|
||||||
<legend className='text-sm font-medium px-1'>
|
|
||||||
Display
|
|
||||||
</legend>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='defaultCalendarView'>
|
|
||||||
Default Calendar View
|
|
||||||
</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='defaultCalendarView'>
|
|
||||||
<SelectValue placeholder='Select view' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='day'>Day</SelectItem>
|
|
||||||
<SelectItem value='week'>Week</SelectItem>
|
|
||||||
<SelectItem value='month'>Month</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='weekStartsOn'>Week Starts On</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='weekStartsOn'>
|
|
||||||
<SelectValue placeholder='Select day' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='sunday'>Sunday</SelectItem>
|
|
||||||
<SelectItem value='monday'>Monday</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='flex items-center justify-between space-x-2'>
|
|
||||||
<Label htmlFor='showWeekends' className='font-normal'>
|
|
||||||
Show Weekends
|
|
||||||
</Label>
|
|
||||||
<Switch id='showWeekends' defaultChecked />
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset className='space-y-4 p-4 border rounded-md'>
|
|
||||||
<legend className='text-sm font-medium px-1'>
|
|
||||||
Availability
|
|
||||||
</legend>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label>Working Hours</Label>
|
|
||||||
<p className='text-sm text-muted-foreground'>
|
|
||||||
Define your typical available hours (e.g.,
|
|
||||||
Monday-Friday, 9 AM - 5 PM).
|
|
||||||
</p>
|
|
||||||
<Button variant='outline_muted' size='sm'>
|
|
||||||
Set Working Hours
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='minNoticeBooking'>
|
|
||||||
Minimum Notice for Bookings
|
|
||||||
</Label>
|
|
||||||
<p className='text-sm text-muted-foreground'>
|
|
||||||
Min time before a booking can be made.
|
|
||||||
</p>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Input
|
|
||||||
id='bookingWindow'
|
|
||||||
type='text'
|
|
||||||
placeholder='e.g., 1h'
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='bookingWindow'>
|
|
||||||
Booking Window (days in advance)
|
|
||||||
</Label>
|
|
||||||
<p className='text-sm text-muted-foreground'>
|
|
||||||
Max time in advance a booking can be made.
|
|
||||||
</p>
|
|
||||||
<Input
|
|
||||||
id='bookingWindow'
|
|
||||||
type='number'
|
|
||||||
placeholder='e.g., 30d'
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset className='space-y-4 p-4 border rounded-md'>
|
|
||||||
<legend className='text-sm font-medium px-1'>
|
|
||||||
iCalendar Integration
|
|
||||||
</legend>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='icalImport'>Import iCal Feed URL</Label>
|
|
||||||
<Input
|
|
||||||
id='icalImport'
|
|
||||||
type='url'
|
|
||||||
placeholder='https://calendar.example.com/feed.ics'
|
|
||||||
/>
|
|
||||||
<Button size='sm' className='mt-1'>
|
|
||||||
Add Feed
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label>Export Your Calendar</Label>
|
|
||||||
<Button variant='outline_muted' size='sm'>
|
|
||||||
Get iCal Export URL
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant='outline_muted'
|
|
||||||
size='sm'
|
|
||||||
className='ml-2'
|
|
||||||
>
|
|
||||||
Download .ics File
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
</CardContent>
|
|
||||||
</ScrollableSettingsWrapper>
|
|
||||||
<CardFooter className='mt-auto border-t pt-4 flex justify-between'>
|
|
||||||
<Button variant='secondary'>Exit</Button>
|
|
||||||
<Button>Save Changes</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent
|
|
||||||
value='sharingPrivacy'
|
|
||||||
className='flex-grow overflow-hidden'
|
|
||||||
>
|
|
||||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
|
||||||
<ScrollableSettingsWrapper>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>Sharing & Privacy</CardTitle>
|
|
||||||
<CardDescription>
|
|
||||||
Control who can see your calendar and book time with you.
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className='space-y-6'>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='defaultVisibility'>
|
|
||||||
Default Calendar Visibility
|
|
||||||
</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='defaultVisibility'>
|
|
||||||
<SelectValue placeholder='Select visibility' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='private'>
|
|
||||||
Private (Only You)
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value='freebusy'>
|
|
||||||
Free/Busy for Friends
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value='fulldetails'>
|
|
||||||
Full Details for Friends
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='whoCanSeeFull'>
|
|
||||||
Who Can See Your Full Calendar Details?
|
|
||||||
</Label>
|
|
||||||
<p className='text-sm text-muted-foreground'>
|
|
||||||
(Override for Default Visibility)
|
|
||||||
<br />
|
|
||||||
<span className='text-sm text-muted-foreground'>
|
|
||||||
This setting will override the default visibility for
|
|
||||||
your calendar. You can set specific friends or groups to
|
|
||||||
see your full calendar details.
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='whoCanSeeFull'>
|
|
||||||
<SelectValue placeholder='Select audience' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='me'>Only Me</SelectItem>
|
|
||||||
<SelectItem value='friends'>My Friends</SelectItem>
|
|
||||||
<SelectItem value='specific'>
|
|
||||||
Specific Friends/Groups (manage separately)
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='whoCanBook'>
|
|
||||||
Who Can Book Time With You?
|
|
||||||
</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='whoCanBook'>
|
|
||||||
<SelectValue placeholder='Select audience' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='none'>No One</SelectItem>
|
|
||||||
<SelectItem value='friends'>My Friends</SelectItem>
|
|
||||||
<SelectItem value='specific'>
|
|
||||||
Specific Friends/Groups (manage separately)
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label>Blocked Users</Label>
|
|
||||||
<Button variant='outline_muted'>
|
|
||||||
Manage Blocked Users
|
|
||||||
</Button>
|
|
||||||
<p className='text-sm text-muted-foreground'>
|
|
||||||
Prevent specific users from seeing your calendar or
|
|
||||||
booking time.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</ScrollableSettingsWrapper>
|
|
||||||
<CardFooter className='mt-auto border-t pt-4 flex justify-between'>
|
|
||||||
<Button variant='secondary'>Exit</Button>
|
|
||||||
<Button>Save Changes</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value='appearance' className='flex-grow overflow-hidden'>
|
|
||||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
|
||||||
<ScrollableSettingsWrapper>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>Appearance</CardTitle>
|
|
||||||
<CardDescription>
|
|
||||||
Customize the look and feel of the application.
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className='space-y-6'>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='theme'>Theme</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='theme'>
|
|
||||||
<SelectValue placeholder='Select theme' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='light'>Light</SelectItem>
|
|
||||||
<SelectItem value='dark'>Dark</SelectItem>
|
|
||||||
<SelectItem value='system'>System Default</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='dateFormat'>Date Format</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='dateFormat'>
|
|
||||||
<SelectValue placeholder='Select date format' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='ddmmyyyy'>DD/MM/YYYY</SelectItem>
|
|
||||||
<SelectItem value='mmddyyyy'>MM/DD/YYYY</SelectItem>
|
|
||||||
<SelectItem value='yyyymmdd'>YYYY-MM-DD</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div className='space-y-2'>
|
|
||||||
<Label htmlFor='timeFormat'>Time Format</Label>
|
|
||||||
<Select>
|
|
||||||
<SelectTrigger id='timeFormat'>
|
|
||||||
<SelectValue placeholder='Select time format' />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value='24h'>24-hour</SelectItem>
|
|
||||||
<SelectItem value='12h'>12-hour</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</ScrollableSettingsWrapper>
|
|
||||||
<CardFooter className='mt-auto border-t pt-4 flex justify-between'>
|
|
||||||
<Button variant='secondary'>Exit</Button>
|
|
||||||
<Button>Save Changes</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</TabsContent>
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
31
src/auth.ts
31
src/auth.ts
|
@ -2,8 +2,15 @@ import NextAuth, { CredentialsSignin } from 'next-auth';
|
||||||
|
|
||||||
import { Prisma } from '@/generated/prisma';
|
import { Prisma } from '@/generated/prisma';
|
||||||
import type { Provider } from 'next-auth/providers';
|
import type { Provider } from 'next-auth/providers';
|
||||||
|
|
||||||
import Credentials from 'next-auth/providers/credentials';
|
import Credentials from 'next-auth/providers/credentials';
|
||||||
import Authentik from 'next-auth/providers/authentik';
|
import AuthentikProvider from 'next-auth/providers/authentik';
|
||||||
|
import DiscordProvider from 'next-auth/providers/discord';
|
||||||
|
import FacebookProvider from 'next-auth/providers/facebook';
|
||||||
|
import GithubProvider from 'next-auth/providers/github';
|
||||||
|
import GitlabProvider from 'next-auth/providers/gitlab';
|
||||||
|
import GoogleProvider from 'next-auth/providers/google';
|
||||||
|
import KeycloakProvider from 'next-auth/providers/keycloak';
|
||||||
|
|
||||||
import { PrismaAdapter } from '@auth/prisma-adapter';
|
import { PrismaAdapter } from '@auth/prisma-adapter';
|
||||||
import { prisma } from '@/prisma';
|
import { prisma } from '@/prisma';
|
||||||
|
@ -88,7 +95,27 @@ const providers: Provider[] = [
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
process.env.AUTH_AUTHENTIK_ID && Authentik,
|
|
||||||
|
process.env.AUTH_DISCORD_ID && DiscordProvider,
|
||||||
|
process.env.AUTH_FACEBOOK_ID && FacebookProvider,
|
||||||
|
process.env.AUTH_GITHUB_ID && GithubProvider,
|
||||||
|
process.env.AUTH_GITLAB_ID && GitlabProvider,
|
||||||
|
process.env.AUTH_GOOGLE_ID && GoogleProvider,
|
||||||
|
process.env.AUTH_KEYCLOAK_ID && KeycloakProvider,
|
||||||
|
|
||||||
|
process.env.AUTH_AUTHENTIK_ID &&
|
||||||
|
AuthentikProvider({
|
||||||
|
profile(profile) {
|
||||||
|
return {
|
||||||
|
id: profile.sub,
|
||||||
|
name: profile.preferred_username,
|
||||||
|
first_name: profile.given_name.split(' ')[0] || '',
|
||||||
|
last_name: profile.given_name.split(' ')[1] || '',
|
||||||
|
email: profile.email,
|
||||||
|
image: profile.picture,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}),
|
||||||
].filter(Boolean) as Provider[];
|
].filter(Boolean) as Provider[];
|
||||||
|
|
||||||
export const providerMap = providers
|
export const providerMap = providers
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { LucideProps } from 'lucide-react';
|
||||||
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
import React, { ForwardRefExoticComponent, RefAttributes } from 'react';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
|
|
||||||
export function IconButton({
|
export function IconButton({
|
||||||
icon,
|
icon,
|
||||||
children,
|
children,
|
||||||
...props
|
...props
|
||||||
}: {
|
}: {
|
||||||
icon: IconProp;
|
icon?: ForwardRefExoticComponent<
|
||||||
children: React.ReactNode;
|
Omit<LucideProps, 'ref'> & RefAttributes<SVGSVGElement>
|
||||||
|
>;
|
||||||
|
children?: React.ReactNode;
|
||||||
} & React.ComponentProps<typeof Button>) {
|
} & React.ComponentProps<typeof Button>) {
|
||||||
return (
|
return (
|
||||||
<Button type='button' variant='secondary' {...props}>
|
<Button type='button' variant='secondary' {...props}>
|
||||||
<FontAwesomeIcon icon={icon} className='mr-2' />
|
{icon && React.createElement(icon, { className: 'mr-2' })}
|
||||||
{children}
|
{children}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { signIn } from '@/auth';
|
import { signIn } from '@/auth';
|
||||||
import { IconButton } from '@/components/buttons/icon-button';
|
import { IconButton } from '@/components/buttons/icon-button';
|
||||||
import { faOpenid } from '@fortawesome/free-brands-svg-icons';
|
import { Fingerprint } from 'lucide-react';
|
||||||
|
|
||||||
export default function SSOLogin({
|
export default function SSOLogin({
|
||||||
provider,
|
provider,
|
||||||
|
@ -22,7 +22,7 @@ export default function SSOLogin({
|
||||||
className='w-full'
|
className='w-full'
|
||||||
type='submit'
|
type='submit'
|
||||||
variant='secondary'
|
variant='secondary'
|
||||||
icon={faOpenid}
|
icon={Fingerprint}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
Login with {providerDisplayName}
|
Login with {providerDisplayName}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import '@/components/react-big-calendar.css';
|
||||||
import 'react-big-calendar/lib/addons/dragAndDrop/styles.css';
|
import 'react-big-calendar/lib/addons/dragAndDrop/styles.css';
|
||||||
import CustomToolbar from '@/components/custom-toolbar';
|
import CustomToolbar from '@/components/custom-toolbar';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useGetApiUserUserCalendar } from '@/generated/api/user/user';
|
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { usePatchApiEventEventID } from '@/generated/api/event/event';
|
import { usePatchApiEventEventID } from '@/generated/api/event/event';
|
||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
|
@ -17,6 +16,8 @@ import { ErrorBoundary } from 'react-error-boundary';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { fromZodIssue } from 'zod-validation-error/v4';
|
import { fromZodIssue } from 'zod-validation-error/v4';
|
||||||
import type { $ZodIssue } from 'zod/v4/core';
|
import type { $ZodIssue } from 'zod/v4/core';
|
||||||
|
import { useGetApiCalendar } from '@/generated/api/calendar/calendar';
|
||||||
|
import { usePatchApiBlockedSlotsSlotID } from '@/generated/api/blocked-slots/blocked-slots';
|
||||||
|
|
||||||
moment.updateLocale('en', {
|
moment.updateLocale('en', {
|
||||||
week: {
|
week: {
|
||||||
|
@ -25,12 +26,29 @@ moment.updateLocale('en', {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function eventPropGetter(event: {
|
||||||
|
id: string;
|
||||||
|
start: Date;
|
||||||
|
end: Date;
|
||||||
|
type: UserCalendarSchemaItem['type'];
|
||||||
|
userId?: string;
|
||||||
|
colorOverride?: string;
|
||||||
|
}) {
|
||||||
|
return {
|
||||||
|
style: event.colorOverride
|
||||||
|
? { backgroundColor: event.colorOverride }
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const DaDRBCalendar = withDragAndDrop<
|
const DaDRBCalendar = withDragAndDrop<
|
||||||
{
|
{
|
||||||
id: string;
|
id: string;
|
||||||
start: Date;
|
start: Date;
|
||||||
end: Date;
|
end: Date;
|
||||||
type: UserCalendarSchemaItem['type'];
|
type: UserCalendarSchemaItem['type'];
|
||||||
|
userId?: string;
|
||||||
|
organizer?: string;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -44,9 +62,21 @@ const localizer = momentLocalizer(moment);
|
||||||
export default function Calendar({
|
export default function Calendar({
|
||||||
userId,
|
userId,
|
||||||
height,
|
height,
|
||||||
|
additionalEvents = [],
|
||||||
|
className,
|
||||||
}: {
|
}: {
|
||||||
userId?: string;
|
userId?: string | string[];
|
||||||
height: string;
|
height: string;
|
||||||
|
additionalEvents?: {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
start: Date;
|
||||||
|
end: Date;
|
||||||
|
type: UserCalendarSchemaItem['type'];
|
||||||
|
userId?: string;
|
||||||
|
colorOverride?: string;
|
||||||
|
}[];
|
||||||
|
className?: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<QueryErrorResetBoundary>
|
<QueryErrorResetBoundary>
|
||||||
|
@ -67,10 +97,26 @@ export default function Calendar({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{userId ? (
|
{typeof userId === 'string' ? (
|
||||||
<CalendarWithUserEvents userId={userId} height={height} />
|
<CalendarWithUserEvents
|
||||||
|
userId={userId}
|
||||||
|
height={height}
|
||||||
|
additionalEvents={additionalEvents}
|
||||||
|
className={className}
|
||||||
|
/>
|
||||||
|
) : Array.isArray(userId) && userId.length > 0 ? (
|
||||||
|
<CalendarWithMultiUserEvents
|
||||||
|
userIds={userId}
|
||||||
|
height={height}
|
||||||
|
additionalEvents={additionalEvents}
|
||||||
|
className={className}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<CalendarWithoutUserEvents height={height} />
|
<CalendarWithoutUserEvents
|
||||||
|
height={height}
|
||||||
|
additionalEvents={additionalEvents}
|
||||||
|
className={className}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
)}
|
)}
|
||||||
|
@ -81,9 +127,21 @@ export default function Calendar({
|
||||||
function CalendarWithUserEvents({
|
function CalendarWithUserEvents({
|
||||||
userId,
|
userId,
|
||||||
height,
|
height,
|
||||||
|
additionalEvents,
|
||||||
|
className,
|
||||||
}: {
|
}: {
|
||||||
userId: string;
|
userId: string;
|
||||||
height: string;
|
height: string;
|
||||||
|
additionalEvents?: {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
start: Date;
|
||||||
|
end: Date;
|
||||||
|
type: UserCalendarSchemaItem['type'];
|
||||||
|
userId?: string;
|
||||||
|
colorOverride?: string;
|
||||||
|
}[];
|
||||||
|
className?: string;
|
||||||
}) {
|
}) {
|
||||||
const sesstion = useSession();
|
const sesstion = useSession();
|
||||||
const [currentView, setCurrentView] = React.useState<
|
const [currentView, setCurrentView] = React.useState<
|
||||||
|
@ -92,9 +150,9 @@ function CalendarWithUserEvents({
|
||||||
const [currentDate, setCurrentDate] = React.useState<Date>(new Date());
|
const [currentDate, setCurrentDate] = React.useState<Date>(new Date());
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { data, refetch, error, isError } = useGetApiUserUserCalendar(
|
const { data, refetch, error, isError } = useGetApiCalendar(
|
||||||
userId,
|
|
||||||
{
|
{
|
||||||
|
userIds: [userId],
|
||||||
start: moment(currentDate)
|
start: moment(currentDate)
|
||||||
.startOf(
|
.startOf(
|
||||||
currentView === 'agenda'
|
currentView === 'agenda'
|
||||||
|
@ -134,9 +192,18 @@ function CalendarWithUserEvents({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const { mutate: patchBlockedSlot } = usePatchApiBlockedSlotsSlotID({
|
||||||
|
mutation: {
|
||||||
|
throwOnError(error) {
|
||||||
|
throw error.response?.data || 'Failed to update blocked slot';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DaDRBCalendar
|
<DaDRBCalendar
|
||||||
|
className={className}
|
||||||
|
eventPropGetter={eventPropGetter}
|
||||||
localizer={localizer}
|
localizer={localizer}
|
||||||
culture='de-DE'
|
culture='de-DE'
|
||||||
defaultView='week'
|
defaultView='week'
|
||||||
|
@ -152,17 +219,27 @@ function CalendarWithUserEvents({
|
||||||
onNavigate={(date) => {
|
onNavigate={(date) => {
|
||||||
setCurrentDate(date);
|
setCurrentDate(date);
|
||||||
}}
|
}}
|
||||||
events={
|
events={[
|
||||||
data?.data.calendar.map((event) => ({
|
...(data?.data.calendar.map((event) => ({
|
||||||
id: event.id,
|
id: event.id,
|
||||||
title: event.type === 'event' ? event.title : 'Blocker',
|
title: event.type === 'event' ? event.title : 'Blocker',
|
||||||
start: new Date(event.start_time),
|
start: new Date(event.start_time),
|
||||||
end: new Date(event.end_time),
|
end: new Date(event.end_time),
|
||||||
type: event.type,
|
type: event.type,
|
||||||
})) ?? []
|
userId: event.users[0],
|
||||||
}
|
organizer: event.type === 'event' ? event.organizer_id : undefined,
|
||||||
|
})) ?? []),
|
||||||
|
...(additionalEvents ?? []),
|
||||||
|
]}
|
||||||
onSelectEvent={(event) => {
|
onSelectEvent={(event) => {
|
||||||
router.push(`/events/${event.id}`);
|
if (event.type === 'blocked_private') return;
|
||||||
|
if (event.type === 'blocked_owned') {
|
||||||
|
router.push(`/blocker/${event.id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.type === 'event') {
|
||||||
|
router.push(`/events/${event.id}`);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
onSelectSlot={(slotInfo) => {
|
onSelectSlot={(slotInfo) => {
|
||||||
router.push(
|
router.push(
|
||||||
|
@ -176,59 +253,220 @@ function CalendarWithUserEvents({
|
||||||
selectable={sesstion.data?.user?.id === userId}
|
selectable={sesstion.data?.user?.id === userId}
|
||||||
onEventDrop={(event) => {
|
onEventDrop={(event) => {
|
||||||
const { start, end, event: droppedEvent } = event;
|
const { start, end, event: droppedEvent } = event;
|
||||||
if (droppedEvent.type === 'blocked_private') return;
|
if (
|
||||||
|
droppedEvent.type === 'blocked_private' ||
|
||||||
|
(droppedEvent.organizer &&
|
||||||
|
droppedEvent.organizer !== sesstion.data?.user?.id)
|
||||||
|
)
|
||||||
|
return;
|
||||||
const startISO = new Date(start).toISOString();
|
const startISO = new Date(start).toISOString();
|
||||||
const endISO = new Date(end).toISOString();
|
const endISO = new Date(end).toISOString();
|
||||||
patchEvent(
|
if (droppedEvent.type === 'blocked_owned') {
|
||||||
{
|
patchBlockedSlot(
|
||||||
eventID: droppedEvent.id,
|
{
|
||||||
data: {
|
slotID: droppedEvent.id,
|
||||||
start_time: startISO,
|
data: {
|
||||||
end_time: endISO,
|
start_time: startISO,
|
||||||
|
end_time: endISO,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
onSuccess: () => {
|
||||||
onSuccess: () => {
|
refetch();
|
||||||
refetch();
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error('Error updating blocked slot:', error);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
);
|
||||||
console.error('Error updating event:', error);
|
return;
|
||||||
|
} else if (droppedEvent.type === 'event') {
|
||||||
|
patchEvent(
|
||||||
|
{
|
||||||
|
eventID: droppedEvent.id,
|
||||||
|
data: {
|
||||||
|
start_time: startISO,
|
||||||
|
end_time: endISO,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
);
|
onSuccess: () => {
|
||||||
|
refetch();
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error('Error updating event:', error);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
onEventResize={(event) => {
|
onEventResize={(event) => {
|
||||||
const { start, end, event: resizedEvent } = event;
|
const { start, end, event: resizedEvent } = event;
|
||||||
if (resizedEvent.type === 'blocked_private') return;
|
if (
|
||||||
|
resizedEvent.type === 'blocked_private' ||
|
||||||
|
(resizedEvent.organizer &&
|
||||||
|
resizedEvent.organizer !== sesstion.data?.user?.id)
|
||||||
|
)
|
||||||
|
return;
|
||||||
const startISO = new Date(start).toISOString();
|
const startISO = new Date(start).toISOString();
|
||||||
const endISO = new Date(end).toISOString();
|
const endISO = new Date(end).toISOString();
|
||||||
if (startISO === endISO) {
|
if (startISO === endISO) {
|
||||||
console.warn('Start and end times are the same, skipping resize.');
|
console.warn('Start and end times are the same, skipping resize.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
patchEvent(
|
if (resizedEvent.type === 'blocked_owned') {
|
||||||
{
|
patchBlockedSlot(
|
||||||
eventID: resizedEvent.id,
|
{
|
||||||
data: {
|
slotID: resizedEvent.id,
|
||||||
start_time: startISO,
|
data: {
|
||||||
end_time: endISO,
|
start_time: startISO,
|
||||||
|
end_time: endISO,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
onSuccess: () => {
|
||||||
onSuccess: () => {
|
refetch();
|
||||||
refetch();
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error('Error resizing blocked slot:', error);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
);
|
||||||
console.error('Error resizing event:', error);
|
return;
|
||||||
|
} else if (resizedEvent.type === 'event') {
|
||||||
|
patchEvent(
|
||||||
|
{
|
||||||
|
eventID: resizedEvent.id,
|
||||||
|
data: {
|
||||||
|
start_time: startISO,
|
||||||
|
end_time: endISO,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
);
|
onSuccess: () => {
|
||||||
|
refetch();
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error('Error resizing event:', error);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CalendarWithoutUserEvents({ height }: { height: string }) {
|
function CalendarWithMultiUserEvents({
|
||||||
|
userIds,
|
||||||
|
height,
|
||||||
|
additionalEvents,
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
userIds: string[];
|
||||||
|
height: string;
|
||||||
|
additionalEvents?: {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
start: Date;
|
||||||
|
end: Date;
|
||||||
|
type: UserCalendarSchemaItem['type'];
|
||||||
|
userId?: string;
|
||||||
|
colorOverride?: string;
|
||||||
|
}[];
|
||||||
|
className?: string;
|
||||||
|
}) {
|
||||||
|
const [currentView, setCurrentView] = React.useState<
|
||||||
|
'month' | 'week' | 'day' | 'agenda' | 'work_week'
|
||||||
|
>('week');
|
||||||
|
const [currentDate, setCurrentDate] = React.useState<Date>(new Date());
|
||||||
|
|
||||||
|
const { data, error, isError } = useGetApiCalendar(
|
||||||
|
{
|
||||||
|
userIds: userIds,
|
||||||
|
start: moment(currentDate)
|
||||||
|
.startOf(
|
||||||
|
currentView === 'agenda'
|
||||||
|
? 'month'
|
||||||
|
: currentView === 'work_week'
|
||||||
|
? 'week'
|
||||||
|
: currentView,
|
||||||
|
)
|
||||||
|
.toISOString(),
|
||||||
|
end: moment(currentDate)
|
||||||
|
.endOf(
|
||||||
|
currentView === 'agenda'
|
||||||
|
? 'month'
|
||||||
|
: currentView === 'work_week'
|
||||||
|
? 'week'
|
||||||
|
: currentView,
|
||||||
|
)
|
||||||
|
.toISOString(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: {
|
||||||
|
refetchOnWindowFocus: true,
|
||||||
|
refetchOnReconnect: true,
|
||||||
|
refetchOnMount: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isError) {
|
||||||
|
throw error.response?.data || 'Failed to fetch calendar data';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DaDRBCalendar
|
||||||
|
className={className}
|
||||||
|
eventPropGetter={eventPropGetter}
|
||||||
|
localizer={localizer}
|
||||||
|
culture='de-DE'
|
||||||
|
defaultView='week'
|
||||||
|
components={{
|
||||||
|
toolbar: CustomToolbar,
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
height: height,
|
||||||
|
}}
|
||||||
|
onView={setCurrentView}
|
||||||
|
view={currentView}
|
||||||
|
date={currentDate}
|
||||||
|
onNavigate={(date) => {
|
||||||
|
setCurrentDate(date);
|
||||||
|
}}
|
||||||
|
events={[
|
||||||
|
...(data?.data.calendar.map((event) => ({
|
||||||
|
id: event.id,
|
||||||
|
title: event.type === 'event' ? event.title : 'Blocker',
|
||||||
|
start: new Date(event.start_time),
|
||||||
|
end: new Date(event.end_time),
|
||||||
|
type: event.type,
|
||||||
|
userId: event.users[0],
|
||||||
|
})) ?? []),
|
||||||
|
...(additionalEvents ?? []),
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function CalendarWithoutUserEvents({
|
||||||
|
height,
|
||||||
|
additionalEvents,
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
height: string;
|
||||||
|
additionalEvents?: {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
start: Date;
|
||||||
|
end: Date;
|
||||||
|
type: UserCalendarSchemaItem['type'];
|
||||||
|
userId?: string;
|
||||||
|
colorOverride?: string;
|
||||||
|
}[];
|
||||||
|
className?: string;
|
||||||
|
}) {
|
||||||
const [currentView, setCurrentView] = React.useState<
|
const [currentView, setCurrentView] = React.useState<
|
||||||
'month' | 'week' | 'day' | 'agenda' | 'work_week'
|
'month' | 'week' | 'day' | 'agenda' | 'work_week'
|
||||||
>('week');
|
>('week');
|
||||||
|
@ -236,6 +474,8 @@ function CalendarWithoutUserEvents({ height }: { height: string }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DaDRBCalendar
|
<DaDRBCalendar
|
||||||
|
className={className}
|
||||||
|
eventPropGetter={eventPropGetter}
|
||||||
localizer={localizer}
|
localizer={localizer}
|
||||||
culture='de-DE'
|
culture='de-DE'
|
||||||
defaultView='week'
|
defaultView='week'
|
||||||
|
@ -251,6 +491,7 @@ function CalendarWithoutUserEvents({ height }: { height: string }) {
|
||||||
onNavigate={(date) => {
|
onNavigate={(date) => {
|
||||||
setCurrentDate(date);
|
setCurrentDate(date);
|
||||||
}}
|
}}
|
||||||
|
events={additionalEvents}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
/* Container der Toolbar */
|
/* Container der Toolbar */
|
||||||
.custom-toolbar {
|
.custom-toolbar {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
gap: 8px;
|
||||||
gap: 12px;
|
|
||||||
padding: calc(var(--spacing) * 2);
|
padding: calc(var(--spacing) * 2);
|
||||||
padding-left: calc(50px + var(--spacing));
|
padding-left: calc(50px + var(--spacing));
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
|
@media (max-width: 870px) {
|
||||||
|
padding-left: 0;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
box-shadow: none;
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +29,12 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-toolbar .navigation-controls .handleWeek {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-toolbar .navigation-controls button {
|
.custom-toolbar .navigation-controls button {
|
||||||
|
@ -77,6 +87,8 @@
|
||||||
border-radius: 11px;
|
border-radius: 11px;
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-toolbar .navigation-controls .handleWeek button {
|
.custom-toolbar .navigation-controls .handleWeek button {
|
||||||
|
@ -93,6 +105,9 @@
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
border-radius: 11px;
|
border-radius: 11px;
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-section .datepicker-box {
|
.right-section .datepicker-box {
|
||||||
|
@ -100,8 +115,12 @@
|
||||||
background-color: #c6c6c6;
|
background-color: #c6c6c6;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
border-radius: 11px;
|
border-radius: 11px;
|
||||||
font-size: 12px;
|
font-size: 14px;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
|
font-family: 'Varela Round', sans-serif;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.datepicker {
|
.datepicker {
|
||||||
|
|
|
@ -171,12 +171,9 @@ const CustomToolbar: React.FC<CustomToolbarProps> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className='custom-toolbar'>
|
||||||
className='custom-toolbar'
|
|
||||||
style={{ display: 'flex', flexDirection: 'initial', gap: '8px' }}
|
|
||||||
>
|
|
||||||
<div className='view-change'>
|
<div className='view-change'>
|
||||||
<div className='view-switcher' style={{ display: 'flex', gap: '8px' }}>
|
<div className='view-switcher'>
|
||||||
<Button
|
<Button
|
||||||
//className='hover:bg-orange-600 hover:text-white'
|
//className='hover:bg-orange-600 hover:text-white'
|
||||||
type='submit'
|
type='submit'
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from '@/components/custom-ui/sidebar';
|
} from '@/components/custom-ui/sidebar';
|
||||||
|
|
||||||
import { ChevronDown } from 'lucide-react';
|
import { CalendarMinus, CalendarMinus2, ChevronDown } from 'lucide-react';
|
||||||
import {
|
import {
|
||||||
Collapsible,
|
Collapsible,
|
||||||
CollapsibleContent,
|
CollapsibleContent,
|
||||||
|
@ -28,8 +28,8 @@ import Link from 'next/link';
|
||||||
import {
|
import {
|
||||||
Star,
|
Star,
|
||||||
CalendarDays,
|
CalendarDays,
|
||||||
User,
|
//User,
|
||||||
Users,
|
//Users,
|
||||||
CalendarClock,
|
CalendarClock,
|
||||||
CalendarPlus,
|
CalendarPlus,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
|
@ -37,10 +37,10 @@ import {
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
title: 'Calendar',
|
title: 'Calendar',
|
||||||
url: '#',
|
url: '/home',
|
||||||
icon: CalendarDays,
|
icon: CalendarDays,
|
||||||
},
|
},
|
||||||
{
|
/*{
|
||||||
title: 'Friends',
|
title: 'Friends',
|
||||||
url: '#',
|
url: '#',
|
||||||
icon: User,
|
icon: User,
|
||||||
|
@ -49,12 +49,17 @@ const items = [
|
||||||
title: 'Groups',
|
title: 'Groups',
|
||||||
url: '#',
|
url: '#',
|
||||||
icon: Users,
|
icon: Users,
|
||||||
},
|
},*/
|
||||||
{
|
{
|
||||||
title: 'Events',
|
title: 'Events',
|
||||||
url: '#',
|
url: '/events',
|
||||||
icon: CalendarClock,
|
icon: CalendarClock,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Blockers',
|
||||||
|
url: '/blocker',
|
||||||
|
icon: CalendarMinus,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function AppSidebar() {
|
export function AppSidebar() {
|
||||||
|
@ -62,25 +67,27 @@ export function AppSidebar() {
|
||||||
<>
|
<>
|
||||||
<Sidebar collapsible='icon' variant='sidebar'>
|
<Sidebar collapsible='icon' variant='sidebar'>
|
||||||
<SidebarHeader className='overflow-hidden'>
|
<SidebarHeader className='overflow-hidden'>
|
||||||
<Logo
|
<Link href='/home'>
|
||||||
colorType='colored'
|
<Logo
|
||||||
logoType='combo'
|
colorType='colored'
|
||||||
height={50}
|
logoType='combo'
|
||||||
className='group-data-[collapsible=icon]:hidden min-w-[203px]'
|
height={50}
|
||||||
></Logo>
|
className='group-data-[collapsible=icon]:hidden min-w-[203px]'
|
||||||
<Logo
|
></Logo>
|
||||||
colorType='colored'
|
<Logo
|
||||||
logoType='submark'
|
colorType='colored'
|
||||||
height={50}
|
logoType='submark'
|
||||||
className='group-data-[collapsible=]:hidden group-data-[mobile=true]/mobile:hidden'
|
height={50}
|
||||||
></Logo>
|
className='group-data-[collapsible=]:hidden group-data-[mobile=true]/mobile:hidden'
|
||||||
|
></Logo>
|
||||||
|
</Link>
|
||||||
</SidebarHeader>
|
</SidebarHeader>
|
||||||
<SidebarContent className='grid grid-rows-[auto_1fr_auto]'>
|
<SidebarContent className='grid grid-rows-[auto_1fr_auto] overflow-hidden'>
|
||||||
<Collapsible defaultOpen className='group/collapsible'>
|
<Collapsible defaultOpen className='group/collapsible'>
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarGroupLabel asChild>
|
<SidebarGroupLabel asChild>
|
||||||
<CollapsibleTrigger>
|
<CollapsibleTrigger disabled>
|
||||||
<span className='flex items-center gap-2 text-xl font-label text-neutral-100'>
|
<span className='flex items-center gap-2 text-xl font-label text-disabled'>
|
||||||
<Star className='size-8' />{' '}
|
<Star className='size-8' />{' '}
|
||||||
<span className='group-data-[collapsible=icon]:hidden'>
|
<span className='group-data-[collapsible=icon]:hidden'>
|
||||||
Favorites
|
Favorites
|
||||||
|
@ -114,7 +121,7 @@ export function AppSidebar() {
|
||||||
<SidebarFooter>
|
<SidebarFooter>
|
||||||
<SidebarMenuItem className='pl-[8px]'>
|
<SidebarMenuItem className='pl-[8px]'>
|
||||||
<Link
|
<Link
|
||||||
href='/event/new'
|
href='/events/new'
|
||||||
className='flex items-center gap-2 text-xl font-label'
|
className='flex items-center gap-2 text-xl font-label'
|
||||||
>
|
>
|
||||||
<CalendarPlus className='size-8' />
|
<CalendarPlus className='size-8' />
|
||||||
|
@ -123,6 +130,17 @@ export function AppSidebar() {
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
|
<SidebarMenuItem className='pl-[8px]'>
|
||||||
|
<Link
|
||||||
|
href='/blocker/new'
|
||||||
|
className='flex items-center gap-2 text-xl font-label'
|
||||||
|
>
|
||||||
|
<CalendarMinus2 className='size-8' />
|
||||||
|
<span className='group-data-[collapsible=icon]:hidden text-nowrap whitespace-nowrap'>
|
||||||
|
New Blocker
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
|
</SidebarMenuItem>
|
||||||
</SidebarFooter>
|
</SidebarFooter>
|
||||||
</SidebarContent>
|
</SidebarContent>
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
|
|
56
src/components/custom-ui/blocked-slot-list-entry.tsx
Normal file
56
src/components/custom-ui/blocked-slot-list-entry.tsx
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Card } from '@/components/ui/card';
|
||||||
|
import Logo from '@/components/misc/logo';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import zod from 'zod/v4';
|
||||||
|
import { BlockedSlotsSchema } from '@/app/api/blocked_slots/validation';
|
||||||
|
|
||||||
|
type BlockedSlotListEntryProps = zod.output<typeof BlockedSlotsSchema>;
|
||||||
|
|
||||||
|
export default function BlockedSlotListEntry(slot: BlockedSlotListEntryProps) {
|
||||||
|
const formatDate = (isoString?: string) => {
|
||||||
|
if (!isoString) return '-';
|
||||||
|
return new Date(isoString).toLocaleDateString();
|
||||||
|
};
|
||||||
|
const formatTime = (isoString?: string) => {
|
||||||
|
if (!isoString) return '-';
|
||||||
|
return new Date(isoString).toLocaleTimeString([], {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Link href={`/blocker/${slot.id}`} className='block'>
|
||||||
|
<Card className='w-full'>
|
||||||
|
<div className='grid grid-cols-1 gap-2 mx-auto md:mx-4 md:grid-cols-[80px_1fr_250px]'>
|
||||||
|
<div className='w-full items-center justify-center grid'>
|
||||||
|
<Logo colorType='monochrome' logoType='submark' width={50} />
|
||||||
|
</div>
|
||||||
|
<div className='w-full items-center justify-center grid my-3 md:my-0'>
|
||||||
|
<h2 className='text-center'>{slot.reason}</h2>
|
||||||
|
</div>
|
||||||
|
<div className='grid gap-4'>
|
||||||
|
<div className='grid grid-cols-[80px_auto] gap-2'>
|
||||||
|
<Label className='text-[var(--color-neutral-300)] justify-end'>
|
||||||
|
start
|
||||||
|
</Label>
|
||||||
|
<Label>
|
||||||
|
{formatDate(slot.start_time)} {formatTime(slot.start_time)}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
<div className='grid grid-cols-[80px_auto] gap-2'>
|
||||||
|
<Label className='text-[var(--color-neutral-300)] justify-end'>
|
||||||
|
end
|
||||||
|
</Label>
|
||||||
|
<Label>
|
||||||
|
{formatDate(slot.end_time)} {formatTime(slot.end_time)}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,9 +1,20 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
import { Card } from '@/components/ui/card';
|
import { Card } from '@/components/ui/card';
|
||||||
import Logo from '@/components/misc/logo';
|
import Logo from '@/components/misc/logo';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
import { EventSchema } from '@/app/api/event/validation';
|
import { EventSchema } from '@/app/api/event/validation';
|
||||||
|
import { useSession } from 'next-auth/react';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '../ui/select';
|
||||||
|
import { usePatchApiEventEventIDParticipantUser } from '@/generated/api/event-participant/event-participant';
|
||||||
|
|
||||||
type EventListEntryProps = zod.output<typeof EventSchema>;
|
type EventListEntryProps = zod.output<typeof EventSchema>;
|
||||||
|
|
||||||
|
@ -13,7 +24,11 @@ export default function EventListEntry({
|
||||||
start_time,
|
start_time,
|
||||||
end_time,
|
end_time,
|
||||||
location,
|
location,
|
||||||
|
participants,
|
||||||
}: EventListEntryProps) {
|
}: EventListEntryProps) {
|
||||||
|
const session = useSession();
|
||||||
|
const updateAttendance = usePatchApiEventEventIDParticipantUser();
|
||||||
|
|
||||||
const formatDate = (isoString?: string) => {
|
const formatDate = (isoString?: string) => {
|
||||||
if (!isoString) return '-';
|
if (!isoString) return '-';
|
||||||
return new Date(isoString).toLocaleDateString();
|
return new Date(isoString).toLocaleDateString();
|
||||||
|
@ -28,7 +43,10 @@ export default function EventListEntry({
|
||||||
return (
|
return (
|
||||||
<Link href={`/events/${id}`} className='block'>
|
<Link href={`/events/${id}`} className='block'>
|
||||||
<Card className='w-full'>
|
<Card className='w-full'>
|
||||||
<div className='grid grid-cols-1 gap-2 mx-auto md:mx-4 md:grid-cols-[80px_1fr_250px]'>
|
<div
|
||||||
|
className='grid grid-cols-1 gap-2 mx-auto md:mx-4 md:grid-cols-[80px_1fr_250px]'
|
||||||
|
data-cy='event-list-entry'
|
||||||
|
>
|
||||||
<div className='w-full items-center justify-center grid'>
|
<div className='w-full items-center justify-center grid'>
|
||||||
<Logo colorType='monochrome' logoType='submark' width={50} />
|
<Logo colorType='monochrome' logoType='submark' width={50} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,6 +78,45 @@ export default function EventListEntry({
|
||||||
<Label>{location}</Label>
|
<Label>{location}</Label>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{participants &&
|
||||||
|
participants.some(
|
||||||
|
(p) => p.user.id === session.data?.user?.id,
|
||||||
|
) && (
|
||||||
|
<div className='flex items-center justify-end'>
|
||||||
|
<Select
|
||||||
|
defaultValue={
|
||||||
|
participants
|
||||||
|
.find((p) => p.user.id === session.data?.user?.id)
|
||||||
|
?.status.toUpperCase() || 'PENDING'
|
||||||
|
}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
updateAttendance.mutate({
|
||||||
|
eventID: id,
|
||||||
|
user: session.data?.user?.id || '',
|
||||||
|
data: {
|
||||||
|
status: value as
|
||||||
|
| 'ACCEPTED'
|
||||||
|
| 'TENTATIVE'
|
||||||
|
| 'DECLINED'
|
||||||
|
| 'PENDING',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectTrigger id='language'>
|
||||||
|
<SelectValue placeholder='Select status' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='ACCEPTED'>Attending</SelectItem>
|
||||||
|
<SelectItem value='TENTATIVE'>Maybe Attending</SelectItem>
|
||||||
|
<SelectItem value='DECLINED'>Not Attending</SelectItem>
|
||||||
|
<SelectItem value='PENDING' disabled>
|
||||||
|
Pending Response
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
@ -1,29 +1,64 @@
|
||||||
import { Input, Textarea } from '@/components/ui/input';
|
import { Input, Textarea } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
|
import React, { ForwardRefExoticComponent, RefAttributes } from 'react';
|
||||||
|
import { Button } from '../ui/button';
|
||||||
|
import { Eye, EyeOff, LucideProps } from 'lucide-react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
export default function LabeledInput({
|
export default function LabeledInput({
|
||||||
type,
|
type,
|
||||||
label,
|
label,
|
||||||
|
subtext,
|
||||||
placeholder,
|
placeholder,
|
||||||
value,
|
value,
|
||||||
|
defaultValue,
|
||||||
name,
|
name,
|
||||||
|
icon,
|
||||||
variantSize = 'default',
|
variantSize = 'default',
|
||||||
autocomplete,
|
autocomplete,
|
||||||
error,
|
error,
|
||||||
|
'data-cy': dataCy,
|
||||||
...rest
|
...rest
|
||||||
}: {
|
}: {
|
||||||
type: 'text' | 'email' | 'password';
|
|
||||||
label: string;
|
label: string;
|
||||||
|
subtext?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
icon?: ForwardRefExoticComponent<
|
||||||
|
Omit<LucideProps, 'ref'> & RefAttributes<SVGSVGElement>
|
||||||
|
>;
|
||||||
variantSize?: 'default' | 'big' | 'textarea';
|
variantSize?: 'default' | 'big' | 'textarea';
|
||||||
autocomplete?: string;
|
autocomplete?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
'data-cy'?: string;
|
||||||
} & React.InputHTMLAttributes<HTMLInputElement>) {
|
} & React.InputHTMLAttributes<HTMLInputElement>) {
|
||||||
|
const [passwordVisible, setPasswordVisible] = React.useState(false);
|
||||||
|
const [inputValue, setInputValue] = React.useState(
|
||||||
|
value || defaultValue || '',
|
||||||
|
);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (value !== undefined) {
|
||||||
|
setInputValue(value);
|
||||||
|
}
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setInputValue(e.target.value);
|
||||||
|
if (rest.onChange) {
|
||||||
|
rest.onChange(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='grid grid-cols-1 gap-1'>
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
<Label htmlFor={name}>{label}</Label>
|
<Label htmlFor={name}>{label}</Label>
|
||||||
|
{subtext && (
|
||||||
|
<Label className='text-sm text-muted-foreground' htmlFor={name}>
|
||||||
|
{subtext}
|
||||||
|
</Label>
|
||||||
|
)}
|
||||||
{variantSize === 'textarea' ? (
|
{variantSize === 'textarea' ? (
|
||||||
<Textarea
|
<Textarea
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
|
@ -31,22 +66,52 @@ export default function LabeledInput({
|
||||||
id={name}
|
id={name}
|
||||||
name={name}
|
name={name}
|
||||||
rows={3}
|
rows={3}
|
||||||
|
data-cy={dataCy}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Input
|
<span className='relative'>
|
||||||
type={type}
|
<Input
|
||||||
placeholder={placeholder}
|
className={cn(
|
||||||
defaultValue={value}
|
type === 'password' ? 'pr-[50px]' : '',
|
||||||
id={name}
|
variantSize === 'big'
|
||||||
name={name}
|
? 'h-12 file:h-10 text-lg placeholder:text-lg sm:text-2xl sm:placeholder:text-2xl'
|
||||||
className={
|
: '',
|
||||||
variantSize === 'big'
|
icon && inputValue === '' ? 'pl-10' : '',
|
||||||
? 'h-12 file:h-10 text-lg gplaceholder:text-lg sm:text-2xl sm:placeholder:text-2xl'
|
'transition-all duration-300 ease-in-out',
|
||||||
: ''
|
)}
|
||||||
}
|
type={passwordVisible ? 'text' : type}
|
||||||
autoComplete={autocomplete}
|
placeholder={placeholder}
|
||||||
{...rest}
|
defaultValue={inputValue}
|
||||||
/>
|
id={name}
|
||||||
|
name={name}
|
||||||
|
autoComplete={autocomplete}
|
||||||
|
data-cy={dataCy}
|
||||||
|
{...rest}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
/>
|
||||||
|
{icon && (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'absolute left-3 top-1/2 -translate-y-1/2 text-muted-input transition-all duration-300 ease-in-out',
|
||||||
|
inputValue === ''
|
||||||
|
? 'opacity-100 scale-100'
|
||||||
|
: 'opacity-0 scale-75 pointer-events-none',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{React.createElement(icon)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{type === 'password' && (
|
||||||
|
<Button
|
||||||
|
className='absolute right-0 top-0 w-[36px] h-[36px]'
|
||||||
|
type='button'
|
||||||
|
variant={'outline_muted'}
|
||||||
|
onClick={() => setPasswordVisible((visible) => !visible)}
|
||||||
|
>
|
||||||
|
{passwordVisible ? <Eye /> : <EyeOff />}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
{error && <p className='text-red-500 text-sm mt-1'>{error}</p>}
|
{error && <p className='text-red-500 text-sm mt-1'>{error}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,15 +5,28 @@ import { user_default_light } from '@/assets/usericon/default/defaultusericon-ex
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
import { ParticipantSchema } from '@/app/api/event/[eventID]/participant/validation';
|
import { ParticipantSchema } from '@/app/api/event/[eventID]/participant/validation';
|
||||||
|
import { usePatchApiEventEventIDParticipantUser } from '@/generated/api/event-participant/event-participant';
|
||||||
|
import { useSession } from 'next-auth/react';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '../ui/select';
|
||||||
|
|
||||||
type ParticipantListEntryProps = zod.output<typeof ParticipantSchema>;
|
type ParticipantListEntryProps = zod.output<typeof ParticipantSchema>;
|
||||||
|
|
||||||
export default function ParticipantListEntry({
|
export default function ParticipantListEntry({
|
||||||
user,
|
user,
|
||||||
}: ParticipantListEntryProps) {
|
status,
|
||||||
|
eventID,
|
||||||
|
}: ParticipantListEntryProps & { eventID?: string }) {
|
||||||
|
const session = useSession();
|
||||||
const { resolvedTheme } = useTheme();
|
const { resolvedTheme } = useTheme();
|
||||||
const defaultImage =
|
const defaultImage =
|
||||||
resolvedTheme === 'dark' ? user_default_dark : user_default_light;
|
resolvedTheme === 'dark' ? user_default_dark : user_default_light;
|
||||||
|
const updateAttendance = usePatchApiEventEventIDParticipantUser();
|
||||||
|
|
||||||
const finalImageSrc = user.image ?? defaultImage;
|
const finalImageSrc = user.image ?? defaultImage;
|
||||||
|
|
||||||
|
@ -21,6 +34,38 @@ export default function ParticipantListEntry({
|
||||||
<div className='flex items-center gap-2 py-1 ml-5'>
|
<div className='flex items-center gap-2 py-1 ml-5'>
|
||||||
<Image src={finalImageSrc} alt='Avatar' width={30} height={30} />
|
<Image src={finalImageSrc} alt='Avatar' width={30} height={30} />
|
||||||
<span>{user.name}</span>
|
<span>{user.name}</span>
|
||||||
|
{user.id === session.data?.user?.id && eventID ? (
|
||||||
|
<Select
|
||||||
|
defaultValue={status}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
updateAttendance.mutate({
|
||||||
|
eventID: eventID,
|
||||||
|
user: session.data?.user?.id || '',
|
||||||
|
data: {
|
||||||
|
status: value as
|
||||||
|
| 'ACCEPTED'
|
||||||
|
| 'TENTATIVE'
|
||||||
|
| 'DECLINED'
|
||||||
|
| 'PENDING',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectTrigger id='language'>
|
||||||
|
<SelectValue placeholder='Select status' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='ACCEPTED'>Attending</SelectItem>
|
||||||
|
<SelectItem value='TENTATIVE'>Maybe Attending</SelectItem>
|
||||||
|
<SelectItem value='DECLINED'>Not Attending</SelectItem>
|
||||||
|
<SelectItem value='PENDING' disabled>
|
||||||
|
Pending Response
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
) : (
|
||||||
|
<span className='text-sm text-gray-500'>{status}</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
285
src/components/forms/blocked-slot-form.tsx
Normal file
285
src/components/forms/blocked-slot-form.tsx
Normal file
|
@ -0,0 +1,285 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import useZodForm from '@/lib/hooks/useZodForm';
|
||||||
|
import {
|
||||||
|
updateBlockedSlotSchema,
|
||||||
|
createBlockedSlotClientSchema,
|
||||||
|
} from '@/app/api/blocked_slots/validation';
|
||||||
|
import {
|
||||||
|
useGetApiBlockedSlotsSlotID,
|
||||||
|
usePatchApiBlockedSlotsSlotID,
|
||||||
|
useDeleteApiBlockedSlotsSlotID,
|
||||||
|
usePostApiBlockedSlots,
|
||||||
|
} from '@/generated/api/blocked-slots/blocked-slots';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import React from 'react';
|
||||||
|
import LabeledInput from '../custom-ui/labeled-input';
|
||||||
|
import { Button } from '../ui/button';
|
||||||
|
import { Card, CardContent, CardHeader } from '../ui/card';
|
||||||
|
import Logo from '../misc/logo';
|
||||||
|
import { eventStartTimeSchema } from '@/app/api/event/validation';
|
||||||
|
import zod from 'zod/v4';
|
||||||
|
|
||||||
|
const dateForDateTimeInputValue = (date: Date) =>
|
||||||
|
new Date(date.getTime() + new Date().getTimezoneOffset() * -60 * 1000)
|
||||||
|
.toISOString()
|
||||||
|
.slice(0, 19);
|
||||||
|
|
||||||
|
export default function BlockedSlotForm({
|
||||||
|
existingBlockedSlotId,
|
||||||
|
}: {
|
||||||
|
existingBlockedSlotId?: string;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const { data: existingBlockedSlot, isLoading: isLoadingExisting } =
|
||||||
|
useGetApiBlockedSlotsSlotID(existingBlockedSlotId || '');
|
||||||
|
|
||||||
|
const {
|
||||||
|
register: registerCreate,
|
||||||
|
handleSubmit: handleCreateSubmit,
|
||||||
|
formState: formStateCreate,
|
||||||
|
reset: resetCreate,
|
||||||
|
} = useZodForm(createBlockedSlotClientSchema);
|
||||||
|
|
||||||
|
const {
|
||||||
|
register: registerUpdate,
|
||||||
|
handleSubmit: handleUpdateSubmit,
|
||||||
|
formState: formStateUpdate,
|
||||||
|
reset: resetUpdate,
|
||||||
|
setValue: setValueUpdate,
|
||||||
|
} = useZodForm(
|
||||||
|
updateBlockedSlotSchema.extend({
|
||||||
|
start_time: eventStartTimeSchema.or(zod.iso.datetime({ local: true })),
|
||||||
|
end_time: eventStartTimeSchema.or(zod.iso.datetime({ local: true })),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const { mutateAsync: updateBlockedSlot } = usePatchApiBlockedSlotsSlotID({
|
||||||
|
mutation: {
|
||||||
|
onSuccess: () => {
|
||||||
|
resetUpdate();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutateAsync: deleteBlockedSlot } = useDeleteApiBlockedSlotsSlotID({
|
||||||
|
mutation: {
|
||||||
|
onSuccess: () => {
|
||||||
|
router.push('/blocker');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutateAsync: createBlockedSlot } = usePostApiBlockedSlots({
|
||||||
|
mutation: {
|
||||||
|
onSuccess: () => {
|
||||||
|
resetCreate();
|
||||||
|
router.push('/blocker');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (existingBlockedSlot?.data) {
|
||||||
|
setValueUpdate(
|
||||||
|
'start_time',
|
||||||
|
dateForDateTimeInputValue(
|
||||||
|
new Date(existingBlockedSlot?.data.blocked_slot.start_time),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
setValueUpdate(
|
||||||
|
'end_time',
|
||||||
|
dateForDateTimeInputValue(
|
||||||
|
new Date(existingBlockedSlot?.data.blocked_slot.end_time),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
setValueUpdate(
|
||||||
|
'reason',
|
||||||
|
existingBlockedSlot?.data.blocked_slot.reason || '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
existingBlockedSlot?.data,
|
||||||
|
resetUpdate,
|
||||||
|
setValueUpdate,
|
||||||
|
isLoadingExisting,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const onUpdateSubmit = handleUpdateSubmit(async (data) => {
|
||||||
|
await updateBlockedSlot(
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
...data,
|
||||||
|
start_time: new Date(data.start_time).toISOString(),
|
||||||
|
end_time: new Date(data.end_time).toISOString(),
|
||||||
|
},
|
||||||
|
slotID: existingBlockedSlotId || '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
router.back();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const onDeleteSubmit = async () => {
|
||||||
|
if (existingBlockedSlotId) {
|
||||||
|
await deleteBlockedSlot({ slotID: existingBlockedSlotId });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCreateSubmit = handleCreateSubmit(async (data) => {
|
||||||
|
await createBlockedSlot({
|
||||||
|
data: {
|
||||||
|
...data,
|
||||||
|
start_time: new Date(data.start_time).toISOString(),
|
||||||
|
end_time: new Date(data.end_time).toISOString(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (existingBlockedSlotId)
|
||||||
|
return (
|
||||||
|
<div className='flex items-center justify-center h-full'>
|
||||||
|
<Card className='w-[max(80%, 500px)] max-w-screen p-0 gap-0 max-xl:w-[95%] mx-auto'>
|
||||||
|
<CardHeader className='p-0 m-0 gap-0 px-6'>
|
||||||
|
<div className='h-full mt-0 ml-2 mb-16 flex items-center justify-between max-sm:grid max-sm:grid-row-start:auto max-sm:mb-6 max-sm:mt-10 max-sm:ml-0'>
|
||||||
|
<div className='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||||
|
<Logo colorType='monochrome' logoType='submark' width={50} />
|
||||||
|
</div>
|
||||||
|
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||||
|
<h1 className='text-center'>{'Update Blocker'}</h1>
|
||||||
|
</div>
|
||||||
|
<div className='w-0 sm:w-[100px]'></div>
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<form onSubmit={onUpdateSubmit}>
|
||||||
|
<div className='grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3'>
|
||||||
|
<LabeledInput
|
||||||
|
label='Start Time'
|
||||||
|
type='datetime-local'
|
||||||
|
id='start_time'
|
||||||
|
{...registerUpdate('start_time')}
|
||||||
|
error={formStateUpdate.errors.start_time?.message}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<LabeledInput
|
||||||
|
label='End Time'
|
||||||
|
type='datetime-local'
|
||||||
|
id='end_time'
|
||||||
|
{...registerUpdate('end_time')}
|
||||||
|
error={formStateUpdate.errors.end_time?.message}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<LabeledInput
|
||||||
|
label='Reason'
|
||||||
|
type='text'
|
||||||
|
id='reason'
|
||||||
|
{...registerUpdate('reason')}
|
||||||
|
error={formStateUpdate.errors.reason?.message}
|
||||||
|
placeholder='Optional reason for blocking this slot'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex justify-end gap-2 p-4'>
|
||||||
|
<Button
|
||||||
|
type='submit'
|
||||||
|
variant='primary'
|
||||||
|
disabled={formStateUpdate.isSubmitting}
|
||||||
|
>
|
||||||
|
{'Update Blocker'}
|
||||||
|
</Button>
|
||||||
|
{existingBlockedSlotId && (
|
||||||
|
<Button
|
||||||
|
type='button'
|
||||||
|
variant='destructive'
|
||||||
|
onClick={onDeleteSubmit}
|
||||||
|
>
|
||||||
|
Delete Blocker
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{formStateUpdate.errors.root && (
|
||||||
|
<p className='text-red-500 text-sm mt-1'>
|
||||||
|
{formStateUpdate.errors.root.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</form>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<div className='flex items-center justify-center h-full'>
|
||||||
|
<Card className='w-[max(80%, 500px)] max-w-screen p-0 gap-0 max-xl:w-[95%] mx-auto'>
|
||||||
|
<CardHeader className='p-0 m-0 gap-0 px-6'>
|
||||||
|
<div className='h-full mt-0 ml-2 mb-16 flex items-center justify-between max-sm:grid max-sm:grid-row-start:auto max-sm:mb-6 max-sm:mt-10 max-sm:ml-0'>
|
||||||
|
<div className='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||||
|
<Logo colorType='monochrome' logoType='submark' width={50} />
|
||||||
|
</div>
|
||||||
|
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||||
|
<h1 className='text-center'>{'Create Blocker'}</h1>
|
||||||
|
</div>
|
||||||
|
<div className='w-0 sm:w-[100px]'></div>
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<form onSubmit={onCreateSubmit}>
|
||||||
|
<div className='grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3'>
|
||||||
|
<LabeledInput
|
||||||
|
label='Start Time'
|
||||||
|
type='datetime-local'
|
||||||
|
id='start_time'
|
||||||
|
{...registerCreate('start_time')}
|
||||||
|
error={formStateCreate.errors.start_time?.message}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<LabeledInput
|
||||||
|
label='End Time'
|
||||||
|
type='datetime-local'
|
||||||
|
id='end_time'
|
||||||
|
{...registerCreate('end_time')}
|
||||||
|
error={formStateCreate.errors.end_time?.message}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<LabeledInput
|
||||||
|
label='Reason'
|
||||||
|
type='text'
|
||||||
|
id='reason'
|
||||||
|
{...registerCreate('reason')}
|
||||||
|
error={formStateCreate.errors.reason?.message}
|
||||||
|
placeholder='Optional reason for blocking this slot'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex justify-end gap-2 p-4'>
|
||||||
|
<Button
|
||||||
|
type='submit'
|
||||||
|
variant='primary'
|
||||||
|
disabled={formStateCreate.isSubmitting}
|
||||||
|
>
|
||||||
|
{'Create Blocker'}
|
||||||
|
</Button>
|
||||||
|
{existingBlockedSlotId && (
|
||||||
|
<Button
|
||||||
|
type='button'
|
||||||
|
variant='destructive'
|
||||||
|
onClick={onDeleteSubmit}
|
||||||
|
>
|
||||||
|
Delete Blocker
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{formStateCreate.errors.root && (
|
||||||
|
<p className='text-red-500 text-sm mt-1'>
|
||||||
|
{formStateCreate.errors.root.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</form>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import { Button } from '@/components/ui/button';
|
||||||
import Logo from '@/components/misc/logo';
|
import Logo from '@/components/misc/logo';
|
||||||
import TimePicker from '@/components/time-picker';
|
import TimePicker from '@/components/time-picker';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
|
||||||
import {
|
import {
|
||||||
usePostApiEvent,
|
usePostApiEvent,
|
||||||
useGetApiEventEventID,
|
useGetApiEventEventID,
|
||||||
|
@ -21,6 +20,17 @@ import { useSearchParams } from 'next/navigation';
|
||||||
|
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
import { PublicUserSchema } from '@/app/api/user/validation';
|
import { PublicUserSchema } from '@/app/api/user/validation';
|
||||||
|
import Calendar from '@/components/calendar';
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from '../ui/dialog';
|
||||||
|
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||||
|
|
||||||
type User = zod.output<typeof PublicUserSchema>;
|
type User = zod.output<typeof PublicUserSchema>;
|
||||||
|
|
||||||
|
@ -41,17 +51,19 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
const startFromUrl = searchParams.get('start');
|
const startFromUrl = searchParams.get('start');
|
||||||
const endFromUrl = searchParams.get('end');
|
const endFromUrl = searchParams.get('end');
|
||||||
|
|
||||||
const { mutate: createEvent, status, isSuccess, error } = usePostApiEvent();
|
const {
|
||||||
const { data, isLoading, error: fetchError } = useGetApiUserMe();
|
mutateAsync: createEvent,
|
||||||
|
status,
|
||||||
|
isSuccess,
|
||||||
|
error,
|
||||||
|
} = usePostApiEvent();
|
||||||
const { data: eventData } = useGetApiEventEventID(props.eventId!, {
|
const { data: eventData } = useGetApiEventEventID(props.eventId!, {
|
||||||
query: { enabled: props.type === 'edit' },
|
query: { enabled: props.type === 'edit' },
|
||||||
});
|
});
|
||||||
|
const { data, isLoading, isError } = useGetApiUserMe();
|
||||||
const patchEvent = usePatchApiEventEventID();
|
const patchEvent = usePatchApiEventEventID();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
// Extract event fields for form defaults
|
|
||||||
const event = eventData?.data?.event;
|
|
||||||
|
|
||||||
// State for date and time fields
|
// State for date and time fields
|
||||||
const [startDate, setStartDate] = React.useState<Date | undefined>(undefined);
|
const [startDate, setStartDate] = React.useState<Date | undefined>(undefined);
|
||||||
const [startTime, setStartTime] = React.useState('');
|
const [startTime, setStartTime] = React.useState('');
|
||||||
|
@ -68,24 +80,28 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
const [location, setLocation] = React.useState('');
|
const [location, setLocation] = React.useState('');
|
||||||
const [description, setDescription] = React.useState('');
|
const [description, setDescription] = React.useState('');
|
||||||
|
|
||||||
|
const [calendarOpen, setCalendarOpen] = React.useState(false);
|
||||||
|
|
||||||
// Update state when event data loads
|
// Update state when event data loads
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (props.type === 'edit' && event) {
|
if (props.type === 'edit' && eventData?.data?.event) {
|
||||||
setTitle(event.title || '');
|
setTitle(eventData?.data?.event.title || '');
|
||||||
// Parse start_time and end_time
|
// Parse start_time and end_time
|
||||||
if (event.start_time) {
|
if (eventData?.data?.event.start_time) {
|
||||||
const start = new Date(event.start_time);
|
const start = new Date(eventData?.data?.event.start_time);
|
||||||
setStartDate(start);
|
setStartDate(start);
|
||||||
setStartTime(start.toTimeString().slice(0, 5)); // "HH:mm"
|
setStartTime(start.toTimeString().slice(0, 5)); // "HH:mm"
|
||||||
}
|
}
|
||||||
if (event.end_time) {
|
if (eventData?.data?.event.end_time) {
|
||||||
const end = new Date(event.end_time);
|
const end = new Date(eventData?.data?.event.end_time);
|
||||||
setEndDate(end);
|
setEndDate(end);
|
||||||
setEndTime(end.toTimeString().slice(0, 5)); // "HH:mm"
|
setEndTime(end.toTimeString().slice(0, 5)); // "HH:mm"
|
||||||
}
|
}
|
||||||
setLocation(event.location || '');
|
setLocation(eventData?.data?.event.location || '');
|
||||||
setDescription(event.description || '');
|
setDescription(eventData?.data?.event.description || '');
|
||||||
setSelectedParticipants(event.participants?.map((u) => u.user) || []);
|
setSelectedParticipants(
|
||||||
|
eventData?.data?.event.participants?.map((u) => u.user) || [],
|
||||||
|
);
|
||||||
} else if (props.type === 'create' && startFromUrl && endFromUrl) {
|
} else if (props.type === 'create' && startFromUrl && endFromUrl) {
|
||||||
// If creating a new event with URL params, set title and dates
|
// If creating a new event with URL params, set title and dates
|
||||||
setTitle('');
|
setTitle('');
|
||||||
|
@ -96,7 +112,7 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
setEndDate(end);
|
setEndDate(end);
|
||||||
setEndTime(end.toTimeString().slice(0, 5)); // "HH:mm"
|
setEndTime(end.toTimeString().slice(0, 5)); // "HH:mm"
|
||||||
}
|
}
|
||||||
}, [event, props.type, startFromUrl, endFromUrl]);
|
}, [eventData?.data?.event, props.type, startFromUrl, endFromUrl]);
|
||||||
|
|
||||||
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -138,8 +154,10 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
participants: selectedParticipants.map((u) => u.id),
|
participants: selectedParticipants.map((u) => u.id),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let eventID: string | undefined;
|
||||||
|
|
||||||
if (props.type === 'edit' && props.eventId) {
|
if (props.type === 'edit' && props.eventId) {
|
||||||
await patchEvent.mutateAsync({
|
const mutationResult = await patchEvent.mutateAsync({
|
||||||
eventID: props.eventId,
|
eventID: props.eventId,
|
||||||
data: {
|
data: {
|
||||||
title: data.title,
|
title: data.title,
|
||||||
|
@ -150,18 +168,20 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
participants: data.participants,
|
participants: data.participants,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
eventID = mutationResult.data.event.id;
|
||||||
console.log('Updating event');
|
console.log('Updating event');
|
||||||
} else {
|
} else {
|
||||||
console.log('Creating event');
|
console.log('Creating event');
|
||||||
createEvent({ data });
|
const mutationResult = await createEvent({ data });
|
||||||
|
eventID = mutationResult.data.event.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.custom((t) => (
|
toast.custom((t) => (
|
||||||
<ToastInner
|
<ToastInner
|
||||||
toastId={t}
|
toastId={t}
|
||||||
title='Event saved'
|
title='Event saved'
|
||||||
description={event?.title}
|
description={eventData?.data?.event.title}
|
||||||
onAction={() => router.push(`/events/${event?.id}`)}
|
onAction={() => router.push(`/events/${eventID}`)}
|
||||||
variant='success'
|
variant='success'
|
||||||
buttonText='show'
|
buttonText='show'
|
||||||
/>
|
/>
|
||||||
|
@ -170,173 +190,216 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
router.back();
|
router.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate values for organiser, created, and updated
|
|
||||||
const organiserValue = isLoading
|
|
||||||
? 'Loading...'
|
|
||||||
: data?.data.user?.name || 'Unknown User';
|
|
||||||
|
|
||||||
// Use DB values for created_at/updated_at in edit mode
|
// Use DB values for created_at/updated_at in edit mode
|
||||||
const createdAtValue =
|
const createdAtValue =
|
||||||
props.type === 'edit' && event?.created_at
|
props.type === 'edit' && eventData?.data?.event?.created_at
|
||||||
? event.created_at
|
? eventData.data.event.created_at
|
||||||
: new Date().toISOString();
|
: new Date().toISOString();
|
||||||
const updatedAtValue =
|
const updatedAtValue =
|
||||||
props.type === 'edit' && event?.updated_at
|
props.type === 'edit' && eventData?.data?.event?.updated_at
|
||||||
? event.updated_at
|
? eventData.data.event.updated_at
|
||||||
: new Date().toISOString();
|
: new Date().toISOString();
|
||||||
|
|
||||||
// Format date for display
|
// Format date for display
|
||||||
const createdAtDisplay = new Date(createdAtValue).toLocaleDateString();
|
const createdAtDisplay = new Date(createdAtValue).toLocaleDateString();
|
||||||
const updatedAtDisplay = new Date(updatedAtValue).toLocaleDateString();
|
const updatedAtDisplay = new Date(updatedAtValue).toLocaleDateString();
|
||||||
|
|
||||||
|
const [isClient, setIsClient] = React.useState(false);
|
||||||
|
React.useEffect(() => {
|
||||||
|
setIsClient(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (props.type === 'edit' && isLoading) return <div>Loading...</div>;
|
if (props.type === 'edit' && isLoading) return <div>Loading...</div>;
|
||||||
if (props.type === 'edit' && fetchError)
|
if (props.type === 'edit' && isError) return <div>Error loading event.</div>;
|
||||||
return <div>Error loading event.</div>;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className='flex flex-col gap-5 w-full' onSubmit={handleSubmit}>
|
<Dialog open={calendarOpen} onOpenChange={setCalendarOpen}>
|
||||||
<div className='grid grid-row-start:auto gap-4 sm:gap-8 w-full'>
|
<form
|
||||||
<div className='h-full w-full mt-0 ml-2 mb-16 flex items-center max-sm:grid max-sm:grid-row-start:auto max-sm:mb-6 max-sm:mt-10 max-sm:ml-0'>
|
className='flex flex-col gap-5 w-full'
|
||||||
<div className='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
onSubmit={handleSubmit}
|
||||||
<Logo colorType='monochrome' logoType='submark' width={50} />
|
data-cy='event-form'
|
||||||
</div>
|
>
|
||||||
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full'>
|
<div className='grid grid-row-start:auto gap-4 sm:gap-8 w-full'>
|
||||||
<LabeledInput
|
<div className='h-full w-full mt-0 ml-2 mb-16 flex items-center max-sm:grid max-sm:grid-row-start:auto max-sm:mb-6 max-sm:mt-10 max-sm:ml-0'>
|
||||||
type='text'
|
<div className='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||||
label='Event Name'
|
<Logo colorType='monochrome' logoType='submark' width={50} />
|
||||||
placeholder={props.type === 'create' ? 'New Event' : 'Event Name'}
|
|
||||||
name='eventName'
|
|
||||||
variantSize='big'
|
|
||||||
value={title}
|
|
||||||
onChange={(e) => setTitle(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className='w-0 sm:w-[50px]'></div>
|
|
||||||
</div>
|
|
||||||
<div className='grid grid-cols-4 gap-4 h-full w-full max-lg:grid-cols-2 max-sm:grid-cols-1'>
|
|
||||||
<div>
|
|
||||||
<TimePicker
|
|
||||||
dateLabel='start Time'
|
|
||||||
timeLabel=' '
|
|
||||||
date={startDate}
|
|
||||||
setDate={setStartDate}
|
|
||||||
time={startTime}
|
|
||||||
setTime={setStartTime}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<TimePicker
|
|
||||||
dateLabel='end Time'
|
|
||||||
timeLabel=' '
|
|
||||||
date={endDate}
|
|
||||||
setDate={setEndDate}
|
|
||||||
time={endTime}
|
|
||||||
setTime={setEndTime}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className='w-54'>
|
|
||||||
<LabeledInput
|
|
||||||
type='text'
|
|
||||||
label='Location'
|
|
||||||
placeholder='where is the event?'
|
|
||||||
name='eventLocation'
|
|
||||||
value={location}
|
|
||||||
onChange={(e) => setLocation(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-4'>
|
|
||||||
<div className='flex flex-row gap-2'>
|
|
||||||
<Label className='w-[70px]'>created:</Label>
|
|
||||||
<Label className='text-[var(--color-neutral-300)]'>
|
|
||||||
{createdAtDisplay}
|
|
||||||
</Label>
|
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-row gap-2'>
|
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full'>
|
||||||
<Label className='w-[70px]'>updated:</Label>
|
<LabeledInput
|
||||||
<p className='text-[var(--color-neutral-300)]'>
|
type='text'
|
||||||
{updatedAtDisplay}
|
label='Event Name'
|
||||||
</p>
|
placeholder={
|
||||||
|
props.type === 'create' ? 'New Event' : 'Event Name'
|
||||||
|
}
|
||||||
|
name='eventName'
|
||||||
|
variantSize='big'
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
data-cy='event-name-input'
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className='w-0 sm:w-[50px]'></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className='grid grid-cols-4 gap-4 h-full w-full max-2xl:grid-cols-2 max-sm:grid-cols-1'>
|
||||||
<div className='h-full w-full grid grid-cols-2 gap-4 max-sm:grid-cols-1'>
|
<div>
|
||||||
<div className='h-full w-full grid grid-flow-row gap-4'>
|
<TimePicker
|
||||||
<div className='h-full w-full'>
|
dateLabel='start Time'
|
||||||
|
timeLabel=' '
|
||||||
|
date={startDate}
|
||||||
|
setDate={setStartDate}
|
||||||
|
time={startTime}
|
||||||
|
setTime={setStartTime}
|
||||||
|
data-cy='event-start-time-picker'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<TimePicker
|
||||||
|
dateLabel='end Time'
|
||||||
|
timeLabel=' '
|
||||||
|
date={endDate}
|
||||||
|
setDate={setEndDate}
|
||||||
|
time={endTime}
|
||||||
|
setTime={setEndTime}
|
||||||
|
data-cy='event-end-time-picker'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='w-54'>
|
||||||
|
<LabeledInput
|
||||||
|
type='text'
|
||||||
|
label='Location'
|
||||||
|
placeholder='where is the event?'
|
||||||
|
name='eventLocation'
|
||||||
|
value={location}
|
||||||
|
onChange={(e) => setLocation(e.target.value)}
|
||||||
|
data-cy='event-location-input'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex flex-col gap-4'>
|
||||||
<div className='flex flex-row gap-2'>
|
<div className='flex flex-row gap-2'>
|
||||||
<Label>Organiser:</Label>
|
<Label className='w-[70px]'>created:</Label>
|
||||||
<Label className='text-[var(--color-neutral-300)]'>
|
<Label className='text-[var(--color-neutral-300)]'>
|
||||||
{organiserValue}
|
{createdAtDisplay}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
|
<div className='flex flex-row gap-2'>
|
||||||
|
<Label className='w-[70px]'>updated:</Label>
|
||||||
|
<p className='text-[var(--color-neutral-300)]'>
|
||||||
|
{updatedAtDisplay}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='h-full w-full grid grid-cols-2 gap-4 max-sm:grid-cols-1'>
|
||||||
|
<div className='h-full w-full grid grid-flow-row gap-4'>
|
||||||
|
<div className='h-full w-full'>
|
||||||
|
<div className='flex flex-row gap-2'>
|
||||||
|
<Label>Organiser:</Label>
|
||||||
|
<p className='text-[var(--color-neutral-300)]'>
|
||||||
|
{!isClient || isLoading
|
||||||
|
? 'Loading...'
|
||||||
|
: data?.data.user.name || 'Unknown User'}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='h-full w-full'>
|
||||||
|
<LabeledInput
|
||||||
|
type='text'
|
||||||
|
label='Event Description'
|
||||||
|
placeholder='What is the event about?'
|
||||||
|
name='eventDescription'
|
||||||
|
variantSize='textarea'
|
||||||
|
value={description}
|
||||||
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
|
data-cy='event-description-input'
|
||||||
|
></LabeledInput>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-full w-full'>
|
<div className='h-full w-full'>
|
||||||
<LabeledInput
|
<Label>Participants</Label>
|
||||||
type='text'
|
<UserSearchInput
|
||||||
label='Event Description'
|
selectedUsers={selectedParticipants}
|
||||||
placeholder='What is the event about?'
|
addUserAction={(user) => {
|
||||||
name='eventDescription'
|
setSelectedParticipants((current) =>
|
||||||
variantSize='textarea'
|
current.find((u) => u.id === user.id)
|
||||||
value={description}
|
? current
|
||||||
onChange={(e) => setDescription(e.target.value)}
|
: [...current, user],
|
||||||
></LabeledInput>
|
);
|
||||||
|
}}
|
||||||
|
removeUserAction={(user) => {
|
||||||
|
setSelectedParticipants((current) =>
|
||||||
|
current.filter((u) => u.id !== user.id),
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button variant='primary'>Calendar</Button>
|
||||||
|
</DialogTrigger>
|
||||||
|
<div className='grid grid-cols-1 mt-3'>
|
||||||
|
{selectedParticipants.map((user) => (
|
||||||
|
<ParticipantListEntry
|
||||||
|
key={user.id}
|
||||||
|
user={user}
|
||||||
|
status='PENDING'
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-full w-full'>
|
|
||||||
<Label>Participants</Label>
|
|
||||||
<UserSearchInput
|
|
||||||
selectedUsers={selectedParticipants}
|
|
||||||
addUserAction={(user) => {
|
|
||||||
setSelectedParticipants((current) =>
|
|
||||||
current.find((u) => u.id === user.id)
|
|
||||||
? current
|
|
||||||
: [...current, user],
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
removeUserAction={(user) => {
|
|
||||||
setSelectedParticipants((current) =>
|
|
||||||
current.filter((u) => u.id !== user.id),
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className='grid grid-cols-1 mt-3 sm:max-h-60 sm:grid-cols-2 sm:overflow-y-auto sm:mb-0'>
|
|
||||||
{selectedParticipants.map((user) => (
|
|
||||||
<ParticipantListEntry
|
|
||||||
key={user.id}
|
|
||||||
user={user}
|
|
||||||
status='PENDING'
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
||||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||||
<Button
|
<Button
|
||||||
type='button'
|
type='button'
|
||||||
variant='secondary'
|
variant='secondary'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.back();
|
router.back();
|
||||||
console.log('user aborted - no change in database');
|
console.log('user aborted - no change in database');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
cancel
|
cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||||
<Button
|
<Button
|
||||||
type='submit'
|
type='submit'
|
||||||
variant='primary'
|
variant='primary'
|
||||||
disabled={status === 'pending'}
|
disabled={status === 'pending'}
|
||||||
>
|
data-cy='event-save-button'
|
||||||
{status === 'pending' ? 'Saving...' : 'save event'}
|
>
|
||||||
</Button>
|
{status === 'pending' ? 'Saving...' : 'save event'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{isSuccess && <p>Event created!</p>}
|
||||||
|
{error && <p className='text-red-500'>Error: {error.message}</p>}
|
||||||
</div>
|
</div>
|
||||||
{isSuccess && <p>Event created!</p>}
|
</form>
|
||||||
{error && <p className='text-red-500'>Error: {error.message}</p>}
|
<DialogContent className='sm:max-w-[750px]'>
|
||||||
</div>
|
<DialogHeader>
|
||||||
</form>
|
<DialogTitle>Calendar</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
Calendar for selected participants
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter className='max-w-[calc(100svw-70px)]'>
|
||||||
|
<Calendar
|
||||||
|
userId={selectedParticipants.map((u) => u.id)}
|
||||||
|
additionalEvents={[
|
||||||
|
{
|
||||||
|
id: 'temp-event',
|
||||||
|
title: title || 'New Event',
|
||||||
|
start: startDate ? new Date(startDate) : new Date(),
|
||||||
|
end: endDate ? new Date(endDate) : new Date(),
|
||||||
|
type: 'event',
|
||||||
|
userId: 'create-event',
|
||||||
|
colorOverride: '#ff9800',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
height='600px'
|
||||||
|
/>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,21 @@ import React, { useState, useRef } from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
import LabeledInput from '@/components/custom-ui/labeled-input';
|
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import useZodForm from '@/lib/hooks/useZodForm';
|
import useZodForm from '@/lib/hooks/useZodForm';
|
||||||
import { loginSchema, registerSchema } from '@/lib/auth/validation';
|
import { loginSchema, registerSchema } from '@/lib/auth/validation';
|
||||||
import { loginAction } from '@/lib/auth/login';
|
import { loginAction } from '@/lib/auth/login';
|
||||||
import { registerAction } from '@/lib/auth/register';
|
import { registerAction } from '@/lib/auth/register';
|
||||||
|
import { IconButton } from '../buttons/icon-button';
|
||||||
|
import {
|
||||||
|
FileKey,
|
||||||
|
FileKey2,
|
||||||
|
LogIn,
|
||||||
|
MailOpen,
|
||||||
|
RotateCcwKey,
|
||||||
|
UserCheck,
|
||||||
|
UserPen,
|
||||||
|
UserPlus,
|
||||||
|
} from 'lucide-react';
|
||||||
|
|
||||||
function LoginFormElement({
|
function LoginFormElement({
|
||||||
setIsSignUp,
|
setIsSignUp,
|
||||||
|
@ -56,6 +66,7 @@ function LoginFormElement({
|
||||||
<LabeledInput
|
<LabeledInput
|
||||||
type='text'
|
type='text'
|
||||||
label='E-Mail or Username'
|
label='E-Mail or Username'
|
||||||
|
icon={UserCheck}
|
||||||
placeholder='What you are known as'
|
placeholder='What you are known as'
|
||||||
error={formState.errors.email?.message}
|
error={formState.errors.email?.message}
|
||||||
{...register('email')}
|
{...register('email')}
|
||||||
|
@ -64,16 +75,22 @@ function LoginFormElement({
|
||||||
<LabeledInput
|
<LabeledInput
|
||||||
type='password'
|
type='password'
|
||||||
label='Password'
|
label='Password'
|
||||||
|
icon={FileKey}
|
||||||
placeholder="Let's hope you remember it"
|
placeholder="Let's hope you remember it"
|
||||||
error={formState.errors.password?.message}
|
error={formState.errors.password?.message}
|
||||||
{...register('password')}
|
{...register('password')}
|
||||||
data-cy='password-input'
|
data-cy='password-input'
|
||||||
/>
|
/>
|
||||||
<div className='grid grid-rows-2 gap-2'>
|
<div className='grid grid-rows-2 gap-2'>
|
||||||
<Button type='submit' variant='primary' data-cy='login-button'>
|
<IconButton
|
||||||
|
type='submit'
|
||||||
|
variant='primary'
|
||||||
|
data-cy='login-button'
|
||||||
|
icon={LogIn}
|
||||||
|
>
|
||||||
Login
|
Login
|
||||||
</Button>
|
</IconButton>
|
||||||
<Button
|
<IconButton
|
||||||
type='button'
|
type='button'
|
||||||
variant='outline_primary'
|
variant='outline_primary'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -81,9 +98,10 @@ function LoginFormElement({
|
||||||
setIsSignUp((v) => !v);
|
setIsSignUp((v) => !v);
|
||||||
}}
|
}}
|
||||||
data-cy='register-switch'
|
data-cy='register-switch'
|
||||||
|
icon={UserPlus}
|
||||||
>
|
>
|
||||||
Sign Up
|
Sign Up
|
||||||
</Button>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{formState.errors.root?.message && (
|
{formState.errors.root?.message && (
|
||||||
|
@ -156,27 +174,30 @@ function RegisterFormElement({
|
||||||
{...register('lastName')}
|
{...register('lastName')}
|
||||||
data-cy='last-name-input'
|
data-cy='last-name-input'
|
||||||
/>
|
/>
|
||||||
<LabeledInput
|
|
||||||
type='email'
|
|
||||||
label='E-Mail'
|
|
||||||
placeholder='Your email address'
|
|
||||||
autocomplete='email'
|
|
||||||
error={formState.errors.email?.message}
|
|
||||||
{...register('email')}
|
|
||||||
data-cy='email-input'
|
|
||||||
/>
|
|
||||||
<LabeledInput
|
<LabeledInput
|
||||||
type='text'
|
type='text'
|
||||||
label='Username'
|
label='Username'
|
||||||
|
icon={UserPen}
|
||||||
placeholder='Your username'
|
placeholder='Your username'
|
||||||
autocomplete='username'
|
autocomplete='username'
|
||||||
error={formState.errors.username?.message}
|
error={formState.errors.username?.message}
|
||||||
{...register('username')}
|
{...register('username')}
|
||||||
data-cy='username-input'
|
data-cy='username-input'
|
||||||
/>
|
/>
|
||||||
|
<LabeledInput
|
||||||
|
type='email'
|
||||||
|
label='E-Mail'
|
||||||
|
icon={MailOpen}
|
||||||
|
placeholder='Your email address'
|
||||||
|
autocomplete='email'
|
||||||
|
error={formState.errors.email?.message}
|
||||||
|
{...register('email')}
|
||||||
|
data-cy='email-input'
|
||||||
|
/>
|
||||||
<LabeledInput
|
<LabeledInput
|
||||||
type='password'
|
type='password'
|
||||||
label='Password'
|
label='Password'
|
||||||
|
icon={FileKey2}
|
||||||
placeholder='Create a password'
|
placeholder='Create a password'
|
||||||
autocomplete='new-password'
|
autocomplete='new-password'
|
||||||
error={formState.errors.password?.message}
|
error={formState.errors.password?.message}
|
||||||
|
@ -186,6 +207,7 @@ function RegisterFormElement({
|
||||||
<LabeledInput
|
<LabeledInput
|
||||||
type='password'
|
type='password'
|
||||||
label='Confirm Password'
|
label='Confirm Password'
|
||||||
|
icon={RotateCcwKey}
|
||||||
placeholder='Repeat your password'
|
placeholder='Repeat your password'
|
||||||
autocomplete='new-password'
|
autocomplete='new-password'
|
||||||
error={formState.errors.confirmPassword?.message}
|
error={formState.errors.confirmPassword?.message}
|
||||||
|
@ -193,19 +215,25 @@ function RegisterFormElement({
|
||||||
data-cy='confirm-password-input'
|
data-cy='confirm-password-input'
|
||||||
/>
|
/>
|
||||||
<div className='grid grid-rows-2 gap-2'>
|
<div className='grid grid-rows-2 gap-2'>
|
||||||
<Button type='submit' variant='primary' data-cy='register-button'>
|
<IconButton
|
||||||
|
type='submit'
|
||||||
|
variant='primary'
|
||||||
|
data-cy='register-button'
|
||||||
|
icon={UserPlus}
|
||||||
|
>
|
||||||
Sign Up
|
Sign Up
|
||||||
</Button>
|
</IconButton>
|
||||||
<Button
|
<IconButton
|
||||||
type='button'
|
type='button'
|
||||||
variant='outline_primary'
|
variant='outline_primary'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
formRef?.current?.reset();
|
formRef?.current?.reset();
|
||||||
setIsSignUp((v) => !v);
|
setIsSignUp((v) => !v);
|
||||||
}}
|
}}
|
||||||
|
icon={LogIn}
|
||||||
>
|
>
|
||||||
Back to Login
|
Back to Login
|
||||||
</Button>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{formState.errors.root?.message && (
|
{formState.errors.root?.message && (
|
||||||
|
|
|
@ -7,12 +7,12 @@ import UserDropdown from '@/components/misc/user-dropdown';
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
title: 'Calendar',
|
title: 'Inbox',
|
||||||
url: '#',
|
url: '#',
|
||||||
icon: Inbox,
|
icon: Inbox,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Friends',
|
title: 'Notifications',
|
||||||
url: '#',
|
url: '#',
|
||||||
icon: BellRing,
|
icon: BellRing,
|
||||||
},
|
},
|
||||||
|
@ -25,17 +25,21 @@ export default function Header({
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<div className='w-full grid grid-rows-[50px_1fr] h-screen'>
|
<div className='w-full grid grid-rows-[50px_1fr] h-screen'>
|
||||||
<header className='border-b-1 grid-cols-[1fr_3fr_1fr] grid items-center px-2 shadow-md'>
|
<header
|
||||||
|
className='border-b-1 grid-cols-[1fr_3fr_1fr] grid items-center px-2 shadow-md'
|
||||||
|
data-cy='header'
|
||||||
|
>
|
||||||
<span className='flex justify-start'>
|
<span className='flex justify-start'>
|
||||||
<SidebarTrigger variant='outline_primary' size='icon' />
|
<SidebarTrigger variant='outline_primary' size='icon' />
|
||||||
</span>
|
</span>
|
||||||
<span className='flex justify-center'>Search</span>
|
<span className='flex justify-center'></span>
|
||||||
<span className='flex gap-1 justify-end'>
|
<span className='flex gap-1 justify-end'>
|
||||||
<ThemePicker />
|
<ThemePicker />
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<NotificationButton
|
<NotificationButton
|
||||||
|
disabled
|
||||||
key={item.title}
|
key={item.title}
|
||||||
variant='outline_primary'
|
variant='outline_muted'
|
||||||
dotVariant='hidden'
|
dotVariant='hidden'
|
||||||
size='icon'
|
size='icon'
|
||||||
>
|
>
|
||||||
|
|
36
src/components/misc/profile-picture-upload.tsx
Normal file
36
src/components/misc/profile-picture-upload.tsx
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import Image from 'next/image';
|
||||||
|
import { Avatar } from '../ui/avatar';
|
||||||
|
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||||
|
import { User } from 'lucide-react';
|
||||||
|
|
||||||
|
import { Input } from '../ui/input';
|
||||||
|
|
||||||
|
export default function ProfilePictureUpload({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: {
|
||||||
|
className?: string;
|
||||||
|
} & React.InputHTMLAttributes<HTMLInputElement>) {
|
||||||
|
const { data } = useGetApiUserMe();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<span className='relative flex space-6'>
|
||||||
|
<Input className={className} id='pic-upload' type='file' {...props} />
|
||||||
|
<Avatar className='flex justify-center items-center ml-6 shadow-md border h-[36px] w-[36px]'>
|
||||||
|
{data?.data.user.image ? (
|
||||||
|
<Image
|
||||||
|
src={data?.data.user.image}
|
||||||
|
alt='Avatar'
|
||||||
|
width='20'
|
||||||
|
height='20'
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<User />
|
||||||
|
)}
|
||||||
|
</Avatar>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ export default function UserCard() {
|
||||||
)}
|
)}
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<div className='flex justify-center'>{data?.data.user.name}</div>
|
<div className='flex justify-center'>{data?.data.user.name}</div>
|
||||||
<div className='flex justify-center text-text-muted'>
|
<div className='flex justify-center text-text-muted text-[12px]'>
|
||||||
{data?.data.user.email}
|
{data?.data.user.email}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,6 +17,7 @@ import UserCard from '@/components/misc/user-card';
|
||||||
|
|
||||||
export default function UserDropdown() {
|
export default function UserDropdown() {
|
||||||
const { data } = useGetApiUserMe();
|
const { data } = useGetApiUserMe();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
|
@ -41,11 +42,13 @@ export default function UserDropdown() {
|
||||||
<UserCard />
|
<UserCard />
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem>Settings</DropdownMenuItem>
|
<Link href='/settings'>
|
||||||
|
<DropdownMenuItem>Settings</DropdownMenuItem>
|
||||||
|
</Link>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem>
|
<Link href='/logout'>
|
||||||
<Link href='/logout'>Logout</Link>
|
<DropdownMenuItem>Logout</DropdownMenuItem>
|
||||||
</DropdownMenuItem>
|
</Link>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
);
|
);
|
||||||
|
|
|
@ -83,7 +83,7 @@ button.rbc-input::-moz-focus-inner {
|
||||||
}
|
}
|
||||||
|
|
||||||
.rbc-off-range-bg {
|
.rbc-off-range-bg {
|
||||||
background: #e6e6e6;
|
background: var(--color-neutral-700);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rbc-header {
|
.rbc-header {
|
||||||
|
@ -596,7 +596,7 @@ button.rbc-input::-moz-focus-inner {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
|
|
||||||
/*Own changes 06*/
|
/*Own changes 06*/
|
||||||
background-color: #383838;
|
background-color: var(--color-neutral-700);
|
||||||
/*Own changes 06*/
|
/*Own changes 06*/
|
||||||
}
|
}
|
||||||
.rbc-time-column .rbc-timeslot-group {
|
.rbc-time-column .rbc-timeslot-group {
|
||||||
|
@ -606,7 +606,7 @@ button.rbc-input::-moz-focus-inner {
|
||||||
}
|
}
|
||||||
|
|
||||||
.rbc-timeslot-group {
|
.rbc-timeslot-group {
|
||||||
border-bottom: 1px solid #8d8d8d; /*#ddd*/
|
border-bottom: 1px solid var(--color-neutral-300); /*#ddd*/
|
||||||
min-height: 40px;
|
min-height: 40px;
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
display: -ms-flexbox;
|
display: -ms-flexbox;
|
||||||
|
@ -624,12 +624,13 @@ button.rbc-input::-moz-focus-inner {
|
||||||
flex: none;
|
flex: none;
|
||||||
|
|
||||||
/*Own changes 07*/
|
/*Own changes 07*/
|
||||||
background-color: #8d8d8d;
|
background-color: var(--color-neutral-500);
|
||||||
/*Own changes 07*/
|
/*Own changes 07*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.rbc-label {
|
.rbc-label {
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
|
width: 54.3542px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rbc-day-slot {
|
.rbc-day-slot {
|
||||||
|
@ -686,7 +687,7 @@ button.rbc-input::-moz-focus-inner {
|
||||||
min-height: 1em;
|
min-height: 1em;
|
||||||
}
|
}
|
||||||
.rbc-day-slot .rbc-time-slot {
|
.rbc-day-slot .rbc-time-slot {
|
||||||
border-top: 1px solid #383838; /*#f7f7f7*/
|
border-top: 1px solid transparent; /*#f7f7f7*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.rbc-time-view-resources .rbc-time-gutter,
|
.rbc-time-view-resources .rbc-time-gutter,
|
||||||
|
@ -782,7 +783,7 @@ button.rbc-input::-moz-focus-inner {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
/*Own changes 05*/
|
/*Own changes 05*/
|
||||||
background-color: #555555;
|
background-color: var(--color-neutral-500);
|
||||||
/*Own changes 05*/
|
/*Own changes 05*/
|
||||||
}
|
}
|
||||||
.rbc-time-view .rbc-allday-cell + .rbc-allday-cell {
|
.rbc-time-view .rbc-allday-cell + .rbc-allday-cell {
|
||||||
|
@ -809,6 +810,10 @@ button.rbc-input::-moz-focus-inner {
|
||||||
-webkit-box-direction: normal;
|
-webkit-box-direction: normal;
|
||||||
-ms-flex-direction: row;
|
-ms-flex-direction: row;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
margin-right: 14px;
|
||||||
|
@media ((hover: none) and (pointer: coarse)) {
|
||||||
|
margin-right: 0px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.rbc-rtl .rbc-time-header.rbc-overflowing {
|
.rbc-rtl .rbc-time-header.rbc-overflowing {
|
||||||
border-right-width: 0;
|
border-right-width: 0;
|
||||||
|
@ -872,7 +877,7 @@ button.rbc-input::-moz-focus-inner {
|
||||||
}
|
}
|
||||||
|
|
||||||
.rbc-time-header-content {
|
.rbc-time-header-content {
|
||||||
border-bottom: 2px solid #717171; /*#ddd*/
|
border-bottom: 2px solid var(--color-neutral-400); /*#ddd*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.rbc-time-column :last-child {
|
.rbc-time-column :last-child {
|
||||||
|
@ -890,7 +895,7 @@ button.rbc-input::-moz-focus-inner {
|
||||||
/*Own changes 09*/
|
/*Own changes 09*/
|
||||||
}
|
}
|
||||||
.rbc-time-content > * + * > * {
|
.rbc-time-content > * + * > * {
|
||||||
border-left: 1px solid #c6c6c6; /*#ddd*/
|
border-left: 1px solid var(--color-neutral-300); /*#ddd*/
|
||||||
}
|
}
|
||||||
.rbc-rtl .rbc-time-content > * + * > * {
|
.rbc-rtl .rbc-time-content > * + * > * {
|
||||||
border-left-width: 0;
|
border-left-width: 0;
|
||||||
|
|
165
src/components/settings/settings-dropdown.tsx
Normal file
165
src/components/settings/settings-dropdown.tsx
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import type React from 'react';
|
||||||
|
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Command,
|
||||||
|
CommandEmpty,
|
||||||
|
CommandGroup,
|
||||||
|
CommandInput,
|
||||||
|
CommandItem,
|
||||||
|
CommandList,
|
||||||
|
} from '@/components/ui/command';
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverTrigger,
|
||||||
|
} from '@/components/ui/popover';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import {
|
||||||
|
Check,
|
||||||
|
ChevronDown,
|
||||||
|
User,
|
||||||
|
Bell,
|
||||||
|
Calendar,
|
||||||
|
Shield,
|
||||||
|
Palette,
|
||||||
|
Key,
|
||||||
|
} from 'lucide-react';
|
||||||
|
|
||||||
|
interface SettingsSection {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
description: string;
|
||||||
|
icon: React.ComponentType<{ className?: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SettingsDropdownProps {
|
||||||
|
currentSection: string;
|
||||||
|
onSectionChange: (section: string) => void;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const settingsSections: SettingsSection[] = [
|
||||||
|
{
|
||||||
|
label: 'Account',
|
||||||
|
value: 'general',
|
||||||
|
description: 'Manage account details',
|
||||||
|
icon: User,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Password',
|
||||||
|
value: 'password',
|
||||||
|
description: 'Manage your password',
|
||||||
|
icon: Key,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Notifications',
|
||||||
|
value: 'notifications',
|
||||||
|
description: 'Choose notification Preferences',
|
||||||
|
icon: Bell,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Calendar',
|
||||||
|
value: 'calendarAvailability',
|
||||||
|
description: 'Manage calendar display, availability and iCal integration',
|
||||||
|
icon: Calendar,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Privacy',
|
||||||
|
value: 'sharingPrivacy',
|
||||||
|
description: 'Control who can see your calendar and book time with you',
|
||||||
|
icon: Shield,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Appearance',
|
||||||
|
value: 'appearance',
|
||||||
|
description: 'Customize the look and feel of the application',
|
||||||
|
icon: Palette,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function SettingsDropdown({
|
||||||
|
currentSection,
|
||||||
|
onSectionChange,
|
||||||
|
className,
|
||||||
|
}: SettingsDropdownProps) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const currentSectionData = settingsSections.find(
|
||||||
|
(section) => section.value === currentSection,
|
||||||
|
);
|
||||||
|
const CurrentIcon = currentSectionData?.icon || User;
|
||||||
|
|
||||||
|
const handleSelect = (value: string) => {
|
||||||
|
onSectionChange(value);
|
||||||
|
setOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cn('w-full max-w-md', className)}>
|
||||||
|
<Popover open={open} onOpenChange={setOpen}>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant='outline_muted'
|
||||||
|
role='combobox'
|
||||||
|
aria-expanded={open}
|
||||||
|
className='w-full justify-between bg-popover text-text h-auto py-3'
|
||||||
|
>
|
||||||
|
<div className='flex items-center gap-3'>
|
||||||
|
<CurrentIcon className='h-4 w-4 text-muted-foreground' />
|
||||||
|
<div className='flex flex-col items-start text-left'>
|
||||||
|
<span className='font-medium'>{currentSectionData?.label}</span>
|
||||||
|
<p className='text-xs text-muted-foreground text-wrap'>
|
||||||
|
{currentSectionData?.description}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ChevronDown className='ml-2 h-4 w-4 shrink-0 opacity-50' />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className='w-full p-0' align='start'>
|
||||||
|
<Command>
|
||||||
|
<CommandInput placeholder='Search settings...' />
|
||||||
|
<CommandList>
|
||||||
|
<CommandEmpty>No settings found.</CommandEmpty>
|
||||||
|
<CommandGroup>
|
||||||
|
{settingsSections.map((section) => {
|
||||||
|
const Icon = section.icon;
|
||||||
|
return (
|
||||||
|
<CommandItem
|
||||||
|
key={section.value}
|
||||||
|
value={section.value}
|
||||||
|
onSelect={() => handleSelect(section.value)}
|
||||||
|
className='flex items-center justify-between p-3'
|
||||||
|
>
|
||||||
|
<div className='flex items-center gap-3'>
|
||||||
|
<Icon className='h-4 w-4 text-muted-foreground' />
|
||||||
|
<div className='flex flex-col'>
|
||||||
|
<span className='font-medium'>{section.label}</span>
|
||||||
|
<p className='text-xs text-muted-foreground text-wrap'>
|
||||||
|
{section.description}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Check
|
||||||
|
className={cn(
|
||||||
|
'ml-2 h-4 w-4',
|
||||||
|
currentSection === section.value
|
||||||
|
? 'opacity-100'
|
||||||
|
: 'opacity-0',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</CommandItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CommandGroup>
|
||||||
|
</CommandList>
|
||||||
|
</Command>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
59
src/components/settings/settings-page.tsx
Normal file
59
src/components/settings/settings-page.tsx
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
import { SettingsDropdown } from '@/components/settings/settings-dropdown';
|
||||||
|
|
||||||
|
import AccountTab from './tabs/account';
|
||||||
|
import NotificationsTab from './tabs/notifications';
|
||||||
|
import CalendarTab from './tabs/calendar';
|
||||||
|
import PrivacyTab from './tabs/privacy';
|
||||||
|
import AppearanceTab from './tabs/appearance';
|
||||||
|
import PasswordTab from './tabs/password';
|
||||||
|
|
||||||
|
export default function SettingsPage() {
|
||||||
|
const [currentSection, setCurrentSection] = useState('general');
|
||||||
|
|
||||||
|
const renderSettingsContent = () => {
|
||||||
|
switch (currentSection) {
|
||||||
|
case 'general':
|
||||||
|
return <AccountTab />;
|
||||||
|
|
||||||
|
case 'password':
|
||||||
|
return <PasswordTab />;
|
||||||
|
|
||||||
|
case 'notifications':
|
||||||
|
return <NotificationsTab />;
|
||||||
|
|
||||||
|
case 'calendarAvailability':
|
||||||
|
return <CalendarTab />;
|
||||||
|
|
||||||
|
case 'sharingPrivacy':
|
||||||
|
return <PrivacyTab />;
|
||||||
|
|
||||||
|
case 'appearance':
|
||||||
|
return <AppearanceTab />;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
||||||
|
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full max-h-[calc(100vh-2rem)] flex flex-col'>
|
||||||
|
{/* TODO: Fix overflow */}
|
||||||
|
<div className='p-6 border-b'>
|
||||||
|
<div className='flex items-center justify-between mb-4'>
|
||||||
|
<h1 className='text-2xl font-semibold'>Settings</h1>
|
||||||
|
</div>
|
||||||
|
<SettingsDropdown
|
||||||
|
currentSection={currentSection}
|
||||||
|
onSectionChange={setCurrentSection}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{renderSettingsContent()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
287
src/components/settings/tabs/account.tsx
Normal file
287
src/components/settings/tabs/account.tsx
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardFooter,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@/components/ui/select';
|
||||||
|
import {
|
||||||
|
useDeleteApiUserMe,
|
||||||
|
useGetApiUserMe,
|
||||||
|
usePatchApiUserMe,
|
||||||
|
} from '@/generated/api/user/user';
|
||||||
|
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||||
|
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||||
|
|
||||||
|
import ProfilePictureUpload from '@/components/misc/profile-picture-upload';
|
||||||
|
import { CalendarClock, MailOpen, UserPen } from 'lucide-react';
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
|
import useZodForm from '@/lib/hooks/useZodForm';
|
||||||
|
import { updateUserClientSchema } from '@/app/api/user/me/validation';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
import { ToastInner } from '@/components/misc/toast-inner';
|
||||||
|
|
||||||
|
export default function AccountTab() {
|
||||||
|
const router = useRouter();
|
||||||
|
const { data, refetch } = useGetApiUserMe();
|
||||||
|
const deleteUser = useDeleteApiUserMe();
|
||||||
|
const updateAccount = usePatchApiUserMe();
|
||||||
|
|
||||||
|
const { handleSubmit, formState, register } = useZodForm(
|
||||||
|
updateUserClientSchema,
|
||||||
|
);
|
||||||
|
|
||||||
|
const onSubmit = handleSubmit(async (submitData) => {
|
||||||
|
await updateAccount.mutateAsync(
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
first_name:
|
||||||
|
submitData?.first_name !== data?.data.user.first_name
|
||||||
|
? submitData?.first_name
|
||||||
|
: undefined,
|
||||||
|
last_name:
|
||||||
|
submitData?.last_name !== data?.data.user.last_name
|
||||||
|
? submitData?.last_name
|
||||||
|
: undefined,
|
||||||
|
name:
|
||||||
|
submitData?.name !== data?.data.user.name
|
||||||
|
? submitData?.name
|
||||||
|
: undefined,
|
||||||
|
email:
|
||||||
|
submitData?.email !== data?.data.user.email
|
||||||
|
? submitData?.email
|
||||||
|
: undefined,
|
||||||
|
image:
|
||||||
|
submitData?.image !== data?.data.user.image
|
||||||
|
? submitData?.image
|
||||||
|
: undefined,
|
||||||
|
timezone:
|
||||||
|
submitData?.timezone !== data?.data.user.timezone
|
||||||
|
? submitData?.timezone
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
refetch();
|
||||||
|
toast.custom((t) => (
|
||||||
|
<ToastInner
|
||||||
|
toastId={t}
|
||||||
|
title='Settings saved'
|
||||||
|
description='Your account settings have been updated successfully.'
|
||||||
|
variant='success'
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
toast.custom((t) => (
|
||||||
|
<ToastInner
|
||||||
|
toastId={t}
|
||||||
|
title='Error saving settings'
|
||||||
|
description={
|
||||||
|
error.response?.data.message || 'An unknown error occurred.'
|
||||||
|
}
|
||||||
|
variant='error'
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return (
|
||||||
|
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
||||||
|
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full h-auto max-h-[calc(100vh-2rem)] flex flex-col'>
|
||||||
|
<div className='p-6 border-b'>
|
||||||
|
<h1 className='text-2xl font-semibold'>Loading Settings...</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form onSubmit={onSubmit} className='h-full flex-grow overflow-auto'>
|
||||||
|
<Card className='pb-0 h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||||
|
<ScrollableSettingsWrapper>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Account Settings</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className='space-y-6 my-2'>
|
||||||
|
{/*-------------------- General Settings --------------------*/}
|
||||||
|
<GroupWrapper title='General Settings'>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<div>
|
||||||
|
<LabeledInput
|
||||||
|
type='text'
|
||||||
|
label='First Name'
|
||||||
|
placeholder='First Name'
|
||||||
|
defaultValue={data.data.user.first_name ?? ''}
|
||||||
|
{...register('first_name')}
|
||||||
|
error={formState.errors.first_name?.message}
|
||||||
|
></LabeledInput>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<LabeledInput
|
||||||
|
type='text'
|
||||||
|
label='Last Name'
|
||||||
|
placeholder='Last Name'
|
||||||
|
defaultValue={data.data.user.last_name ?? ''}
|
||||||
|
{...register('last_name')}
|
||||||
|
error={formState.errors.last_name?.message}
|
||||||
|
></LabeledInput>
|
||||||
|
</div>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<LabeledInput
|
||||||
|
type='text'
|
||||||
|
label='User Name'
|
||||||
|
icon={UserPen}
|
||||||
|
placeholder='User Name'
|
||||||
|
defaultValue={data.data.user.name}
|
||||||
|
{...register('name')}
|
||||||
|
error={formState.errors.name?.message}
|
||||||
|
></LabeledInput>
|
||||||
|
</div>
|
||||||
|
<div className='space-y-2 space-b-2'>
|
||||||
|
<LabeledInput
|
||||||
|
type='email'
|
||||||
|
label='Email Address'
|
||||||
|
icon={MailOpen}
|
||||||
|
placeholder='Your E-Mail'
|
||||||
|
defaultValue={data.data.user.email ?? ''}
|
||||||
|
{...register('email')}
|
||||||
|
error={formState.errors.email?.message}
|
||||||
|
></LabeledInput>
|
||||||
|
|
||||||
|
<span className='text-sm text-muted-foreground'>
|
||||||
|
Email might be managed by your SSO provider.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{formState.errors.root && (
|
||||||
|
<p className='text-red-500 text-sm mt-1'>
|
||||||
|
{formState.errors.root.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- General Settings --------------------*/}
|
||||||
|
{/*-------------------- Profile Picture --------------------*/}
|
||||||
|
<GroupWrapper title='Profile Picture'>
|
||||||
|
<div className='space-y-2 grid grid-cols-[1fr_auto]'>
|
||||||
|
<ProfilePictureUpload disabled />
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Profile Picture --------------------*/}
|
||||||
|
{/*-------------------- Regional Settings --------------------*/}
|
||||||
|
<GroupWrapper title='Regional Settings'>
|
||||||
|
<div className='space-y-2 grid sm:grid-cols-[1fr_auto] sm:flex-row gap-4'>
|
||||||
|
<div className='grid gap-1'>
|
||||||
|
<LabeledInput
|
||||||
|
type='text'
|
||||||
|
label='Timezone'
|
||||||
|
placeholder='Europe/Berlin'
|
||||||
|
icon={CalendarClock}
|
||||||
|
defaultValue={data?.data.user.timezone ?? ''}
|
||||||
|
{...register('timezone')}
|
||||||
|
error={
|
||||||
|
formState.errors.timezone?.message
|
||||||
|
? 'Invalid Timezone'
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
></LabeledInput>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className='grid gap-1'>
|
||||||
|
<Label htmlFor='language'>Language</Label>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='language'>
|
||||||
|
<SelectValue placeholder='Select language' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='en'>English</SelectItem>
|
||||||
|
<SelectItem value='de'>German</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Regional Settings --------------------*/}
|
||||||
|
{/*-------------------- DANGER ZONE --------------------*/}
|
||||||
|
<GroupWrapper title='DANGER ZONE' className='border-destructive'>
|
||||||
|
<div className='flex items-center justify-evenly sm:flex-row flex-col gap-6'>
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button variant='destructive'>Delete Account</Button>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<DialogTitle>Are you absolutely sure?</DialogTitle>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<DialogDescription>
|
||||||
|
This action cannot be undone. This will permanently
|
||||||
|
delete your account and remove your data from our
|
||||||
|
servers.
|
||||||
|
</DialogDescription>
|
||||||
|
<Button
|
||||||
|
variant='destructive'
|
||||||
|
onClick={() => {
|
||||||
|
deleteUser.mutate(undefined, {
|
||||||
|
onSuccess: () => {
|
||||||
|
router.push('/api/logout');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Confirm Delete
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DialogHeader>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
<span className='text-sm text-muted-foreground pt-1'>
|
||||||
|
Permanently delete your account and all associated data.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- DANGER ZONE --------------------*/}
|
||||||
|
</CardContent>
|
||||||
|
</ScrollableSettingsWrapper>
|
||||||
|
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||||
|
<Button
|
||||||
|
onClick={() => router.back()}
|
||||||
|
variant='secondary'
|
||||||
|
type='button'
|
||||||
|
>
|
||||||
|
Exit
|
||||||
|
</Button>
|
||||||
|
<Button variant='primary'>Save Changes</Button>
|
||||||
|
</CardFooter>
|
||||||
|
</Card>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
55
src/components/settings/tabs/appearance.tsx
Normal file
55
src/components/settings/tabs/appearance.tsx
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardFooter,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||||
|
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { ThemePicker } from '@/components/misc/theme-picker';
|
||||||
|
|
||||||
|
export default function AppearanceTab() {
|
||||||
|
const router = useRouter();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='flex-grow overflow-auto'>
|
||||||
|
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||||
|
<ScrollableSettingsWrapper>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Appearance</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className='space-y-6 my-2'>
|
||||||
|
{/*-------------------- Change Theme --------------------*/}
|
||||||
|
<GroupWrapper title='Change Theme'>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<Label htmlFor='theme'>Theme</Label>
|
||||||
|
<ThemePicker />
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Change Theme --------------------*/}
|
||||||
|
</CardContent>
|
||||||
|
</ScrollableSettingsWrapper>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||||
|
<Button
|
||||||
|
onClick={() => router.back()}
|
||||||
|
variant='secondary'
|
||||||
|
type='button'
|
||||||
|
>
|
||||||
|
Exit
|
||||||
|
</Button>
|
||||||
|
<Button variant='primary'>Save Changes</Button>
|
||||||
|
</CardFooter>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
226
src/components/settings/tabs/calendar.tsx
Normal file
226
src/components/settings/tabs/calendar.tsx
Normal file
|
@ -0,0 +1,226 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardFooter,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@/components/ui/select';
|
||||||
|
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||||
|
import { Switch } from '@/components/ui/switch';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||||
|
import {
|
||||||
|
CalendarArrowDown,
|
||||||
|
CalendarArrowUp,
|
||||||
|
CalendarCheck,
|
||||||
|
CalendarPlus,
|
||||||
|
ClockAlert,
|
||||||
|
ClockFading,
|
||||||
|
} from 'lucide-react';
|
||||||
|
import { IconButton } from '@/components/buttons/icon-button';
|
||||||
|
|
||||||
|
export default function CalendarTab() {
|
||||||
|
const router = useRouter();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='flex-grow overflow-auto'>
|
||||||
|
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||||
|
<ScrollableSettingsWrapper>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Calendar & Availability</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className='space-y-6 my-2'>
|
||||||
|
{/*-------------------- Date & Time Format --------------------*/}
|
||||||
|
<GroupWrapper title='Date & Time Format'>
|
||||||
|
<div className='flex flex-col space-y-4'>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<Label htmlFor='dateFormat'>Date Format</Label>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='dateFormat'>
|
||||||
|
<SelectValue placeholder='Select date format' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='ddmmyyyy'>DD/MM/YYYY</SelectItem>
|
||||||
|
<SelectItem value='mmddyyyy'>MM/DD/YYYY</SelectItem>
|
||||||
|
<SelectItem value='yyyymmdd'>YYYY-MM-DD</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<Label htmlFor='timeFormat'>Time Format</Label>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='timeFormat'>
|
||||||
|
<SelectValue placeholder='Select time format' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='24h'>24-hour</SelectItem>
|
||||||
|
<SelectItem value='12h'>12-hour</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Date & Time Format --------------------*/}
|
||||||
|
{/*-------------------- Calendar --------------------*/}
|
||||||
|
<GroupWrapper title='Calendar'>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<Label htmlFor='defaultCalendarView'>
|
||||||
|
Default Calendar View
|
||||||
|
</Label>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='defaultCalendarView'>
|
||||||
|
<SelectValue placeholder='Select view' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='day'>Day</SelectItem>
|
||||||
|
<SelectItem value='week'>Week</SelectItem>
|
||||||
|
<SelectItem value='month'>Month</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<Label htmlFor='weekStartsOn'>Week Starts On</Label>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='weekStartsOn'>
|
||||||
|
<SelectValue placeholder='Select day' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='sunday'>Sunday</SelectItem>
|
||||||
|
<SelectItem value='monday'>Monday</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center justify-between space-x-2'>
|
||||||
|
<Label htmlFor='showWeekends' className='font-normal'>
|
||||||
|
Show Weekends
|
||||||
|
</Label>
|
||||||
|
<Switch id='showWeekends' defaultChecked disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Calendar --------------------*/}
|
||||||
|
{/*-------------------- Availability --------------------*/}
|
||||||
|
<GroupWrapper title='Availability'>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<Label>Working Hours</Label>
|
||||||
|
<span className='text-sm text-muted-foreground'>
|
||||||
|
Define your typical available hours (e.g., Monday-Friday,
|
||||||
|
9 AM - 5 PM).
|
||||||
|
</span>
|
||||||
|
<Button variant='outline_muted' size='sm' disabled>
|
||||||
|
Set Working Hours
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<LabeledInput
|
||||||
|
disabled
|
||||||
|
type='text'
|
||||||
|
label='Minimum Notice for Bookings'
|
||||||
|
icon={ClockAlert}
|
||||||
|
subtext='Min time before a booking can be made.'
|
||||||
|
placeholder='e.g. 1h'
|
||||||
|
defaultValue={''}
|
||||||
|
></LabeledInput>
|
||||||
|
</div>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<LabeledInput
|
||||||
|
disabled
|
||||||
|
type='text'
|
||||||
|
label='Booking Window (days in advance)'
|
||||||
|
icon={ClockFading}
|
||||||
|
subtext='Max time in advance a booking can be made.'
|
||||||
|
placeholder='e.g. 30d'
|
||||||
|
defaultValue={''}
|
||||||
|
></LabeledInput>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Availability --------------------*/}
|
||||||
|
{/*-------------------- iCalendar Integration --------------------*/}
|
||||||
|
<GroupWrapper title='iCalendar Integration'>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<form
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
|
className='space-y-2'
|
||||||
|
>
|
||||||
|
<LabeledInput
|
||||||
|
disabled
|
||||||
|
type='url'
|
||||||
|
label='Import iCal Feed URL'
|
||||||
|
icon={CalendarCheck}
|
||||||
|
placeholder='https://calendar.example.com/feed.ics'
|
||||||
|
defaultValue={''}
|
||||||
|
name='icalUrl'
|
||||||
|
required
|
||||||
|
></LabeledInput>
|
||||||
|
<IconButton
|
||||||
|
disabled
|
||||||
|
type='submit'
|
||||||
|
size='sm'
|
||||||
|
className='mt-1'
|
||||||
|
variant={'secondary'}
|
||||||
|
icon={CalendarPlus}
|
||||||
|
title='Submit iCal URL'
|
||||||
|
>
|
||||||
|
Add Feed
|
||||||
|
</IconButton>
|
||||||
|
</form>
|
||||||
|
<div className='space-y-2'>
|
||||||
|
<Label>Export Your Calendar</Label>
|
||||||
|
<IconButton
|
||||||
|
disabled
|
||||||
|
variant='outline_muted'
|
||||||
|
size='sm'
|
||||||
|
icon={CalendarArrowUp}
|
||||||
|
>
|
||||||
|
Get iCal Export URL
|
||||||
|
</IconButton>
|
||||||
|
<IconButton
|
||||||
|
disabled
|
||||||
|
variant='outline_muted'
|
||||||
|
size='sm'
|
||||||
|
className='ml-2'
|
||||||
|
icon={CalendarArrowDown}
|
||||||
|
>
|
||||||
|
Download .ics File
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- iCalendar Integration --------------------*/}
|
||||||
|
</CardContent>
|
||||||
|
</ScrollableSettingsWrapper>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||||
|
<Button
|
||||||
|
onClick={() => router.back()}
|
||||||
|
variant='secondary'
|
||||||
|
type='button'
|
||||||
|
>
|
||||||
|
Exit
|
||||||
|
</Button>
|
||||||
|
<Button variant='primary'>Save Changes</Button>
|
||||||
|
</CardFooter>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
134
src/components/settings/tabs/notifications.tsx
Normal file
134
src/components/settings/tabs/notifications.tsx
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardFooter,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@/components/ui/select';
|
||||||
|
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||||
|
import { Switch } from '@/components/ui/switch';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
|
export default function NotificationsTab() {
|
||||||
|
const router = useRouter();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='flex-grow overflow-auto'>
|
||||||
|
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||||
|
<ScrollableSettingsWrapper>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Notification Preferences</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className='space-y-6 my-2'>
|
||||||
|
{/*-------------------- All --------------------*/}
|
||||||
|
<GroupWrapper title='All'>
|
||||||
|
<div className='flex items-center justify-between'>
|
||||||
|
<Label
|
||||||
|
htmlFor='masterEmailNotifications'
|
||||||
|
className='font-normal'
|
||||||
|
>
|
||||||
|
Enable All Email Notifications
|
||||||
|
</Label>
|
||||||
|
<Switch id='masterEmailNotifications' disabled />
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- All --------------------*/}
|
||||||
|
{/*-------------------- Meetings --------------------*/}
|
||||||
|
<GroupWrapper title='Meetings'>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<div className='flex items-center justify-between space-x-2'>
|
||||||
|
<Label htmlFor='newMeetingBookings' className='font-normal'>
|
||||||
|
New Meeting Bookings
|
||||||
|
</Label>
|
||||||
|
<Switch id='newMeetingBookings' disabled />
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center justify-between space-x-2'>
|
||||||
|
<Label
|
||||||
|
htmlFor='meetingConfirmations'
|
||||||
|
className='font-normal'
|
||||||
|
>
|
||||||
|
Meeting Confirmations/Cancellations
|
||||||
|
</Label>
|
||||||
|
<Switch id='meetingConfirmations' disabled />
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center justify-between space-x-2'>
|
||||||
|
<Label
|
||||||
|
htmlFor='enableMeetingReminders'
|
||||||
|
className='font-normal'
|
||||||
|
>
|
||||||
|
Meeting Reminders
|
||||||
|
</Label>
|
||||||
|
<div>
|
||||||
|
<Switch id='enableMeetingReminders' disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex items-center justify-between space-x-2'>
|
||||||
|
<Label className='font-normal' htmlFor='remindBefore'>
|
||||||
|
Remind me before
|
||||||
|
</Label>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='remindBefore'>
|
||||||
|
<SelectValue placeholder='Select reminder time' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='15m'>15 minutes</SelectItem>
|
||||||
|
<SelectItem value='30m'>30 minutes</SelectItem>
|
||||||
|
<SelectItem value='1h'>1 hour</SelectItem>
|
||||||
|
<SelectItem value='1d'>1 day</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Meetings --------------------*/}
|
||||||
|
{/*-------------------- Social --------------------*/}
|
||||||
|
<GroupWrapper title='Social'>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<div className='flex items-center justify-between space-x-2'>
|
||||||
|
<Label htmlFor='friendRequests' className='font-normal'>
|
||||||
|
Friend Requests
|
||||||
|
</Label>
|
||||||
|
<Switch id='friendRequests' disabled />
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center justify-between space-x-2'>
|
||||||
|
<Label htmlFor='groupUpdates' className='font-normal'>
|
||||||
|
Group Invitations/Updates
|
||||||
|
</Label>
|
||||||
|
<Switch id='groupUpdates' disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Social --------------------*/}
|
||||||
|
</CardContent>
|
||||||
|
</ScrollableSettingsWrapper>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||||
|
<Button
|
||||||
|
onClick={() => router.back()}
|
||||||
|
variant='secondary'
|
||||||
|
type='button'
|
||||||
|
>
|
||||||
|
Exit
|
||||||
|
</Button>
|
||||||
|
<Button variant='primary'>Save Changes</Button>
|
||||||
|
</CardFooter>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
151
src/components/settings/tabs/password.tsx
Normal file
151
src/components/settings/tabs/password.tsx
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardFooter,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||||
|
import {
|
||||||
|
useGetApiUserMe,
|
||||||
|
usePatchApiUserMePassword,
|
||||||
|
} from '@/generated/api/user/user';
|
||||||
|
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||||
|
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||||
|
|
||||||
|
import { BookKey, FileKey, FileKey2, RotateCcwKey } from 'lucide-react';
|
||||||
|
import useZodForm from '@/lib/hooks/useZodForm';
|
||||||
|
import { updateUserPasswordServerSchema } from '@/app/api/user/me/validation';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
|
export default function PasswordTab() {
|
||||||
|
const router = useRouter();
|
||||||
|
const { data } = useGetApiUserMe();
|
||||||
|
const updatePassword = usePatchApiUserMePassword();
|
||||||
|
|
||||||
|
const { handleSubmit, formState, register, setError } = useZodForm(
|
||||||
|
updateUserPasswordServerSchema,
|
||||||
|
);
|
||||||
|
|
||||||
|
const onSubmit = handleSubmit(async (data) => {
|
||||||
|
await updatePassword.mutateAsync(
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
router.refresh();
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
setError('root', {
|
||||||
|
message: error.response?.data.message,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setError('root', {
|
||||||
|
message: 'An unknown error occurred.',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return (
|
||||||
|
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
||||||
|
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full h-auto max-h-[calc(100vh-2rem)] flex flex-col'>
|
||||||
|
<div className='p-6 border-b'>
|
||||||
|
<h1 className='text-2xl font-semibold'>Loading Settings...</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form onSubmit={onSubmit}>
|
||||||
|
<div className='flex-grow overflow-auto'>
|
||||||
|
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||||
|
<ScrollableSettingsWrapper>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Password Settings</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className='space-y-6 my-2'>
|
||||||
|
{/*-------------------- Reset Password --------------------*/}
|
||||||
|
<GroupWrapper title='Reset Password'>
|
||||||
|
<div className='flex flex-col items-center gap-6'>
|
||||||
|
<div className='flex flex-col sm:flex-row gap-6 w-full'>
|
||||||
|
<div className='flex-1'>
|
||||||
|
<LabeledInput
|
||||||
|
type='password'
|
||||||
|
label='Current Password'
|
||||||
|
icon={FileKey}
|
||||||
|
{...register('current_password')}
|
||||||
|
error={formState.errors.current_password?.message}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex-1'>
|
||||||
|
<LabeledInput
|
||||||
|
type='password'
|
||||||
|
label='New Password'
|
||||||
|
icon={FileKey2}
|
||||||
|
{...register('new_password')}
|
||||||
|
error={formState.errors.new_password?.message}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex-1'>
|
||||||
|
<LabeledInput
|
||||||
|
type='password'
|
||||||
|
label='Repeat Password'
|
||||||
|
icon={RotateCcwKey}
|
||||||
|
{...register('confirm_new_password')}
|
||||||
|
error={formState.errors.confirm_new_password?.message}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex items-end'>
|
||||||
|
<Button
|
||||||
|
variant={
|
||||||
|
formState.isValid
|
||||||
|
? 'outline_secondary'
|
||||||
|
: 'outline_muted'
|
||||||
|
}
|
||||||
|
size='icon'
|
||||||
|
className='w-full md:size-9'
|
||||||
|
disabled={!formState.isValid || formState.isSubmitting}
|
||||||
|
>
|
||||||
|
<BookKey className='h-[1.2rem] w-[1.2rem]' />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{formState.errors.root && (
|
||||||
|
<p className='text-red-500 text-sm mt-1'>
|
||||||
|
{formState.errors.root.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Reset Password --------------------*/}
|
||||||
|
</CardContent>
|
||||||
|
</ScrollableSettingsWrapper>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||||
|
<Button
|
||||||
|
onClick={() => router.back()}
|
||||||
|
variant='secondary'
|
||||||
|
type='button'
|
||||||
|
>
|
||||||
|
Exit
|
||||||
|
</Button>
|
||||||
|
<Button variant='primary'>Save Changes</Button>
|
||||||
|
</CardFooter>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
143
src/components/settings/tabs/privacy.tsx
Normal file
143
src/components/settings/tabs/privacy.tsx
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardFooter,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@/components/ui/select';
|
||||||
|
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { IconButton } from '@/components/buttons/icon-button';
|
||||||
|
import { UserLock } from 'lucide-react';
|
||||||
|
|
||||||
|
export default function PrivacyTab() {
|
||||||
|
const router = useRouter();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='flex-grow overflow-auto'>
|
||||||
|
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||||
|
<ScrollableSettingsWrapper>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Sharing & Privacy</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className='space-y-6 my-2'>
|
||||||
|
{/*-------------------- Privacy Settigs --------------------*/}
|
||||||
|
<GroupWrapper title='Privacy Settings'>
|
||||||
|
<div className='flex flex-col space-y-4'>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<Label htmlFor='defaultVisibility'>
|
||||||
|
Default Calendar Visibility
|
||||||
|
</Label>
|
||||||
|
<span className='text-sm text-muted-foreground'>
|
||||||
|
Default setting for new friends.
|
||||||
|
</span>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='defaultVisibility'>
|
||||||
|
<SelectValue placeholder='Select visibility' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='private'>
|
||||||
|
Private (Only You)
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value='freebusy'>Free/Busy</SelectItem>
|
||||||
|
<SelectItem value='fulldetails'>
|
||||||
|
Full Details
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<Label htmlFor='whoCanSeeFull'>
|
||||||
|
Who Can See Your Full Calendar Details?
|
||||||
|
</Label>
|
||||||
|
<span className='text-sm text-muted-foreground'>
|
||||||
|
(Override for Default Visibility)
|
||||||
|
<br />
|
||||||
|
<span className='text-sm text-muted-foreground'>
|
||||||
|
This setting will override the default visibility for
|
||||||
|
your calendar. You can set specific friends or groups to
|
||||||
|
see your full calendar details.
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='whoCanSeeFull'>
|
||||||
|
<SelectValue placeholder='Select audience' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='me'>Only Me</SelectItem>
|
||||||
|
<SelectItem value='friends'>My Friends</SelectItem>
|
||||||
|
<SelectItem value='specific'>
|
||||||
|
Specific Friends/Groups (manage separately)
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<Label htmlFor='whoCanBook'>
|
||||||
|
Who Can Book Time With You?
|
||||||
|
</Label>
|
||||||
|
<Select disabled>
|
||||||
|
<SelectTrigger id='whoCanBook'>
|
||||||
|
<SelectValue placeholder='Select audience' />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value='none'>No One</SelectItem>
|
||||||
|
<SelectItem value='friends'>My Friends</SelectItem>
|
||||||
|
<SelectItem value='specific'>
|
||||||
|
Specific Friends/Groups (manage separately)
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className='space-y-4'>
|
||||||
|
<div className='grid grid-cols-1 gap-1'>
|
||||||
|
<Label>Blocked Users</Label>
|
||||||
|
<span className='text-sm text-muted-foreground'>
|
||||||
|
Prevent specific users from seeing your calendar or
|
||||||
|
booking time.
|
||||||
|
</span>
|
||||||
|
<IconButton
|
||||||
|
disabled
|
||||||
|
variant='outline_muted'
|
||||||
|
size='sm'
|
||||||
|
icon={UserLock}
|
||||||
|
>
|
||||||
|
Manage Blocked Users
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GroupWrapper>
|
||||||
|
{/*-------------------- Privacy Settigs --------------------*/}
|
||||||
|
</CardContent>
|
||||||
|
</ScrollableSettingsWrapper>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||||
|
<Button
|
||||||
|
onClick={() => router.back()}
|
||||||
|
variant='secondary'
|
||||||
|
type='button'
|
||||||
|
>
|
||||||
|
Exit
|
||||||
|
</Button>
|
||||||
|
<Button variant='primary'>Save Changes</Button>
|
||||||
|
</CardFooter>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ export default function TimePicker({
|
||||||
setDate,
|
setDate,
|
||||||
time,
|
time,
|
||||||
setTime,
|
setTime,
|
||||||
|
...props
|
||||||
}: {
|
}: {
|
||||||
dateLabel?: string;
|
dateLabel?: string;
|
||||||
timeLabel?: string;
|
timeLabel?: string;
|
||||||
|
@ -27,12 +28,12 @@ export default function TimePicker({
|
||||||
setDate?: (date: Date | undefined) => void;
|
setDate?: (date: Date | undefined) => void;
|
||||||
time?: string;
|
time?: string;
|
||||||
setTime?: (time: string) => void;
|
setTime?: (time: string) => void;
|
||||||
}) {
|
} & React.HTMLAttributes<HTMLDivElement>) {
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex gap-4'>
|
<div className='grid grid-cols-2 gap-4' {...props}>
|
||||||
<div className='flex flex-col gap-3'>
|
<div className='grid grid-rows-2 gap-2'>
|
||||||
<Label htmlFor='date' className='px-1'>
|
<Label htmlFor='date' className='px-1'>
|
||||||
{dateLabel}
|
{dateLabel}
|
||||||
</Label>
|
</Label>
|
||||||
|
@ -68,7 +69,7 @@ export default function TimePicker({
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col gap-3'>
|
<div className='grid grid-rows-2 gap-2'>
|
||||||
<Label htmlFor='time' className='px-1'>
|
<Label htmlFor='time' className='px-1'>
|
||||||
{timeLabel}
|
{timeLabel}
|
||||||
</Label>
|
</Label>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
const buttonVariants = cva(
|
const buttonVariants = cva(
|
||||||
"radius-lg inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-button transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
"radius-lg inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-button transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-nonef",
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
|
|
|
@ -126,7 +126,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
data-slot='card-footer'
|
data-slot='card-footer'
|
||||||
className={cn('flex items-center px-6 [.border-t]:pt-6', className)}
|
className={cn('flex items-center px-6', className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -69,7 +69,7 @@ function DialogContent({
|
||||||
{showCloseButton && (
|
{showCloseButton && (
|
||||||
<DialogPrimitive.Close
|
<DialogPrimitive.Close
|
||||||
data-slot='dialog-close'
|
data-slot='dialog-close'
|
||||||
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-2 right-2 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
||||||
>
|
>
|
||||||
<XIcon />
|
<XIcon />
|
||||||
<span className='sr-only'>Close</span>
|
<span className='sr-only'>Close</span>
|
||||||
|
|
23
src/components/wrappers/group-wrapper.tsx
Normal file
23
src/components/wrappers/group-wrapper.tsx
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import type * as React from 'react';
|
||||||
|
|
||||||
|
interface ScrollableSettingsWrapperProps {
|
||||||
|
className?: string;
|
||||||
|
title?: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GroupWrapper({
|
||||||
|
className,
|
||||||
|
title,
|
||||||
|
children,
|
||||||
|
}: ScrollableSettingsWrapperProps) {
|
||||||
|
return (
|
||||||
|
<fieldset
|
||||||
|
className={cn('space-t-4 p-4 border rounded-md shadow-md', className)}
|
||||||
|
>
|
||||||
|
<legend className='text-sm font-medium px-1'>{title}</legend>
|
||||||
|
{children}
|
||||||
|
</fieldset>
|
||||||
|
);
|
||||||
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
export const queryClient = new QueryClient();
|
||||||
|
|
||||||
export function QueryProvider({ children }: { children: React.ReactNode }) {
|
export function QueryProvider({ children }: { children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import React from 'react';
|
import { cn } from '@/lib/utils';
|
||||||
|
import type * as React from 'react';
|
||||||
|
|
||||||
interface ScrollableContentWrapperProps {
|
interface ScrollableSettingsWrapperProps {
|
||||||
children: React.ReactNode;
|
|
||||||
className?: string;
|
className?: string;
|
||||||
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ScrollableSettingsWrapper: React.FC<
|
export function ScrollableSettingsWrapper({
|
||||||
ScrollableContentWrapperProps
|
className,
|
||||||
> = ({ children, className = '' }) => {
|
children,
|
||||||
|
}: ScrollableSettingsWrapperProps) {
|
||||||
return (
|
return (
|
||||||
<div className={`h-[500px] overflow-y-auto space-y-2 ${className}`}>
|
<div className={cn('overflow-y-auto h-full', className)}>{children}</div>
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
145
yarn.lock
145
yarn.lock
|
@ -436,21 +436,21 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@eslint/config-array@npm:^0.20.1":
|
"@eslint/config-array@npm:^0.21.0":
|
||||||
version: 0.20.1
|
version: 0.21.0
|
||||||
resolution: "@eslint/config-array@npm:0.20.1"
|
resolution: "@eslint/config-array@npm:0.21.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@eslint/object-schema": "npm:^2.1.6"
|
"@eslint/object-schema": "npm:^2.1.6"
|
||||||
debug: "npm:^4.3.1"
|
debug: "npm:^4.3.1"
|
||||||
minimatch: "npm:^3.1.2"
|
minimatch: "npm:^3.1.2"
|
||||||
checksum: 10c0/709108c3925d83c2166024646829ab61ba5fa85c6568daefd32508899f46ed8dc36d7153042df6dcc7e58ad543bc93298b646575daecb5eb4e39a43d838dab42
|
checksum: 10c0/0ea801139166c4aa56465b309af512ef9b2d3c68f9198751bbc3e21894fe70f25fbf26e1b0e9fffff41857bc21bfddeee58649ae6d79aadcd747db0c5dca771f
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@eslint/config-helpers@npm:^0.2.1":
|
"@eslint/config-helpers@npm:^0.3.0":
|
||||||
version: 0.2.3
|
version: 0.3.0
|
||||||
resolution: "@eslint/config-helpers@npm:0.2.3"
|
resolution: "@eslint/config-helpers@npm:0.3.0"
|
||||||
checksum: 10c0/8fd36d7f33013628787947c81894807c7498b31eacf6648efa6d7c7a99aac6bf0d59a8a4d14f968ec2aeebefb76a1a7e4fd4cd556a296323d4711b3d7a7cda22
|
checksum: 10c0/013ae7b189eeae8b30cc2ee87bc5c9c091a9cd615579003290eb28bebad5d78806a478e74ba10b3fe08ed66975b52af7d2cd4b4b43990376412b14e5664878c8
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -489,10 +489,10 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@eslint/js@npm:9.29.0":
|
"@eslint/js@npm:9.30.1":
|
||||||
version: 9.29.0
|
version: 9.30.1
|
||||||
resolution: "@eslint/js@npm:9.29.0"
|
resolution: "@eslint/js@npm:9.30.1"
|
||||||
checksum: 10c0/d0ccf37063fa27a3fae9347cb044f84ca10b5a2fa19ffb2b3fedf3b96843ac1ff359ea9f0ab0e80f2f16fda4cb0dc61ea0fed0375090f050fe0a029e7d6de3a3
|
checksum: 10c0/17fc382a0deafdb1cadac1269d9c2f2464f025bde6e4d12fc4f4775eb9886b41340d4650b72e85a53423644fdc89bf59c987a852f27379ad25feecf2c5bbc1c9
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -1013,6 +1013,15 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@marko19907/string-to-color@npm:^1.0.0":
|
||||||
|
version: 1.0.0
|
||||||
|
resolution: "@marko19907/string-to-color@npm:1.0.0"
|
||||||
|
dependencies:
|
||||||
|
esm-seedrandom: "npm:^3.0.5"
|
||||||
|
checksum: 10c0/fd297937fb5a8a0c3372bc614f9a4e21842e3392ef54e0d323f0fe730ec5b5a441f921e63b3b151bd39ca64a120ddfe905d1a67ca62ed637ade69c96c55fe641
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@napi-rs/wasm-runtime@npm:^0.2.11":
|
"@napi-rs/wasm-runtime@npm:^0.2.11":
|
||||||
version: 0.2.11
|
version: 0.2.11
|
||||||
resolution: "@napi-rs/wasm-runtime@npm:0.2.11"
|
resolution: "@napi-rs/wasm-runtime@npm:0.2.11"
|
||||||
|
@ -2215,9 +2224,9 @@ __metadata:
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@rushstack/eslint-patch@npm:^1.10.3":
|
"@rushstack/eslint-patch@npm:^1.10.3":
|
||||||
version: 1.11.0
|
version: 1.12.0
|
||||||
resolution: "@rushstack/eslint-patch@npm:1.11.0"
|
resolution: "@rushstack/eslint-patch@npm:1.12.0"
|
||||||
checksum: 10c0/abea8d8cf2f4f50343f74abd6a8173c521ddd09b102021f5aa379ef373c40af5948b23db0e87eca1682e559e09d97d3f0c48ea71edad682c6bf72b840c8675b3
|
checksum: 10c0/1e567656d92632c085a446f40767bc451caffe1131e8d6a7a3e8f3e3f4167f5f29744a84c709f2440f299442d4bc68ff773784462166800b8c09c0e08042415b
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -3243,21 +3252,21 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@tanstack/query-core@npm:5.81.2":
|
"@tanstack/query-core@npm:5.81.5":
|
||||||
version: 5.81.2
|
version: 5.81.5
|
||||||
resolution: "@tanstack/query-core@npm:5.81.2"
|
resolution: "@tanstack/query-core@npm:5.81.5"
|
||||||
checksum: 10c0/36a6bddec2e7512015bcfbb0d7b0876fab418de9e0ef21ad403598276960e0b7d53efd62832ce462738ad22d9883e31cb5403eafc65dfd9b2f6744c22a9d8e42
|
checksum: 10c0/8d3af841f0e2f3fba1dfd100a8bbc2d07e7b1d5b8570d3d0d8bba5127601c2788e5f7c84839f93f3b0cbe54f14866c1fef8e3f9e745f02d27afaaeea33b7b755
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@tanstack/react-query@npm:^5.80.7":
|
"@tanstack/react-query@npm:^5.80.7":
|
||||||
version: 5.81.2
|
version: 5.81.5
|
||||||
resolution: "@tanstack/react-query@npm:5.81.2"
|
resolution: "@tanstack/react-query@npm:5.81.5"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@tanstack/query-core": "npm:5.81.2"
|
"@tanstack/query-core": "npm:5.81.5"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ^18 || ^19
|
react: ^18 || ^19
|
||||||
checksum: 10c0/a80a2e7401a02bfc8d7a926c9e48b0a108cae21a2c47691632e754de44ca08838c105fb0c30804f4ccbf173bee04ad9a3e45a8bebdfc1d1a32468bbb9d960e19
|
checksum: 10c0/04803dd7d7d6ac73ba8c55bb25d76aa2f74d173d1574a113c35559bf6a8ac7d04a75db5e470e9a2e4132fee5e0ce1ab23bd8c27d17f70a461aca0e7ae740e76b
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -3378,12 +3387,12 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@types/node@npm:22.15.33":
|
"@types/node@npm:22.16.0":
|
||||||
version: 22.15.33
|
version: 22.16.0
|
||||||
resolution: "@types/node@npm:22.15.33"
|
resolution: "@types/node@npm:22.16.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: "npm:~6.21.0"
|
undici-types: "npm:~6.21.0"
|
||||||
checksum: 10c0/ee040c29c891aa37fffc27d04a8529318c391356346933646b7692eaf62236831ad532f6ebaf43ebd6a2ef1f0f091860d8a0a83a4e3c5a4f66d37aa1b2c99f31
|
checksum: 10c0/6219b521062f6c38d4d85ebd25807bd7f2bc703a5acba24e2c6716938d9d6cefd6fafd7b5156f61580eb58a0d82e8921751b778655675389631d813e5f261c03
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -4777,9 +4786,9 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"cypress@npm:14.5.0":
|
"cypress@npm:14.5.1":
|
||||||
version: 14.5.0
|
version: 14.5.1
|
||||||
resolution: "cypress@npm:14.5.0"
|
resolution: "cypress@npm:14.5.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@cypress/request": "npm:^3.0.8"
|
"@cypress/request": "npm:^3.0.8"
|
||||||
"@cypress/xvfb": "npm:^1.2.4"
|
"@cypress/xvfb": "npm:^1.2.4"
|
||||||
|
@ -4827,7 +4836,7 @@ __metadata:
|
||||||
yauzl: "npm:^2.10.0"
|
yauzl: "npm:^2.10.0"
|
||||||
bin:
|
bin:
|
||||||
cypress: bin/cypress
|
cypress: bin/cypress
|
||||||
checksum: 10c0/b76b05c029625357fbc34f22b632c55f9f981f86c3a568a88ea3d8982b8299e4bd4275e966b2ec767f9a989c6e9059fb03a4a8086048b4e990079b1cab19ba11
|
checksum: 10c0/23c87cafcd2fe949af1b3297cc4c9c8f8d741f5dfa8119ff54b387227dba8dc0dbcfb2d160c4df5d4f281374524753598f3501f0fdf0b1ea66c5b8047484c0d2
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -5085,9 +5094,9 @@ __metadata:
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"dotenv@npm:^16.3.0":
|
"dotenv@npm:^16.3.0":
|
||||||
version: 16.5.0
|
version: 16.6.0
|
||||||
resolution: "dotenv@npm:16.5.0"
|
resolution: "dotenv@npm:16.6.0"
|
||||||
checksum: 10c0/5bc94c919fbd955bf0ba44d33922a1e93d1078e64a1db5c30faeded1d996e7a83c55332cb8ea4fae5a9ca4d0be44cbceb95c5811e70f9f095298df09d1997dd9
|
checksum: 10c0/c1029a8656e03abc53c0522baf733131ffd4e633d8ab66c3f2d470ebdd7c5d143ffab64945afc475e60c5f803f0e734a9f9247949d17cc8ff564fba5c15978b1
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -5667,17 +5676,17 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"eslint@npm:9.29.0":
|
"eslint@npm:9.30.1":
|
||||||
version: 9.29.0
|
version: 9.30.1
|
||||||
resolution: "eslint@npm:9.29.0"
|
resolution: "eslint@npm:9.30.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@eslint-community/eslint-utils": "npm:^4.2.0"
|
"@eslint-community/eslint-utils": "npm:^4.2.0"
|
||||||
"@eslint-community/regexpp": "npm:^4.12.1"
|
"@eslint-community/regexpp": "npm:^4.12.1"
|
||||||
"@eslint/config-array": "npm:^0.20.1"
|
"@eslint/config-array": "npm:^0.21.0"
|
||||||
"@eslint/config-helpers": "npm:^0.2.1"
|
"@eslint/config-helpers": "npm:^0.3.0"
|
||||||
"@eslint/core": "npm:^0.14.0"
|
"@eslint/core": "npm:^0.14.0"
|
||||||
"@eslint/eslintrc": "npm:^3.3.1"
|
"@eslint/eslintrc": "npm:^3.3.1"
|
||||||
"@eslint/js": "npm:9.29.0"
|
"@eslint/js": "npm:9.30.1"
|
||||||
"@eslint/plugin-kit": "npm:^0.3.1"
|
"@eslint/plugin-kit": "npm:^0.3.1"
|
||||||
"@humanfs/node": "npm:^0.16.6"
|
"@humanfs/node": "npm:^0.16.6"
|
||||||
"@humanwhocodes/module-importer": "npm:^1.0.1"
|
"@humanwhocodes/module-importer": "npm:^1.0.1"
|
||||||
|
@ -5713,7 +5722,14 @@ __metadata:
|
||||||
optional: true
|
optional: true
|
||||||
bin:
|
bin:
|
||||||
eslint: bin/eslint.js
|
eslint: bin/eslint.js
|
||||||
checksum: 10c0/75e3f841e0f8b0fa93dbb2ba6ae538bd8b611c3654117bc3dadf90bb009923dfd2c15ec2948dc6e6b8b571317cc125c5cceb9255da8cd644ee740020df645dd8
|
checksum: 10c0/5a5867078e03ea56a1b6d1ee1548659abc38a6d5136c7ef94e21c5dbeb28e3ed50b15d2e0da25fce85600f6cf7ea7715eae650c41e8ae826c34490e9ec73d5d6
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"esm-seedrandom@npm:^3.0.5":
|
||||||
|
version: 3.0.5
|
||||||
|
resolution: "esm-seedrandom@npm:3.0.5"
|
||||||
|
checksum: 10c0/6fe5a33f31bce0e733814df884cdfc27812e4b04ce973f7cf008b7b8500ecab6706f54591841bd12dd3bdd9bbb153abf04fb8efd4934a5b0ab273bff114cdb3b
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -7582,12 +7598,12 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"lucide-react@npm:^0.523.0":
|
"lucide-react@npm:^0.525.0":
|
||||||
version: 0.523.0
|
version: 0.525.0
|
||||||
resolution: "lucide-react@npm:0.523.0"
|
resolution: "lucide-react@npm:0.525.0"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||||
checksum: 10c0/dafd180d05326edc81d928f37d6574930f0592da08b91c536ae5675d0b764295368e8daf9bcc81a5283c18e2f19412060d1da475b4f26112168245e708bd562f
|
checksum: 10c0/81c4438e2cf1c86ea2ebe0a97b378201512450894283cccce766a89bc6a4e47c8df1d9115d845d98f582bb0a10be31c454aa232520fea35018dac1cd8466ea9b
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -7683,6 +7699,7 @@ __metadata:
|
||||||
"@fortawesome/free-solid-svg-icons": "npm:^6.7.2"
|
"@fortawesome/free-solid-svg-icons": "npm:^6.7.2"
|
||||||
"@fortawesome/react-fontawesome": "npm:^0.2.2"
|
"@fortawesome/react-fontawesome": "npm:^0.2.2"
|
||||||
"@hookform/resolvers": "npm:^5.0.1"
|
"@hookform/resolvers": "npm:^5.0.1"
|
||||||
|
"@marko19907/string-to-color": "npm:^1.0.0"
|
||||||
"@prisma/client": "npm:^6.9.0"
|
"@prisma/client": "npm:^6.9.0"
|
||||||
"@radix-ui/react-avatar": "npm:^1.1.10"
|
"@radix-ui/react-avatar": "npm:^1.1.10"
|
||||||
"@radix-ui/react-collapsible": "npm:^1.1.11"
|
"@radix-ui/react-collapsible": "npm:^1.1.11"
|
||||||
|
@ -7700,7 +7717,7 @@ __metadata:
|
||||||
"@radix-ui/react-tooltip": "npm:^1.2.7"
|
"@radix-ui/react-tooltip": "npm:^1.2.7"
|
||||||
"@tailwindcss/postcss": "npm:4.1.11"
|
"@tailwindcss/postcss": "npm:4.1.11"
|
||||||
"@tanstack/react-query": "npm:^5.80.7"
|
"@tanstack/react-query": "npm:^5.80.7"
|
||||||
"@types/node": "npm:22.15.33"
|
"@types/node": "npm:22.16.0"
|
||||||
"@types/react": "npm:19.1.8"
|
"@types/react": "npm:19.1.8"
|
||||||
"@types/react-big-calendar": "npm:1.16.2"
|
"@types/react-big-calendar": "npm:1.16.2"
|
||||||
"@types/react-dom": "npm:19.1.6"
|
"@types/react-dom": "npm:19.1.6"
|
||||||
|
@ -7710,13 +7727,13 @@ __metadata:
|
||||||
class-variance-authority: "npm:^0.7.1"
|
class-variance-authority: "npm:^0.7.1"
|
||||||
clsx: "npm:^2.1.1"
|
clsx: "npm:^2.1.1"
|
||||||
cmdk: "npm:^1.1.1"
|
cmdk: "npm:^1.1.1"
|
||||||
cypress: "npm:14.5.0"
|
cypress: "npm:14.5.1"
|
||||||
date-fns: "npm:^4.1.0"
|
date-fns: "npm:^4.1.0"
|
||||||
dotenv-cli: "npm:8.0.0"
|
dotenv-cli: "npm:8.0.0"
|
||||||
eslint: "npm:9.29.0"
|
eslint: "npm:9.30.1"
|
||||||
eslint-config-next: "npm:15.3.4"
|
eslint-config-next: "npm:15.3.4"
|
||||||
eslint-config-prettier: "npm:10.1.5"
|
eslint-config-prettier: "npm:10.1.5"
|
||||||
lucide-react: "npm:^0.523.0"
|
lucide-react: "npm:^0.525.0"
|
||||||
next: "npm:15.3.4"
|
next: "npm:15.3.4"
|
||||||
next-auth: "npm:^5.0.0-beta.25"
|
next-auth: "npm:^5.0.0-beta.25"
|
||||||
next-swagger-doc: "npm:^0.4.1"
|
next-swagger-doc: "npm:^0.4.1"
|
||||||
|
@ -8971,15 +8988,15 @@ __metadata:
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"react-day-picker@npm:^9.7.0":
|
"react-day-picker@npm:^9.7.0":
|
||||||
version: 9.7.0
|
version: 9.8.0
|
||||||
resolution: "react-day-picker@npm:9.7.0"
|
resolution: "react-day-picker@npm:9.8.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@date-fns/tz": "npm:1.2.0"
|
"@date-fns/tz": "npm:1.2.0"
|
||||||
date-fns: "npm:4.1.0"
|
date-fns: "npm:4.1.0"
|
||||||
date-fns-jalali: "npm:4.1.0-0"
|
date-fns-jalali: "npm:4.1.0-0"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ">=16.8.0"
|
react: ">=16.8.0"
|
||||||
checksum: 10c0/c08c45a53aebceda1c938d2e4c95eb1702dcf149715e3457739f8930dce19a3be5780e5bad12dcc9d244d50b7e0efb226c336d81c1c062f616cf422e6a3804a6
|
checksum: 10c0/910dfbc59e9fece7f5365a2a23ed497e07f227a733289e8141b858b6ce482087df6b01f2ba4f9f7e452ebc3465af0e227f192708a673396221865df07e5ab2ac
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -9018,11 +9035,11 @@ __metadata:
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"react-hook-form@npm:^7.56.4":
|
"react-hook-form@npm:^7.56.4":
|
||||||
version: 7.58.1
|
version: 7.60.0
|
||||||
resolution: "react-hook-form@npm:7.58.1"
|
resolution: "react-hook-form@npm:7.60.0"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ^16.8.0 || ^17 || ^18 || ^19
|
react: ^16.8.0 || ^17 || ^18 || ^19
|
||||||
checksum: 10c0/981b9982b7eb497c3afff86c219175fdd4d92a24e3533518035239545dda23f5ebc6ba647fb29a250f768bdf811ba413094ce0103fbf36b436737fc18aa1bb49
|
checksum: 10c0/eb8518d42a074d9e115d4b414bac18ae72708b2d047a9453dcc7588b00df300b32cebf6ecb7f2c8aa534808b3dc54bde4124af95c1e432b6691f9aba07c93b11
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -10197,8 +10214,8 @@ __metadata:
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"swagger-ui-react@npm:^5.24.1":
|
"swagger-ui-react@npm:^5.24.1":
|
||||||
version: 5.25.3
|
version: 5.26.0
|
||||||
resolution: "swagger-ui-react@npm:5.25.3"
|
resolution: "swagger-ui-react@npm:5.26.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime-corejs3": "npm:^7.27.1"
|
"@babel/runtime-corejs3": "npm:^7.27.1"
|
||||||
"@scarf/scarf": "npm:=1.4.0"
|
"@scarf/scarf": "npm:=1.4.0"
|
||||||
|
@ -10236,7 +10253,7 @@ __metadata:
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ">=16.8.0 <19"
|
react: ">=16.8.0 <19"
|
||||||
react-dom: ">=16.8.0 <19"
|
react-dom: ">=16.8.0 <19"
|
||||||
checksum: 10c0/9d6542d0d1bd2533e87853d4deef5507d30b35941c697d50c763428533a88cbd9c2e3abe1af5946e35aa7fa3568dc14b9da4363f09bdf6d8023e0699efceb5cf
|
checksum: 10c0/4ce665f46171d724050435db86ce046d5a7777b5601d4ae6b418245e1fc9792591d6cb54fc583c074855f9890ff5b0e986b0a5601f47b79cfc8377dee8a3e3cc
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -10675,8 +10692,8 @@ __metadata:
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"typedoc@npm:^0.28.0":
|
"typedoc@npm:^0.28.0":
|
||||||
version: 0.28.5
|
version: 0.28.6
|
||||||
resolution: "typedoc@npm:0.28.5"
|
resolution: "typedoc@npm:0.28.6"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@gerrit0/mini-shiki": "npm:^3.2.2"
|
"@gerrit0/mini-shiki": "npm:^3.2.2"
|
||||||
lunr: "npm:^2.3.9"
|
lunr: "npm:^2.3.9"
|
||||||
|
@ -10687,7 +10704,7 @@ __metadata:
|
||||||
typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x
|
typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x
|
||||||
bin:
|
bin:
|
||||||
typedoc: bin/typedoc
|
typedoc: bin/typedoc
|
||||||
checksum: 10c0/fc8235dbe8f14da24fdb088467b01887b3f1375b27d5caf0276ae405f03aa1f523e94aea52fe8ce1a3d477ae9e3f4f69fdc28614275445a828a77db88784e6ce
|
checksum: 10c0/f83f4ceef6e7b55c4547798d069f64a284df2e93052f317ea09d7f1d345caf73e9247bd38b04702be5f5c79848873b1216c3dbaf284bf4657bdbf7b144ecc9bb
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
@ -11297,8 +11314,8 @@ __metadata:
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"zod@npm:^3.25.60":
|
"zod@npm:^3.25.60":
|
||||||
version: 3.25.67
|
version: 3.25.74
|
||||||
resolution: "zod@npm:3.25.67"
|
resolution: "zod@npm:3.25.74"
|
||||||
checksum: 10c0/80a0cab3033272c4ab9312198081f0c4ea88e9673c059aa36dc32024906363729db54bdb78f3dc9d5529bd1601f74974d5a56c0a23e40c6f04a9270c9ff22336
|
checksum: 10c0/59e38b046ac333b5bd1ba325a83b6798721227cbfb1e69dfc7159bd7824b904241ab923026edb714fafefec3624265ae374a70aee9a5a45b365bd31781ffa105
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue