Compare commits
45 commits
style/new_
...
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 |
125 changed files with 3608 additions and 1626 deletions
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
|
||||||
|
|
|
@ -1,21 +1,4 @@
|
||||||
{
|
{
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"jsxSingleQuote": true,
|
"jsxSingleQuote": true
|
||||||
"semi": true,
|
|
||||||
"trailingComma": "all",
|
|
||||||
"printWidth": 80,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"endOfLine": "lf",
|
|
||||||
"importOrder": [
|
|
||||||
"^@/components/(.*)$",
|
|
||||||
"^@/lib/(.*)$",
|
|
||||||
"^@/app/(.*)$",
|
|
||||||
"^@/generated/(.*)$",
|
|
||||||
"^@/(auth|prisma)$",
|
|
||||||
"^[./]"
|
|
||||||
],
|
|
||||||
"importOrderSeparation": true,
|
|
||||||
"importOrderSortSpecifiers": true,
|
|
||||||
"plugins": ["@trivago/prettier-plugin-sort-imports"]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,8 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
|
|
||||||
e2e: {
|
e2e: {
|
||||||
|
setupNodeEvents(on, config) {
|
||||||
|
// implement node event listeners here
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,4 +1,3 @@
|
||||||
// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths
|
|
||||||
import { PrismaClient } from '../../src/generated/prisma';
|
import { PrismaClient } from '../../src/generated/prisma';
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable @typescript-eslint/no-namespace */
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* 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
|
||||||
|
@ -46,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 {
|
||||||
|
@ -57,6 +73,7 @@ declare global {
|
||||||
selector: string,
|
selector: string,
|
||||||
...args: any[]
|
...args: any[]
|
||||||
): Chainable<JQuery<HTMLElement>>;
|
): Chainable<JQuery<HTMLElement>>;
|
||||||
|
login(): Chainable<void>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* eslint-disable @typescript-eslint/no-namespace */
|
|
||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
// This example support/component.ts is processed and
|
// This example support/component.ts is processed and
|
||||||
// loaded automatically before your test files.
|
// loaded automatically before your test files.
|
||||||
|
@ -13,13 +12,14 @@
|
||||||
// You can read more here:
|
// You can read more here:
|
||||||
// https://on.cypress.io/configuration
|
// https://on.cypress.io/configuration
|
||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
import { mount } from 'cypress/react';
|
|
||||||
|
|
||||||
import '@/app/globals.css';
|
import '@/app/globals.css';
|
||||||
|
|
||||||
// Import commands.js using ES2015 syntax:
|
// Import commands.js using ES2015 syntax:
|
||||||
import './commands';
|
import './commands';
|
||||||
|
|
||||||
|
import { mount } from 'cypress/react';
|
||||||
|
|
||||||
// Augment the Cypress namespace to include type definitions for
|
// Augment the Cypress namespace to include type definitions for
|
||||||
// your custom command.
|
// your custom command.
|
||||||
// Alternatively, can be defined in cypress/support/component.d.ts
|
// Alternatively, can be defined in cypress/support/component.d.ts
|
||||||
|
|
|
@ -12,5 +12,6 @@
|
||||||
// You can read more here:
|
// You can read more here:
|
||||||
// https://on.cypress.io/configuration
|
// https://on.cypress.io/configuration
|
||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
|
|
||||||
// Import commands.js using ES2015 syntax:
|
// Import commands.js using ES2015 syntax:
|
||||||
import './commands';
|
import './commands';
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { FlatCompat } from '@eslint/eslintrc';
|
|
||||||
import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths';
|
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
import { FlatCompat } from '@eslint/eslintrc';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
|
@ -15,21 +14,6 @@ const eslintConfig = [
|
||||||
{
|
{
|
||||||
ignores: ['src/generated/**', '.next/**', 'public/**'],
|
ignores: ['src/generated/**', '.next/**', 'public/**'],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
plugins: {
|
|
||||||
'no-relative-import-paths': noRelativeImportPaths,
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'no-relative-import-paths/no-relative-import-paths': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
allowSameFolder: true,
|
|
||||||
rootDir: 'src',
|
|
||||||
prefix: "@",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export default eslintConfig;
|
export default eslintConfig;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
import { registry } from '@/lib/swagger';
|
||||||
import { OpenApiGeneratorV3 } from '@asteasolutions/zod-to-openapi';
|
import { OpenApiGeneratorV3 } from '@asteasolutions/zod-to-openapi';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { registry } from '@/lib/swagger';
|
|
||||||
|
|
||||||
function recursiveFileSearch(dir: string, fileList: string[] = []): string[] {
|
function recursiveFileSearch(dir: string, fileList: string[] = []): string[] {
|
||||||
const files = fs.readdirSync(dir);
|
const files = fs.readdirSync(dir);
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
|
|
|
@ -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: '/**',
|
||||||
},
|
},
|
||||||
|
|
10
package.json
10
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",
|
||||||
|
@ -73,19 +73,17 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "3.3.1",
|
"@eslint/eslintrc": "3.3.1",
|
||||||
"@tailwindcss/postcss": "4.1.11",
|
"@tailwindcss/postcss": "4.1.11",
|
||||||
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
"@types/node": "22.16.0",
|
||||||
"@types/node": "22.15.34",
|
|
||||||
"@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.30.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",
|
||||||
"eslint-plugin-no-relative-import-paths": "^1.6.1",
|
|
||||||
"orval": "7.10.0",
|
"orval": "7.10.0",
|
||||||
"postcss": "8.5.6",
|
"postcss": "8.5.6",
|
||||||
"prettier": "3.6.2",
|
"prettier": "3.6.2",
|
||||||
|
|
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>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,16 +1,20 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useSession } from 'next-auth/react';
|
|
||||||
import { useParams, useRouter } from 'next/navigation';
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { toast } from 'sonner';
|
|
||||||
|
|
||||||
import { RedirectButton } from '@/components/buttons/redirect-button';
|
|
||||||
import ParticipantListEntry from '@/components/custom-ui/participant-list-entry';
|
|
||||||
import Logo from '@/components/misc/logo';
|
import Logo from '@/components/misc/logo';
|
||||||
import { ToastInner } from '@/components/misc/toast-inner';
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import {
|
||||||
|
useDeleteApiEventEventID,
|
||||||
|
useGetApiEventEventID,
|
||||||
|
} from '@/generated/api/event/event';
|
||||||
|
import { RedirectButton } from '@/components/buttons/redirect-button';
|
||||||
|
import { useSession } from 'next-auth/react';
|
||||||
|
import ParticipantListEntry from '@/components/custom-ui/participant-list-entry';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { ToastInner } from '@/components/misc/toast-inner';
|
||||||
|
import { toast } from 'sonner';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
@ -20,13 +24,6 @@ import {
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from '@/components/ui/dialog';
|
} from '@/components/ui/dialog';
|
||||||
import { Label } from '@/components/ui/label';
|
|
||||||
|
|
||||||
import {
|
|
||||||
useDeleteApiEventEventID,
|
|
||||||
useGetApiEventEventID,
|
|
||||||
} from '@/generated/api/event/event';
|
|
||||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
|
||||||
|
|
||||||
export default function ShowEvent() {
|
export default function ShowEvent() {
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
|
@ -37,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 '-';
|
||||||
|
@ -72,167 +63,186 @@ export default function ShowEvent() {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className='w-[80%] max-w-screen p-0 gap-0 max-xl:w-[95%] mx-auto'>
|
<div>
|
||||||
<CardHeader className='p-0 m-0 gap-0' />
|
<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' />
|
||||||
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className='flex flex-col gap-5 w-full'>
|
<div className='flex flex-col gap-5 w-full'>
|
||||||
<div className='grid grid-row-start:auto gap-4 sm:gap-8'>
|
<div className='grid grid-row-start:auto gap-4 sm:gap-8'>
|
||||||
<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='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'>
|
<div className='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||||
<Logo colorType='monochrome' logoType='submark' width={50} />
|
<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'>
|
||||||
|
{eventData.data.event.title || 'Untitled Event'}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className='w-0 sm:w-[100px]'></div>
|
||||||
</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='grid grid-cols-4 gap-4 h-full w-full max-lg:grid-cols-2 max-sm:grid-cols-1'>
|
||||||
<h1 className='text-center'>
|
<div>
|
||||||
{event.title || 'Untitled Event'}
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
</h1>
|
start Time
|
||||||
</div>
|
|
||||||
<div className='w-0 sm:w-[100px]'></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>
|
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
|
||||||
start Time
|
|
||||||
</Label>
|
|
||||||
<Label size='large'>
|
|
||||||
{event.start_time
|
|
||||||
? `${formatDate(event.start_time)} ${formatTime(event.start_time)}`
|
|
||||||
: '-'}
|
|
||||||
</Label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
|
||||||
end Time
|
|
||||||
</Label>
|
|
||||||
<Label size='large'>
|
|
||||||
{event.end_time
|
|
||||||
? `${formatDate(event.end_time)} ${formatTime(event.end_time)}`
|
|
||||||
: '-'}
|
|
||||||
</Label>
|
|
||||||
</div>
|
|
||||||
<div className='w-54'>
|
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
|
||||||
Location
|
|
||||||
</Label>
|
|
||||||
<Label size='large'>{event.location || '-'}</Label>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-4'>
|
|
||||||
<div className='flex flex-row gap-2'>
|
|
||||||
<Label className='w-[70px] text-[var(--color-neutral-300)]'>
|
|
||||||
created:
|
|
||||||
</Label>
|
</Label>
|
||||||
<Label>
|
<Label size='large'>
|
||||||
{event.created_at ? formatDate(event.created_at) : '-'}
|
{eventData.data.event.start_time
|
||||||
|
? `${formatDate(eventData.data.event.start_time)} ${formatTime(eventData.data.event.start_time)}`
|
||||||
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-row gap-2'>
|
<div>
|
||||||
<Label className='w-[70px] text-[var(--color-neutral-300)]'>
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
updated:
|
end Time
|
||||||
</Label>
|
</Label>
|
||||||
<Label>
|
<Label size='large'>
|
||||||
{event.updated_at ? formatDate(event.updated_at) : '-'}
|
{eventData.data.event.end_time
|
||||||
|
? `${formatDate(eventData.data.event.end_time)} ${formatTime(eventData.data.event.end_time)}`
|
||||||
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className='w-54'>
|
||||||
</div>
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
<div className='h-full w-full grid grid-cols-2 gap-4 max-sm:grid-cols-1'>
|
Location
|
||||||
<div className='h-full w-full grid grid-flow-row gap-4 sm:gap-8'>
|
</Label>
|
||||||
<div className='h-full w-full'>
|
<Label size='large'>
|
||||||
|
{eventData.data.event.location || '-'}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
<div className='flex flex-col gap-4'>
|
||||||
<div className='flex flex-row gap-2'>
|
<div className='flex flex-row gap-2'>
|
||||||
<Label className='text-[var(--color-neutral-300)]'>
|
<Label className='w-[70px] text-[var(--color-neutral-300)]'>
|
||||||
Organiser:
|
created:
|
||||||
|
</Label>
|
||||||
|
<Label>
|
||||||
|
{eventData.data.event.created_at
|
||||||
|
? formatDate(eventData.data.event.created_at)
|
||||||
|
: '-'}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
<div className='flex flex-row gap-2'>
|
||||||
|
<Label className='w-[70px] text-[var(--color-neutral-300)]'>
|
||||||
|
updated:
|
||||||
|
</Label>
|
||||||
|
<Label>
|
||||||
|
{eventData.data.event.updated_at
|
||||||
|
? formatDate(eventData.data.event.updated_at)
|
||||||
|
: '-'}
|
||||||
</Label>
|
</Label>
|
||||||
<Label size='large'>{organiserName}</Label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-full w-full'>
|
</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 sm:gap-8'>
|
||||||
|
<div className='h-full w-full'>
|
||||||
|
<div className='flex flex-row gap-2'>
|
||||||
|
<Label className='text-[var(--color-neutral-300)]'>
|
||||||
|
Organiser:
|
||||||
|
</Label>
|
||||||
|
<Label size='large'>
|
||||||
|
{eventData.data.event.organizer.name || 'Unknown User'}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='h-full w-full'>
|
||||||
|
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||||
|
Description
|
||||||
|
</Label>
|
||||||
|
<Label size='large'>
|
||||||
|
{eventData.data.event.description || '-'}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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'>
|
||||||
Description
|
Participants
|
||||||
</Label>
|
</Label>{' '}
|
||||||
<Label size='large'>{event.description || '-'}</Label>
|
<div className='grid grid-cols-1 mt-3'>
|
||||||
|
{eventData.data.event.participants?.map((user) => (
|
||||||
|
<ParticipantListEntry
|
||||||
|
key={user.user.id}
|
||||||
|
{...user}
|
||||||
|
eventID={eventData.data.event.id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-full w-full mt-2'>
|
|
||||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
|
||||||
Participants
|
|
||||||
</Label>{' '}
|
|
||||||
<div className='grid grid-cols-1 mt-3 sm:max-h-60 sm:grid-cols-2 sm:overflow-y-auto sm:mb-0'>
|
|
||||||
{event.participants?.map((user) => (
|
|
||||||
<ParticipantListEntry key={user.user.id} {...user} />
|
|
||||||
))}
|
|
||||||
</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-full'>
|
<div className='w-[20%] grid max-sm:w-full'>
|
||||||
{session.data?.user?.id === event.organizer.id ? (
|
{session.data?.user?.id ===
|
||||||
<Dialog
|
eventData.data.event.organizer.id ? (
|
||||||
open={deleteDialogOpen}
|
<Dialog
|
||||||
onOpenChange={setDeleteDialogOpen}
|
open={deleteDialogOpen}
|
||||||
>
|
onOpenChange={setDeleteDialogOpen}
|
||||||
<DialogTrigger asChild>
|
>
|
||||||
<Button variant='destructive' className='w-full'>
|
<DialogTrigger asChild>
|
||||||
delete
|
<Button variant='destructive' className='w-full'>
|
||||||
</Button>
|
delete
|
||||||
</DialogTrigger>
|
|
||||||
<DialogContent>
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>Delete Event</DialogTitle>
|
|
||||||
<DialogDescription>
|
|
||||||
Are you sure you want to delete the event “
|
|
||||||
{event.title}”? This action cannot be undone.
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
<DialogFooter>
|
|
||||||
<Button
|
|
||||||
variant='secondary'
|
|
||||||
onClick={() => setDeleteDialogOpen(false)}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
</DialogTrigger>
|
||||||
variant='muted'
|
<DialogContent>
|
||||||
onClick={() => {
|
<DialogHeader>
|
||||||
deleteEvent.mutate(
|
<DialogTitle>Delete Event</DialogTitle>
|
||||||
{ eventID: event.id },
|
<DialogDescription>
|
||||||
{
|
Are you sure you want to delete the event “
|
||||||
onSuccess: () => {
|
{eventData.data.event.title}”? This action
|
||||||
router.push('/home');
|
cannot be undone.
|
||||||
toast.custom((t) => (
|
</DialogDescription>
|
||||||
<ToastInner
|
</DialogHeader>
|
||||||
toastId={t}
|
<DialogFooter>
|
||||||
title='Event deleted'
|
<Button
|
||||||
description={event?.title}
|
variant='secondary'
|
||||||
variant='success'
|
onClick={() => setDeleteDialogOpen(false)}
|
||||||
/>
|
>
|
||||||
));
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant='muted'
|
||||||
|
onClick={() => {
|
||||||
|
deleteEvent.mutate(
|
||||||
|
{ eventID: eventData.data.event.id },
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
router.push('/home');
|
||||||
|
toast.custom((t) => (
|
||||||
|
<ToastInner
|
||||||
|
toastId={t}
|
||||||
|
title='Event deleted'
|
||||||
|
description={eventData.data.event.title}
|
||||||
|
variant='success'
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
);
|
||||||
);
|
setDeleteDialogOpen(false);
|
||||||
setDeleteDialogOpen(false);
|
}}
|
||||||
}}
|
>
|
||||||
>
|
Delete
|
||||||
Delete
|
</Button>
|
||||||
</Button>
|
</DialogFooter>
|
||||||
</DialogFooter>
|
</DialogContent>
|
||||||
</DialogContent>
|
</Dialog>
|
||||||
</Dialog>
|
) : 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 ===
|
||||||
{session.data?.user?.id === event.organizer.id ? (
|
eventData.data.event.organizer.id ? (
|
||||||
<RedirectButton
|
<RedirectButton
|
||||||
redirectUrl={`/events/edit/${eventID}`}
|
redirectUrl={`/events/edit/${eventID}`}
|
||||||
buttonText='edit'
|
buttonText='edit'
|
||||||
className='w-full'
|
className='w-full'
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</CardContent>
|
||||||
</CardContent>
|
</Card>
|
||||||
</Card>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import EventForm from '@/components/forms/event-form';
|
|
||||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||||
|
import EventForm from '@/components/forms/event-form';
|
||||||
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
params,
|
params,
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import EventForm from '@/components/forms/event-form';
|
|
||||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||||
|
import EventForm from '@/components/forms/event-form';
|
||||||
|
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'>
|
||||||
<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' />
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import { RedirectButton } from '@/components/buttons/redirect-button';
|
import { RedirectButton } from '@/components/buttons/redirect-button';
|
||||||
import EventListEntry from '@/components/custom-ui/event-list-entry';
|
import EventListEntry from '@/components/custom-ui/event-list-entry';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { useGetApiEvent } from '@/generated/api/event/event';
|
import { useGetApiEvent } from '@/generated/api/event/event';
|
||||||
|
|
||||||
export default function Events() {
|
export default function Events() {
|
||||||
|
@ -18,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
|
||||||
|
@ -26,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
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import Calendar from '@/components/calendar';
|
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() {
|
||||||
|
@ -15,7 +14,9 @@ export default function Home() {
|
||||||
<span style={{ whiteSpace: 'nowrap' }}>
|
<span style={{ whiteSpace: 'nowrap' }}>
|
||||||
{isLoading
|
{isLoading
|
||||||
? 'Loading...'
|
? 'Loading...'
|
||||||
: data?.data.user?.first_name || 'Unknown User'}{' '}
|
: data?.data.user?.first_name ||
|
||||||
|
data?.data.user?.name ||
|
||||||
|
'Unknown User'}{' '}
|
||||||
👋
|
👋
|
||||||
</span>
|
</span>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { cookies } from 'next/headers';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { cookies } from 'next/headers';
|
||||||
|
|
||||||
import { AppSidebar } from '@/components/custom-ui/app-sidebar';
|
import { AppSidebar } from '@/components/custom-ui/app-sidebar';
|
||||||
import Header from '@/components/misc/header';
|
|
||||||
import SidebarProviderWrapper from '@/components/wrappers/sidebar-provider';
|
import SidebarProviderWrapper from '@/components/wrappers/sidebar-provider';
|
||||||
|
import Header from '@/components/misc/header';
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { getApiDocs } from '@/lib/swagger';
|
import { getApiDocs } from '@/lib/swagger';
|
||||||
|
|
||||||
import ReactSwagger from './react-swagger';
|
import ReactSwagger from './react-swagger';
|
||||||
|
|
||||||
export default async function IndexPage() {
|
export default async function IndexPage() {
|
||||||
|
|
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(),
|
||||||
|
});
|
|
@ -1,23 +1,19 @@
|
||||||
import { z } from 'zod/v4';
|
import { auth } from '@/auth';
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
import {
|
||||||
|
userCalendarQuerySchema,
|
||||||
|
UserCalendarResponseSchema,
|
||||||
|
UserCalendarSchema,
|
||||||
|
} from './validation';
|
||||||
import {
|
import {
|
||||||
ErrorResponseSchema,
|
ErrorResponseSchema,
|
||||||
ZodErrorResponseSchema,
|
ZodErrorResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
|
import { z } from 'zod/v4';
|
||||||
import { auth } from '@/auth';
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
import {
|
|
||||||
UserCalendarResponseSchema,
|
|
||||||
UserCalendarSchema,
|
|
||||||
userCalendarQuerySchema,
|
|
||||||
} from './validation';
|
|
||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
const authCheck = userAuthenticated(req);
|
const authCheck = userAuthenticated(req);
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import {
|
||||||
|
userCalendarQuerySchema,
|
||||||
|
UserCalendarResponseSchema,
|
||||||
|
} from './validation';
|
||||||
import {
|
import {
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
import {
|
|
||||||
UserCalendarResponseSchema,
|
|
||||||
userCalendarQuerySchema,
|
|
||||||
} from './validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
EventSchema,
|
|
||||||
eventEndTimeSchema,
|
eventEndTimeSchema,
|
||||||
|
EventSchema,
|
||||||
eventStartTimeSchema,
|
eventStartTimeSchema,
|
||||||
} from '@/app/api/event/validation';
|
} from '@/app/api/event/validation';
|
||||||
|
|
||||||
|
@ -49,6 +48,7 @@ export const VisibleSlotSchema = EventSchema.omit({
|
||||||
type: zod.literal('event'),
|
type: zod.literal('event'),
|
||||||
users: zod.string().array(),
|
users: zod.string().array(),
|
||||||
user_id: zod.string().optional(),
|
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',
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import { auth } from '@/auth';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ErrorResponseSchema,
|
ErrorResponseSchema,
|
||||||
SuccessResponseSchema,
|
SuccessResponseSchema,
|
||||||
ZodErrorResponseSchema,
|
ZodErrorResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
|
|
||||||
import { auth } from '@/auth';
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ParticipantResponseSchema,
|
ParticipantResponseSchema,
|
||||||
updateParticipantSchema,
|
updateParticipantSchema,
|
||||||
} from '@/app/api/event/[eventID]/participant/validation';
|
} from '../validation';
|
||||||
|
|
||||||
export const GET = auth(async (req, { params }) => {
|
export const GET = auth(async (req, { params }) => {
|
||||||
const authCheck = userAuthenticated(req);
|
const authCheck = userAuthenticated(req);
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
|
import {
|
||||||
|
ParticipantResponseSchema,
|
||||||
|
updateParticipantSchema,
|
||||||
|
} from '../validation';
|
||||||
import {
|
import {
|
||||||
invalidRequestDataResponse,
|
invalidRequestDataResponse,
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
serverReturnedDataValidationErrorResponse,
|
serverReturnedDataValidationErrorResponse,
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
EventIdParamSchema,
|
EventIdParamSchema,
|
||||||
SuccessResponseSchema,
|
|
||||||
UserIdParamSchema,
|
UserIdParamSchema,
|
||||||
|
SuccessResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
|
|
||||||
import {
|
|
||||||
ParticipantResponseSchema,
|
|
||||||
updateParticipantSchema,
|
|
||||||
} from '@/app/api/event/[eventID]/participant/validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import { auth } from '@/auth';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ErrorResponseSchema,
|
ErrorResponseSchema,
|
||||||
ZodErrorResponseSchema,
|
ZodErrorResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
|
|
||||||
import { auth } from '@/auth';
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
inviteParticipantSchema,
|
||||||
ParticipantResponseSchema,
|
ParticipantResponseSchema,
|
||||||
ParticipantsResponseSchema,
|
ParticipantsResponseSchema,
|
||||||
inviteParticipantSchema,
|
|
||||||
} from './validation';
|
} from './validation';
|
||||||
|
|
||||||
export const GET = auth(async (req, { params }) => {
|
export const GET = auth(async (req, { params }) => {
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
|
import {
|
||||||
|
ParticipantsResponseSchema,
|
||||||
|
ParticipantResponseSchema,
|
||||||
|
inviteParticipantSchema,
|
||||||
|
} from './validation';
|
||||||
import {
|
import {
|
||||||
invalidRequestDataResponse,
|
invalidRequestDataResponse,
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
serverReturnedDataValidationErrorResponse,
|
serverReturnedDataValidationErrorResponse,
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
|
||||||
import { EventIdParamSchema } from '@/app/api/validation';
|
import { EventIdParamSchema } from '@/app/api/validation';
|
||||||
|
|
||||||
import {
|
|
||||||
ParticipantResponseSchema,
|
|
||||||
ParticipantsResponseSchema,
|
|
||||||
inviteParticipantSchema,
|
|
||||||
} from './validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PublicUserSchema,
|
|
||||||
existingUserIdServerSchema,
|
existingUserIdServerSchema,
|
||||||
|
PublicUserSchema,
|
||||||
} from '@/app/api/user/validation';
|
} from '@/app/api/user/validation';
|
||||||
|
|
||||||
extendZodWithOpenApi(zod);
|
extendZodWithOpenApi(zod);
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import { auth } from '@/auth';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
|
||||||
import {
|
|
||||||
EventResponseSchema,
|
|
||||||
updateEventSchema,
|
|
||||||
} from '@/app/api/event/validation';
|
|
||||||
import {
|
import {
|
||||||
ErrorResponseSchema,
|
ErrorResponseSchema,
|
||||||
SuccessResponseSchema,
|
SuccessResponseSchema,
|
||||||
ZodErrorResponseSchema,
|
ZodErrorResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '../../validation';
|
||||||
|
import { EventResponseSchema } from '../validation';
|
||||||
import { auth } from '@/auth';
|
import { updateEventSchema } from '../validation';
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
export const GET = auth(async (req, { params }) => {
|
export const GET = auth(async (req, { params }) => {
|
||||||
const authCheck = userAuthenticated(req);
|
const authCheck = userAuthenticated(req);
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
import { EventResponseSchema, updateEventSchema } from '../validation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
invalidRequestDataResponse,
|
invalidRequestDataResponse,
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
serverReturnedDataValidationErrorResponse,
|
serverReturnedDataValidationErrorResponse,
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
EventIdParamSchema,
|
EventIdParamSchema,
|
||||||
SuccessResponseSchema,
|
SuccessResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
|
import zod from 'zod/v4';
|
||||||
import { EventResponseSchema, updateEventSchema } from '@/app/api/event/validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import { auth } from '@/auth';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
import { ErrorResponseSchema, ZodErrorResponseSchema } from '../validation';
|
||||||
import { auth } from '@/auth';
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
import { ErrorResponseSchema, ZodErrorResponseSchema } from '@/app/api/validation';
|
|
||||||
import {
|
import {
|
||||||
|
createEventSchema,
|
||||||
EventResponseSchema,
|
EventResponseSchema,
|
||||||
EventsResponseSchema,
|
EventsResponseSchema,
|
||||||
createEventSchema,
|
|
||||||
} from './validation';
|
} from './validation';
|
||||||
|
|
||||||
export const GET = auth(async (req) => {
|
export const GET = auth(async (req) => {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
|
import {
|
||||||
|
EventResponseSchema,
|
||||||
|
EventsResponseSchema,
|
||||||
|
createEventSchema,
|
||||||
|
} from './validation';
|
||||||
import {
|
import {
|
||||||
invalidRequestDataResponse,
|
invalidRequestDataResponse,
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
|
@ -7,12 +11,6 @@ import {
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
|
||||||
import {
|
|
||||||
EventResponseSchema,
|
|
||||||
EventsResponseSchema,
|
|
||||||
createEventSchema,
|
|
||||||
} from './validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PublicUserSchema,
|
|
||||||
existingUserIdServerSchema,
|
existingUserIdServerSchema,
|
||||||
} from '@/app/api/user/validation';
|
PublicUserSchema,
|
||||||
|
} from '../user/validation';
|
||||||
import { ParticipantSchema } from './[eventID]/participant/validation';
|
import { ParticipantSchema } from './[eventID]/participant/validation';
|
||||||
|
|
||||||
extendZodWithOpenApi(zod);
|
extendZodWithOpenApi(zod);
|
||||||
|
|
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');
|
||||||
|
};
|
|
@ -1,18 +1,15 @@
|
||||||
|
import { auth } from '@/auth';
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import { searchUserSchema, searchUserResponseSchema } from './validation';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ErrorResponseSchema,
|
ErrorResponseSchema,
|
||||||
ZodErrorResponseSchema,
|
ZodErrorResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
|
|
||||||
import { auth } from '@/auth';
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
import { searchUserResponseSchema, searchUserSchema } from './validation';
|
|
||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
const authCheck = userAuthenticated(req);
|
const authCheck = userAuthenticated(req);
|
||||||
if (!authCheck.continue)
|
if (!authCheck.continue)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
|
import { searchUserResponseSchema, searchUserSchema } from './validation';
|
||||||
import {
|
import {
|
||||||
invalidRequestDataResponse,
|
invalidRequestDataResponse,
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
|
@ -7,8 +7,6 @@ import {
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
|
||||||
import { searchUserResponseSchema, searchUserSchema } from './validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
|
import { PublicUserSchema } from '../../user/validation';
|
||||||
import { PublicUserSchema } from '@/app/api/user/validation';
|
|
||||||
|
|
||||||
export const searchUserSchema = zod.object({
|
export const searchUserSchema = zod.object({
|
||||||
query: zod.string().optional().default(''),
|
query: zod.string().optional().default(''),
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
|
import { auth } from '@/auth';
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
import { PublicUserResponseSchema } from '../validation';
|
||||||
import { ErrorResponseSchema } from '@/app/api/validation';
|
import { ErrorResponseSchema } from '@/app/api/validation';
|
||||||
|
|
||||||
import { auth } from '@/auth';
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
import { PublicUserResponseSchema } from '@/app/api/user/validation';
|
|
||||||
|
|
||||||
export const GET = auth(async function GET(req, { params }) {
|
export const GET = auth(async function GET(req, { params }) {
|
||||||
const authCheck = userAuthenticated(req);
|
const authCheck = userAuthenticated(req);
|
||||||
if (!authCheck.continue)
|
if (!authCheck.continue)
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { PublicUserResponseSchema } from '../validation';
|
||||||
import zod from 'zod/v4';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
import { UserIdParamSchema } from '@/app/api/validation';
|
import zod from 'zod/v4';
|
||||||
import { PublicUserResponseSchema } from '@/app/api/user/validation';
|
import { UserIdParamSchema } from '../../validation';
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
import bcrypt from 'bcryptjs';
|
import { auth } from '@/auth';
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import { updateUserPasswordServerSchema } from '../validation';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
import { FullUserResponseSchema } from '../../validation';
|
||||||
import {
|
import {
|
||||||
ErrorResponseSchema,
|
ErrorResponseSchema,
|
||||||
ZodErrorResponseSchema,
|
ZodErrorResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
|
import bcrypt from 'bcryptjs';
|
||||||
import { auth } from '@/auth';
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
import { FullUserResponseSchema } from '@/app/api/user/validation';
|
|
||||||
import { updateUserPasswordServerSchema } from '@/app/api/user/me/validation';
|
|
||||||
|
|
||||||
export const PATCH = auth(async function PATCH(req) {
|
export const PATCH = auth(async function PATCH(req) {
|
||||||
const authCheck = userAuthenticated(req);
|
const authCheck = userAuthenticated(req);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
|
import { FullUserResponseSchema } from '../../validation';
|
||||||
|
import { updateUserPasswordServerSchema } from '../validation';
|
||||||
import {
|
import {
|
||||||
invalidRequestDataResponse,
|
invalidRequestDataResponse,
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
|
@ -7,9 +8,6 @@ import {
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
|
||||||
import { FullUserResponseSchema } from '@/app/api/user/validation';
|
|
||||||
import { updateUserPasswordServerSchema } from '@/app/api/user/me/validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
|
import { auth } from '@/auth';
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
import { updateUserServerSchema } from './validation';
|
||||||
import {
|
import {
|
||||||
returnZodTypeCheckedResponse,
|
returnZodTypeCheckedResponse,
|
||||||
userAuthenticated,
|
userAuthenticated,
|
||||||
} from '@/lib/apiHelpers';
|
} from '@/lib/apiHelpers';
|
||||||
|
import { FullUserResponseSchema } from '../validation';
|
||||||
import {
|
import {
|
||||||
ErrorResponseSchema,
|
ErrorResponseSchema,
|
||||||
SuccessResponseSchema,
|
SuccessResponseSchema,
|
||||||
ZodErrorResponseSchema,
|
ZodErrorResponseSchema,
|
||||||
} from '@/app/api/validation';
|
} from '@/app/api/validation';
|
||||||
|
|
||||||
import { auth } from '@/auth';
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
import { FullUserResponseSchema } from '@/app/api/user/validation';
|
|
||||||
import { updateUserServerSchema } from './validation';
|
|
||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
const authCheck = userAuthenticated(req);
|
const authCheck = userAuthenticated(req);
|
||||||
if (!authCheck.continue)
|
if (!authCheck.continue)
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
|
import { FullUserResponseSchema } from '../validation';
|
||||||
|
import { updateUserServerSchema } from './validation';
|
||||||
import {
|
import {
|
||||||
invalidRequestDataResponse,
|
invalidRequestDataResponse,
|
||||||
notAuthenticatedResponse,
|
notAuthenticatedResponse,
|
||||||
serverReturnedDataValidationErrorResponse,
|
serverReturnedDataValidationErrorResponse,
|
||||||
userNotFoundResponse,
|
userNotFoundResponse,
|
||||||
} from '@/lib/defaultApiResponses';
|
} from '@/lib/defaultApiResponses';
|
||||||
|
import { SuccessResponseSchema } from '../../validation';
|
||||||
import { SuccessResponseSchema } from '@/app/api/validation';
|
|
||||||
import { FullUserResponseSchema } from '@/app/api/user/validation';
|
|
||||||
import { updateUserServerSchema } from './validation';
|
|
||||||
|
|
||||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
|
|
|
@ -1,12 +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';
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
@ -23,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'),
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
|
||||||
|
|
||||||
import { allTimeZones } from '@/lib/timezones';
|
|
||||||
|
|
||||||
import { prisma } from '@/prisma';
|
import { prisma } from '@/prisma';
|
||||||
|
import zod from 'zod/v4';
|
||||||
|
import { allTimeZones } from '@/lib/timezones';
|
||||||
|
|
||||||
extendZodWithOpenApi(zod);
|
extendZodWithOpenApi(zod);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
import { registry } from '@/lib/swagger';
|
||||||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||||
import zod from 'zod/v4';
|
import zod from 'zod/v4';
|
||||||
|
|
||||||
import { registry } from '@/lib/swagger';
|
|
||||||
|
|
||||||
extendZodWithOpenApi(zod);
|
extendZodWithOpenApi(zod);
|
||||||
|
|
||||||
export const ErrorResponseSchema = zod
|
export const ErrorResponseSchema = zod
|
||||||
|
@ -86,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',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import type { Metadata } from 'next';
|
|
||||||
import { SessionProvider } from 'next-auth/react';
|
|
||||||
|
|
||||||
import { Toaster } from '@/components/ui/sonner';
|
|
||||||
import { QueryProvider } from '@/components/wrappers/query-provider';
|
|
||||||
import { ThemeProvider } from '@/components/wrappers/theme-provider';
|
import { ThemeProvider } from '@/components/wrappers/theme-provider';
|
||||||
|
|
||||||
|
import type { Metadata } from 'next';
|
||||||
import './globals.css';
|
import './globals.css';
|
||||||
|
import { QueryProvider } from '@/components/wrappers/query-provider';
|
||||||
|
import { Toaster } from '@/components/ui/sonner';
|
||||||
|
import { SessionProvider } from 'next-auth/react';
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: 'MeetUp',
|
title: 'MeetUp',
|
||||||
|
|
|
@ -1,24 +1,22 @@
|
||||||
import Image from 'next/image';
|
import { auth, providerMap } from '@/auth';
|
||||||
import { redirect } from 'next/navigation';
|
|
||||||
|
|
||||||
import SSOLogin from '@/components/buttons/sso-login-button';
|
import SSOLogin from '@/components/buttons/sso-login-button';
|
||||||
|
import LoginForm from '@/components/forms/login-form';
|
||||||
|
import { redirect } from 'next/navigation';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import Image from 'next/image';
|
||||||
|
import { Separator } from '@/components/ui/separator';
|
||||||
|
import Logo from '@/components/misc/logo';
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
} from '@/components/custom-ui/login-card';
|
} from '@/components/custom-ui/login-card';
|
||||||
import LoginForm from '@/components/forms/login-form';
|
|
||||||
import Logo from '@/components/misc/logo';
|
|
||||||
import { ThemePicker } from '@/components/misc/theme-picker';
|
import { ThemePicker } from '@/components/misc/theme-picker';
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import {
|
import {
|
||||||
HoverCard,
|
HoverCard,
|
||||||
HoverCardContent,
|
|
||||||
HoverCardTrigger,
|
HoverCardTrigger,
|
||||||
|
HoverCardContent,
|
||||||
} from '@/components/ui/hover-card';
|
} from '@/components/ui/hover-card';
|
||||||
import { Separator } from '@/components/ui/separator';
|
|
||||||
|
|
||||||
import { auth, providerMap } from '@/auth';
|
|
||||||
|
|
||||||
export default async function LoginPage() {
|
export default async function LoginPage() {
|
||||||
const session = await auth();
|
const session = await auth();
|
||||||
|
@ -44,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
|
||||||
|
@ -63,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>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { signOut } from '@/auth';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
|
@ -7,8 +8,6 @@ import {
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from '@/components/ui/card';
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
import { signOut } from '@/auth';
|
|
||||||
|
|
||||||
export default function SignOutPage() {
|
export default function SignOutPage() {
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col items-center justify-center h-screen'>
|
<div className='flex flex-col items-center justify-center h-screen'>
|
||||||
|
|
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,6 +1,5 @@
|
||||||
import { redirect } from 'next/navigation';
|
|
||||||
|
|
||||||
import { auth } from '@/auth';
|
import { auth } from '@/auth';
|
||||||
|
import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
export default async function Home() {
|
export default async function Home() {
|
||||||
const session = await auth();
|
const session = await auth();
|
||||||
|
|
|
@ -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 {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from '@/components/ui/select';
|
|
||||||
import { Switch } from '@/components/ui/switch';
|
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
||||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
|
||||||
|
|
||||||
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
|
@ -1,21 +1,22 @@
|
||||||
import { PrismaAdapter } from '@auth/prisma-adapter';
|
|
||||||
import NextAuth, { CredentialsSignin } from 'next-auth';
|
import NextAuth, { CredentialsSignin } from 'next-auth';
|
||||||
|
|
||||||
|
import { Prisma } from '@/generated/prisma';
|
||||||
import type { Provider } from 'next-auth/providers';
|
import type { Provider } from 'next-auth/providers';
|
||||||
import AuthentikProvider from 'next-auth/providers/authentik';
|
|
||||||
import Credentials from 'next-auth/providers/credentials';
|
import Credentials from 'next-auth/providers/credentials';
|
||||||
|
import AuthentikProvider from 'next-auth/providers/authentik';
|
||||||
import DiscordProvider from 'next-auth/providers/discord';
|
import DiscordProvider from 'next-auth/providers/discord';
|
||||||
import FacebookProvider from 'next-auth/providers/facebook';
|
import FacebookProvider from 'next-auth/providers/facebook';
|
||||||
import GithubProvider from 'next-auth/providers/github';
|
import GithubProvider from 'next-auth/providers/github';
|
||||||
import GitlabProvider from 'next-auth/providers/gitlab';
|
import GitlabProvider from 'next-auth/providers/gitlab';
|
||||||
import GoogleProvider from 'next-auth/providers/google';
|
import GoogleProvider from 'next-auth/providers/google';
|
||||||
import KeycloakProvider from 'next-auth/providers/keycloak';
|
import KeycloakProvider from 'next-auth/providers/keycloak';
|
||||||
import { ZodError } from 'zod/v4';
|
|
||||||
|
import { PrismaAdapter } from '@auth/prisma-adapter';
|
||||||
|
import { prisma } from '@/prisma';
|
||||||
|
|
||||||
import { loginSchema } from '@/lib/auth/validation';
|
import { loginSchema } from '@/lib/auth/validation';
|
||||||
|
import { ZodError } from 'zod/v4';
|
||||||
import { Prisma } from '@/generated/prisma';
|
|
||||||
|
|
||||||
import { prisma } from '@/prisma';
|
|
||||||
|
|
||||||
class InvalidLoginError extends CredentialsSignin {
|
class InvalidLoginError extends CredentialsSignin {
|
||||||
constructor(code: string) {
|
constructor(code: string) {
|
||||||
|
@ -94,13 +95,27 @@ const providers: Provider[] = [
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
process.env.AUTH_AUTHENTIK_ID && AuthentikProvider,
|
|
||||||
process.env.AUTH_DISCORD_ID && DiscordProvider,
|
process.env.AUTH_DISCORD_ID && DiscordProvider,
|
||||||
process.env.AUTH_FACEBOOK_ID && FacebookProvider,
|
process.env.AUTH_FACEBOOK_ID && FacebookProvider,
|
||||||
process.env.AUTH_GITHUB_ID && GithubProvider,
|
process.env.AUTH_GITHUB_ID && GithubProvider,
|
||||||
process.env.AUTH_GITLAB_ID && GitlabProvider,
|
process.env.AUTH_GITLAB_ID && GitlabProvider,
|
||||||
process.env.AUTH_GOOGLE_ID && GoogleProvider,
|
process.env.AUTH_GOOGLE_ID && GoogleProvider,
|
||||||
process.env.AUTH_KEYCLOAK_ID && KeycloakProvider,
|
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 { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { LucideProps } from 'lucide-react';
|
||||||
|
import React, { ForwardRefExoticComponent, RefAttributes } from 'react';
|
||||||
|
|
||||||
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,10 +1,10 @@
|
||||||
import { NDot, NotificationDot } from '@/components/misc/notification-dot';
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/components/ui/dropdown-menu';
|
} from '@/components/ui/dropdown-menu';
|
||||||
|
import { NDot, NotificationDot } from '@/components/misc/notification-dot';
|
||||||
|
|
||||||
export function NotificationButton({
|
export function NotificationButton({
|
||||||
dotVariant,
|
dotVariant,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import Link from 'next/link';
|
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import Link from 'next/link';
|
||||||
|
|
||||||
export function RedirectButton({
|
export function RedirectButton({
|
||||||
redirectUrl,
|
redirectUrl,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { faOpenid } from '@fortawesome/free-brands-svg-icons';
|
|
||||||
|
|
||||||
import { IconButton } from '@/components/buttons/icon-button';
|
|
||||||
|
|
||||||
import { signIn } from '@/auth';
|
import { signIn } from '@/auth';
|
||||||
|
import { IconButton } from '@/components/buttons/icon-button';
|
||||||
|
import { Fingerprint } from 'lucide-react';
|
||||||
|
|
||||||
export default function SSOLogin({
|
export default function SSOLogin({
|
||||||
provider,
|
provider,
|
||||||
|
@ -24,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}
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { QueryErrorResetBoundary } from '@tanstack/react-query';
|
|
||||||
import moment from 'moment';
|
|
||||||
import { useSession } from 'next-auth/react';
|
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
import React from 'react';
|
|
||||||
import { Calendar as RBCalendar, momentLocalizer } from 'react-big-calendar';
|
import { Calendar as RBCalendar, momentLocalizer } from 'react-big-calendar';
|
||||||
import withDragAndDrop from 'react-big-calendar/lib/addons/dragAndDrop';
|
import withDragAndDrop from 'react-big-calendar/lib/addons/dragAndDrop';
|
||||||
|
import moment from 'moment';
|
||||||
|
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 React from 'react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { usePatchApiEventEventID } from '@/generated/api/event/event';
|
||||||
|
import { useSession } from 'next-auth/react';
|
||||||
|
import { UserCalendarSchemaItem } from '@/generated/api/meetup.schemas';
|
||||||
|
import { QueryErrorResetBoundary } from '@tanstack/react-query';
|
||||||
import { ErrorBoundary } from 'react-error-boundary';
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
|
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 CustomToolbar from '@/components/custom-toolbar';
|
|
||||||
import '@/components/react-big-calendar.css';
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
|
|
||||||
import { useGetApiCalendar } from '@/generated/api/calendar/calendar';
|
import { useGetApiCalendar } from '@/generated/api/calendar/calendar';
|
||||||
import { usePatchApiEventEventID } from '@/generated/api/event/event';
|
import { usePatchApiBlockedSlotsSlotID } from '@/generated/api/blocked-slots/blocked-slots';
|
||||||
import { UserCalendarSchemaItem } from '@/generated/api/meetup.schemas';
|
|
||||||
|
|
||||||
moment.updateLocale('en', {
|
moment.updateLocale('en', {
|
||||||
week: {
|
week: {
|
||||||
|
@ -49,6 +48,7 @@ const DaDRBCalendar = withDragAndDrop<
|
||||||
end: Date;
|
end: Date;
|
||||||
type: UserCalendarSchemaItem['type'];
|
type: UserCalendarSchemaItem['type'];
|
||||||
userId?: string;
|
userId?: string;
|
||||||
|
organizer?: string;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -192,6 +192,13 @@ function CalendarWithUserEvents({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const { mutate: patchBlockedSlot } = usePatchApiBlockedSlotsSlotID({
|
||||||
|
mutation: {
|
||||||
|
throwOnError(error) {
|
||||||
|
throw error.response?.data || 'Failed to update blocked slot';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DaDRBCalendar
|
<DaDRBCalendar
|
||||||
|
@ -220,11 +227,19 @@ function CalendarWithUserEvents({
|
||||||
end: new Date(event.end_time),
|
end: new Date(event.end_time),
|
||||||
type: event.type,
|
type: event.type,
|
||||||
userId: event.users[0],
|
userId: event.users[0],
|
||||||
|
organizer: event.type === 'event' ? event.organizer_id : undefined,
|
||||||
})) ?? []),
|
})) ?? []),
|
||||||
...(additionalEvents ?? []),
|
...(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(
|
||||||
|
@ -235,56 +250,108 @@ function CalendarWithUserEvents({
|
||||||
resourceTitleAccessor={(event) => event.title}
|
resourceTitleAccessor={(event) => event.title}
|
||||||
startAccessor={(event) => event.start}
|
startAccessor={(event) => event.start}
|
||||||
endAccessor={(event) => event.end}
|
endAccessor={(event) => event.end}
|
||||||
selectable={sesstion.data?.user?.id === userId && !additionalEvents}
|
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);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { NavigateAction } from 'react-big-calendar';
|
import './custom-toolbar.css';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
import DatePicker from 'react-datepicker';
|
import DatePicker from 'react-datepicker';
|
||||||
import 'react-datepicker/dist/react-datepicker.css';
|
import 'react-datepicker/dist/react-datepicker.css';
|
||||||
|
import { NavigateAction } from 'react-big-calendar';
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
|
|
||||||
import './custom-toolbar.css';
|
|
||||||
|
|
||||||
interface CustomToolbarProps {
|
interface CustomToolbarProps {
|
||||||
//Aktuell angezeigtes Datum
|
//Aktuell angezeigtes Datum
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { ChevronDown } from 'lucide-react';
|
|
||||||
import {
|
|
||||||
CalendarClock,
|
|
||||||
CalendarDays,
|
|
||||||
CalendarPlus,
|
|
||||||
Star,
|
|
||||||
User,
|
|
||||||
Users,
|
|
||||||
} from 'lucide-react';
|
|
||||||
import Link from 'next/link';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sidebar,
|
Sidebar,
|
||||||
SidebarContent,
|
SidebarContent,
|
||||||
|
@ -24,20 +13,34 @@ import {
|
||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from '@/components/custom-ui/sidebar';
|
} from '@/components/custom-ui/sidebar';
|
||||||
import Logo from '@/components/misc/logo';
|
|
||||||
|
import { CalendarMinus, CalendarMinus2, ChevronDown } from 'lucide-react';
|
||||||
import {
|
import {
|
||||||
Collapsible,
|
Collapsible,
|
||||||
CollapsibleContent,
|
CollapsibleContent,
|
||||||
CollapsibleTrigger,
|
CollapsibleTrigger,
|
||||||
} from '@/components/ui/collapsible';
|
} from '@/components/ui/collapsible';
|
||||||
|
|
||||||
|
import Logo from '@/components/misc/logo';
|
||||||
|
|
||||||
|
import Link from 'next/link';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Star,
|
||||||
|
CalendarDays,
|
||||||
|
//User,
|
||||||
|
//Users,
|
||||||
|
CalendarClock,
|
||||||
|
CalendarPlus,
|
||||||
|
} from 'lucide-react';
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
title: 'Calendar',
|
title: 'Calendar',
|
||||||
url: '/home',
|
url: '/home',
|
||||||
icon: CalendarDays,
|
icon: CalendarDays,
|
||||||
},
|
},
|
||||||
{
|
/*{
|
||||||
title: 'Friends',
|
title: 'Friends',
|
||||||
url: '#',
|
url: '#',
|
||||||
icon: User,
|
icon: User,
|
||||||
|
@ -46,12 +49,17 @@ const items = [
|
||||||
title: 'Groups',
|
title: 'Groups',
|
||||||
url: '#',
|
url: '#',
|
||||||
icon: Users,
|
icon: Users,
|
||||||
},
|
},*/
|
||||||
{
|
{
|
||||||
title: 'Events',
|
title: 'Events',
|
||||||
url: '/events',
|
url: '/events',
|
||||||
icon: CalendarClock,
|
icon: CalendarClock,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Blockers',
|
||||||
|
url: '/blocker',
|
||||||
|
icon: CalendarMinus,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function AppSidebar() {
|
export function AppSidebar() {
|
||||||
|
@ -59,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] overflow-hidden'>
|
<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
|
||||||
|
@ -120,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,24 +1,20 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useSession } from 'next-auth/react';
|
import { Card } from '@/components/ui/card';
|
||||||
|
import Logo from '@/components/misc/logo';
|
||||||
|
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 Logo from '@/components/misc/logo';
|
|
||||||
import { Card } from '@/components/ui/card';
|
|
||||||
import { Label } from '@/components/ui/label';
|
|
||||||
|
|
||||||
import { EventSchema } from '@/app/api/event/validation';
|
import { EventSchema } from '@/app/api/event/validation';
|
||||||
|
import { useSession } from 'next-auth/react';
|
||||||
import { usePatchApiEventEventIDParticipantUser } from '@/generated/api/event-participant/event-participant';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from '@/components/ui/select';
|
} from '../ui/select';
|
||||||
|
import { usePatchApiEventEventIDParticipantUser } from '@/generated/api/event-participant/event-participant';
|
||||||
|
|
||||||
type EventListEntryProps = zod.output<typeof EventSchema>;
|
type EventListEntryProps = zod.output<typeof EventSchema>;
|
||||||
|
|
||||||
|
@ -47,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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -1,21 +1,32 @@
|
||||||
|
import React from 'react';
|
||||||
|
import Image from 'next/image';
|
||||||
import { user_default_dark } from '@/assets/usericon/default/defaultusericon-export';
|
import { user_default_dark } from '@/assets/usericon/default/defaultusericon-export';
|
||||||
import { user_default_light } from '@/assets/usericon/default/defaultusericon-export';
|
import { user_default_light } from '@/assets/usericon/default/defaultusericon-export';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import Image from 'next/image';
|
|
||||||
import React from 'react';
|
|
||||||
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,
|
||||||
status,
|
status,
|
||||||
}: ParticipantListEntryProps) {
|
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;
|
||||||
|
|
||||||
|
@ -23,7 +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>
|
||||||
<span className='text-sm text-gray-500'>{status}</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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useIsMobile } from '@/hooks/use-mobile';
|
|
||||||
import { Slot } from '@radix-ui/react-slot';
|
|
||||||
import { VariantProps, cva } from 'class-variance-authority';
|
|
||||||
import { PanelLeftIcon } from 'lucide-react';
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { Slot } from '@radix-ui/react-slot';
|
||||||
|
import { cva, VariantProps } from 'class-variance-authority';
|
||||||
|
import { PanelLeftIcon } from 'lucide-react';
|
||||||
|
|
||||||
|
import { useIsMobile } from '@/hooks/use-mobile';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
|
@ -24,8 +25,6 @@ import {
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from '@/components/ui/tooltip';
|
} from '@/components/ui/tooltip';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
|
||||||
|
|
||||||
const SIDEBAR_COOKIE_NAME = 'sidebar_state';
|
const SIDEBAR_COOKIE_NAME = 'sidebar_state';
|
||||||
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
||||||
const SIDEBAR_WIDTH = '16rem';
|
const SIDEBAR_WIDTH = '16rem';
|
||||||
|
|
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>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,30 +1,26 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
import { useSearchParams } from 'next/navigation';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { toast } from 'sonner';
|
|
||||||
import zod from 'zod/v4';
|
|
||||||
|
|
||||||
import Calendar from '@/components/calendar';
|
|
||||||
import LabeledInput from '@/components/custom-ui/labeled-input';
|
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||||
import Logo from '@/components/misc/logo';
|
|
||||||
import { ToastInner } from '@/components/misc/toast-inner';
|
|
||||||
import { UserSearchInput } from '@/components/misc/user-search';
|
|
||||||
import TimePicker from '@/components/time-picker';
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import Logo from '@/components/misc/logo';
|
||||||
|
import TimePicker from '@/components/time-picker';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { PublicUserSchema } from '@/app/api/user/validation';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
usePostApiEvent,
|
||||||
useGetApiEventEventID,
|
useGetApiEventEventID,
|
||||||
usePatchApiEventEventID,
|
usePatchApiEventEventID,
|
||||||
usePostApiEvent,
|
|
||||||
} from '@/generated/api/event/event';
|
} from '@/generated/api/event/event';
|
||||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
import { ToastInner } from '@/components/misc/toast-inner';
|
||||||
|
import { UserSearchInput } from '@/components/misc/user-search';
|
||||||
|
import ParticipantListEntry from '../custom-ui/participant-list-entry';
|
||||||
|
|
||||||
import ParticipantListEntry from '@/components/custom-ui/participant-list-entry';
|
import { useSearchParams } from 'next/navigation';
|
||||||
|
|
||||||
|
import zod from 'zod/v4';
|
||||||
|
import { PublicUserSchema } from '@/app/api/user/validation';
|
||||||
|
import Calendar from '@/components/calendar';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
@ -33,7 +29,8 @@ import {
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from '@/components/ui/dialog';
|
} from '../ui/dialog';
|
||||||
|
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||||
|
|
||||||
type User = zod.output<typeof PublicUserSchema>;
|
type User = zod.output<typeof PublicUserSchema>;
|
||||||
|
|
||||||
|
@ -54,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('');
|
||||||
|
@ -85,22 +84,24 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
||||||
|
|
||||||
// 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('');
|
||||||
|
@ -111,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();
|
||||||
|
@ -153,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,
|
||||||
|
@ -165,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'
|
||||||
/>
|
/>
|
||||||
|
@ -185,207 +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 (
|
||||||
<>
|
<Dialog open={calendarOpen} onOpenChange={setCalendarOpen}>
|
||||||
<Dialog open={calendarOpen} onOpenChange={setCalendarOpen}>
|
<form
|
||||||
<form className='flex flex-col gap-5 w-full' onSubmit={handleSubmit}>
|
className='flex flex-col gap-5 w-full'
|
||||||
<div className='grid grid-row-start:auto gap-4 sm:gap-8 w-full'>
|
onSubmit={handleSubmit}
|
||||||
<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'>
|
data-cy='event-form'
|
||||||
<div className='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
>
|
||||||
<Logo colorType='monochrome' logoType='submark' width={50} />
|
<div className='grid grid-row-start:auto gap-4 sm:gap-8 w-full'>
|
||||||
</div>
|
<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'>
|
||||||
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full'>
|
<div className='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||||
<LabeledInput
|
<Logo colorType='monochrome' logoType='submark' width={50} />
|
||||||
type='text'
|
|
||||||
label='Event Name'
|
|
||||||
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>
|
||||||
<div className='grid grid-cols-4 gap-4 h-full w-full max-lg:grid-cols-2 max-sm:grid-cols-1'>
|
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full'>
|
||||||
<div>
|
<LabeledInput
|
||||||
<TimePicker
|
type='text'
|
||||||
dateLabel='start Time'
|
label='Event Name'
|
||||||
timeLabel=' '
|
placeholder={
|
||||||
date={startDate}
|
props.type === 'create' ? 'New Event' : 'Event Name'
|
||||||
setDate={setStartDate}
|
}
|
||||||
time={startTime}
|
name='eventName'
|
||||||
setTime={setStartTime}
|
variantSize='big'
|
||||||
/>
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
data-cy='event-name-input'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='w-0 sm:w-[50px]'></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>
|
||||||
|
<TimePicker
|
||||||
|
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'>
|
||||||
|
<Label className='w-[70px]'>created:</Label>
|
||||||
|
<Label className='text-[var(--color-neutral-300)]'>
|
||||||
|
{createdAtDisplay}
|
||||||
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className='flex flex-row gap-2'>
|
||||||
<TimePicker
|
<Label className='w-[70px]'>updated:</Label>
|
||||||
dateLabel='end Time'
|
<p className='text-[var(--color-neutral-300)]'>
|
||||||
timeLabel=' '
|
{updatedAtDisplay}
|
||||||
date={endDate}
|
</p>
|
||||||
setDate={setEndDate}
|
|
||||||
time={endTime}
|
|
||||||
setTime={setEndTime}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className='w-54'>
|
</div>
|
||||||
<LabeledInput
|
</div>
|
||||||
type='text'
|
<div className='h-full w-full grid grid-cols-2 gap-4 max-sm:grid-cols-1'>
|
||||||
label='Location'
|
<div className='h-full w-full grid grid-flow-row gap-4'>
|
||||||
placeholder='where is the event?'
|
<div className='h-full w-full'>
|
||||||
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'>
|
<div className='flex flex-row gap-2'>
|
||||||
<Label className='w-[70px]'>created:</Label>
|
<Label>Organiser:</Label>
|
||||||
<Label className='text-[var(--color-neutral-300)]'>
|
|
||||||
{createdAtDisplay}
|
|
||||||
</Label>
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-row gap-2'>
|
|
||||||
<Label className='w-[70px]'>updated:</Label>
|
|
||||||
<p className='text-[var(--color-neutral-300)]'>
|
<p className='text-[var(--color-neutral-300)]'>
|
||||||
{updatedAtDisplay}
|
{!isClient || isLoading
|
||||||
|
? 'Loading...'
|
||||||
|
: data?.data.user.name || 'Unknown User'}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
|
||||||
<Label className='text-[var(--color-neutral-300)]'>
|
|
||||||
{organiserValue}
|
|
||||||
</Label>
|
|
||||||
</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)}
|
|
||||||
></LabeledInput>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='h-full w-full'>
|
<div className='h-full w-full'>
|
||||||
<Label>Participants</Label>
|
<LabeledInput
|
||||||
<UserSearchInput
|
type='text'
|
||||||
selectedUsers={selectedParticipants}
|
label='Event Description'
|
||||||
addUserAction={(user) => {
|
placeholder='What is the event about?'
|
||||||
setSelectedParticipants((current) =>
|
name='eventDescription'
|
||||||
current.find((u) => u.id === user.id)
|
variantSize='textarea'
|
||||||
? current
|
value={description}
|
||||||
: [...current, user],
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
);
|
data-cy='event-description-input'
|
||||||
}}
|
></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 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>
|
</div>
|
||||||
|
<div className='h-full w-full'>
|
||||||
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
<Label>Participants</Label>
|
||||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
<UserSearchInput
|
||||||
<Button
|
selectedUsers={selectedParticipants}
|
||||||
type='button'
|
addUserAction={(user) => {
|
||||||
variant='secondary'
|
setSelectedParticipants((current) =>
|
||||||
onClick={() => {
|
current.find((u) => u.id === user.id)
|
||||||
router.back();
|
? current
|
||||||
console.log('user aborted - no change in database');
|
: [...current, user],
|
||||||
}}
|
);
|
||||||
>
|
}}
|
||||||
cancel
|
removeUserAction={(user) => {
|
||||||
</Button>
|
setSelectedParticipants((current) =>
|
||||||
</div>
|
current.filter((u) => u.id !== user.id),
|
||||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
);
|
||||||
<Button
|
}}
|
||||||
type='submit'
|
/>
|
||||||
variant='primary'
|
<DialogTrigger asChild>
|
||||||
disabled={status === 'pending'}
|
<Button variant='primary'>Calendar</Button>
|
||||||
>
|
</DialogTrigger>
|
||||||
{status === 'pending' ? 'Saving...' : 'save event'}
|
<div className='grid grid-cols-1 mt-3'>
|
||||||
</Button>
|
{selectedParticipants.map((user) => (
|
||||||
|
<ParticipantListEntry
|
||||||
|
key={user.id}
|
||||||
|
user={user}
|
||||||
|
status='PENDING'
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{isSuccess && <p>Event created!</p>}
|
|
||||||
{error && <p className='text-red-500'>Error: {error.message}</p>}
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
<DialogContent className='sm:max-w-[750px]'>
|
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
||||||
<DialogHeader>
|
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||||
<DialogTitle>Calendar</DialogTitle>
|
<Button
|
||||||
<DialogDescription>
|
type='button'
|
||||||
Calendar for selected participants
|
variant='secondary'
|
||||||
</DialogDescription>
|
onClick={() => {
|
||||||
</DialogHeader>
|
router.back();
|
||||||
<DialogFooter className='max-w-[calc(100svw-70px)]'>
|
console.log('user aborted - no change in database');
|
||||||
<Calendar
|
}}
|
||||||
userId={selectedParticipants.map((u) => u.id)}
|
>
|
||||||
additionalEvents={[
|
cancel
|
||||||
{
|
</Button>
|
||||||
id: 'temp-event',
|
</div>
|
||||||
title: title || 'New Event',
|
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||||
start: startDate ? new Date(startDate) : new Date(),
|
<Button
|
||||||
end: endDate ? new Date(endDate) : new Date(),
|
type='submit'
|
||||||
type: 'event',
|
variant='primary'
|
||||||
userId: 'create-event',
|
disabled={status === 'pending'}
|
||||||
colorOverride: '#ff9800',
|
data-cy='event-save-button'
|
||||||
},
|
>
|
||||||
]}
|
{status === 'pending' ? 'Saving...' : 'save event'}
|
||||||
height='600px'
|
</Button>
|
||||||
/>
|
</div>
|
||||||
</DialogFooter>
|
</div>
|
||||||
</DialogContent>
|
{isSuccess && <p>Event created!</p>}
|
||||||
</Dialog>
|
{error && <p className='text-red-500'>Error: {error.message}</p>}
|
||||||
</>
|
</div>
|
||||||
|
</form>
|
||||||
|
<DialogContent className='sm:max-w-[750px]'>
|
||||||
|
<DialogHeader>
|
||||||
|
<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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState, useRef } from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import React, { useRef, useState } from 'react';
|
|
||||||
|
|
||||||
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 { 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 { loginSchema, registerSchema } from '@/lib/auth/validation';
|
import { IconButton } from '../buttons/icon-button';
|
||||||
import useZodForm from '@/lib/hooks/useZodForm';
|
import {
|
||||||
|
FileKey,
|
||||||
|
FileKey2,
|
||||||
|
LogIn,
|
||||||
|
MailOpen,
|
||||||
|
RotateCcwKey,
|
||||||
|
UserCheck,
|
||||||
|
UserPen,
|
||||||
|
UserPlus,
|
||||||
|
} from 'lucide-react';
|
||||||
|
|
||||||
function LoginFormElement({
|
function LoginFormElement({
|
||||||
setIsSignUp,
|
setIsSignUp,
|
||||||
|
@ -57,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')}
|
||||||
|
@ -65,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={() => {
|
||||||
|
@ -82,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 && (
|
||||||
|
@ -157,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}
|
||||||
|
@ -187,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}
|
||||||
|
@ -194,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 && (
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { BellRing, Inbox } from 'lucide-react';
|
|
||||||
|
|
||||||
import { NotificationButton } from '@/components/buttons/notification-button';
|
|
||||||
import { SidebarTrigger } from '@/components/custom-ui/sidebar';
|
import { SidebarTrigger } from '@/components/custom-ui/sidebar';
|
||||||
import { ThemePicker } from '@/components/misc/theme-picker';
|
import { ThemePicker } from '@/components/misc/theme-picker';
|
||||||
|
import { NotificationButton } from '@/components/buttons/notification-button';
|
||||||
|
|
||||||
|
import { BellRing, Inbox } from 'lucide-react';
|
||||||
import UserDropdown from '@/components/misc/user-dropdown';
|
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'
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import Image, { ImageProps } from 'next/image';
|
||||||
|
|
||||||
import * as logoAssets from '@/assets/logo/logo-export';
|
import * as logoAssets from '@/assets/logo/logo-export';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import Image, { ImageProps } from 'next/image';
|
|
||||||
import React, { useEffect, useState } from 'react';
|
|
||||||
|
|
||||||
type ColorType = 'colored' | 'monochrome';
|
type ColorType = 'colored' | 'monochrome';
|
||||||
type LogoType = 'combo' | 'primary' | 'secondary' | 'submark';
|
type LogoType = 'combo' | 'primary' | 'secondary' | 'submark';
|
||||||
|
|
|
@ -9,12 +9,6 @@ import {
|
||||||
Sparkles,
|
Sparkles,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
|
|
||||||
import {
|
|
||||||
SidebarMenu,
|
|
||||||
SidebarMenuButton,
|
|
||||||
SidebarMenuItem,
|
|
||||||
useSidebar,
|
|
||||||
} from '@/components/custom-ui/sidebar';
|
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
|
@ -25,6 +19,12 @@ import {
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/components/ui/dropdown-menu';
|
} from '@/components/ui/dropdown-menu';
|
||||||
|
import {
|
||||||
|
SidebarMenu,
|
||||||
|
SidebarMenuButton,
|
||||||
|
SidebarMenuItem,
|
||||||
|
useSidebar,
|
||||||
|
} from '@/components/custom-ui/sidebar';
|
||||||
|
|
||||||
export function NavUser({
|
export function NavUser({
|
||||||
user,
|
user,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { type VariantProps, cva } from 'class-variance-authority';
|
|
||||||
import { CircleSmall } from 'lucide-react';
|
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
|
import { CircleSmall } from 'lucide-react';
|
||||||
|
|
||||||
const dotVariants = cva('', {
|
const dotVariants = cva('', {
|
||||||
variants: {
|
variants: {
|
||||||
|
|
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>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { ThemePicker } from '@/components/misc/theme-picker';
|
import { ThemePicker } from '@/components/misc/theme-picker';
|
||||||
import { ThemeProvider } from '@/components/wrappers/theme-provider';
|
import { ThemeProvider } from '@/components/wrappers/theme-provider';
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
import { Moon, Sun } from 'lucide-react';
|
import { Moon, Sun } from 'lucide-react';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -39,54 +39,12 @@ import { Button } from '@/components/ui/button';
|
||||||
|
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { toast } from 'sonner';
|
||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
import * as Icons from 'lucide-react';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { toast } from 'sonner';
|
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
/*
|
|
||||||
USAGE:
|
|
||||||
|
|
||||||
import { ToastInner } from '@/components/misc/toast-inner';
|
|
||||||
|
|
||||||
|
|
||||||
<Button
|
|
||||||
variant='outline_primary'
|
|
||||||
onClick={() =>
|
|
||||||
|
|
||||||
|
|
||||||
toast.custom(
|
|
||||||
(t) => (
|
|
||||||
<ToastInner
|
|
||||||
toastId={t}
|
|
||||||
title=''
|
|
||||||
description=''
|
|
||||||
onAction={() => console.log('on Action')} //No Button shown if this is null
|
|
||||||
variant=''default' | 'success' | 'error' | 'info' | 'warning' | 'notification''
|
|
||||||
buttonText=[No Button shown if this is null]
|
|
||||||
iconName=[Any Icon Name from Lucide in UpperCamelCase or default if null]
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
duration: 5000,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Show Toast
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { toast } from 'sonner';
|
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import * as Icons from 'lucide-react';
|
||||||
|
|
||||||
interface ToastInnerProps {
|
interface ToastInnerProps {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import { User } from 'lucide-react';
|
|
||||||
import Image from 'next/image';
|
|
||||||
|
|
||||||
import { Avatar } from '@/components/ui/avatar';
|
|
||||||
|
|
||||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||||
|
import { Avatar } from '@/components/ui/avatar';
|
||||||
|
import Image from 'next/image';
|
||||||
|
import { User } from 'lucide-react';
|
||||||
|
|
||||||
export default function UserCard() {
|
export default function UserCard() {
|
||||||
const { data } = useGetApiUserMe();
|
const { data } = useGetApiUserMe();
|
||||||
|
@ -23,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>
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { ChevronDown, User } from 'lucide-react';
|
|
||||||
import Image from 'next/image';
|
|
||||||
import Link from 'next/link';
|
|
||||||
|
|
||||||
import UserCard from '@/components/misc/user-card';
|
|
||||||
import { Avatar } from '@/components/ui/avatar';
|
import { Avatar } from '@/components/ui/avatar';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
|
@ -14,11 +9,15 @@ import {
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/components/ui/dropdown-menu';
|
} from '@/components/ui/dropdown-menu';
|
||||||
|
|
||||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||||
|
import { ChevronDown, User } from 'lucide-react';
|
||||||
|
import Image from 'next/image';
|
||||||
|
import Link from 'next/link';
|
||||||
|
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>
|
||||||
|
@ -43,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>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import zod from 'zod/v4';
|
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||||
|
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
|
@ -18,12 +18,9 @@ import {
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from '@/components/ui/popover';
|
} from '@/components/ui/popover';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
|
||||||
|
|
||||||
import { PublicUserSchema } from '@/app/api/user/validation';
|
|
||||||
|
|
||||||
import { useGetApiSearchUser } from '@/generated/api/search/search';
|
import { useGetApiSearchUser } from '@/generated/api/search/search';
|
||||||
|
import zod from 'zod/v4';
|
||||||
|
import { PublicUserSchema } from '@/app/api/user/validation';
|
||||||
|
|
||||||
type User = zod.output<typeof PublicUserSchema>;
|
type User = zod.output<typeof PublicUserSchema>;
|
||||||
|
|
||||||
|
|
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>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { ChevronDownIcon } from 'lucide-react';
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { ChevronDownIcon } from 'lucide-react';
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Calendar } from '@/components/ui/calendar';
|
import { Calendar } from '@/components/ui/calendar';
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Slot } from '@radix-ui/react-slot';
|
|
||||||
import { type VariantProps, cva } from 'class-variance-authority';
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { Slot } from '@radix-ui/react-slot';
|
||||||
|
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: {
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
import {
|
import {
|
||||||
ChevronDownIcon,
|
ChevronDownIcon,
|
||||||
ChevronLeftIcon,
|
ChevronLeftIcon,
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import * as React from 'react';
|
|
||||||
import { DayButton, DayPicker, getDefaultClassNames } from 'react-day-picker';
|
import { DayButton, DayPicker, getDefaultClassNames } from 'react-day-picker';
|
||||||
|
|
||||||
import { Button, buttonVariants } from '@/components/ui/button';
|
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
import { Button, buttonVariants } from '@/components/ui/button';
|
||||||
|
|
||||||
function Calendar({
|
function Calendar({
|
||||||
className,
|
className,
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue