Compare commits
3 commits
main
...
style/new_
Author | SHA1 | Date | |
---|---|---|---|
ce7e1f2952 | |||
2a2c4bc967 | |||
657a64ca7f |
125 changed files with 1643 additions and 3625 deletions
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
@ -10,7 +10,7 @@ jobs:
|
|||
name: Tests
|
||||
runs-on: docker
|
||||
container:
|
||||
image: cypress/browsers:latest@sha256:95587c1ce688ce6f59934cc234a753a32a1782ca1c7959707a7d2332e69f6f63
|
||||
image: cypress/browsers:latest@sha256:9daea41366dfd1b72496bf3e8295eda215a6990c2dbe4f9ff4b8ba47342864fb
|
||||
options: --user 1001
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
|
@ -1,4 +1,21 @@
|
|||
{
|
||||
"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,8 +9,5 @@ export default defineConfig({
|
|||
},
|
||||
|
||||
e2e: {
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
12
cypress/e2e/auth-user.ts
Normal file
12
cypress/e2e/auth-user.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
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,40 +1,9 @@
|
|||
import authUser from './auth-user';
|
||||
|
||||
describe('event creation', () => {
|
||||
it('loads', () => {
|
||||
cy.login();
|
||||
authUser();
|
||||
|
||||
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');
|
||||
// cy.visit('http://127.0.0.1:3000/events/new'); // TODO: Add event creation tests
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths
|
||||
import { PrismaClient } from '../../src/generated/prisma';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************
|
||||
// This example commands.ts shows you how to
|
||||
|
@ -46,22 +46,6 @@ Cypress.Commands.add('getBySelLike', (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 {
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
|
@ -73,7 +57,6 @@ declare global {
|
|||
selector: string,
|
||||
...args: any[]
|
||||
): Chainable<JQuery<HTMLElement>>;
|
||||
login(): Chainable<void>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
// ***********************************************************
|
||||
// This example support/component.ts is processed and
|
||||
// loaded automatically before your test files.
|
||||
|
@ -12,14 +13,13 @@
|
|||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
import { mount } from 'cypress/react';
|
||||
|
||||
import '@/app/globals.css';
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands';
|
||||
|
||||
import { mount } from 'cypress/react';
|
||||
|
||||
// Augment the Cypress namespace to include type definitions for
|
||||
// your custom command.
|
||||
// Alternatively, can be defined in cypress/support/component.d.ts
|
||||
|
|
|
@ -12,6 +12,5 @@
|
|||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands';
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { FlatCompat } from '@eslint/eslintrc';
|
||||
import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths';
|
||||
import { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { FlatCompat } from '@eslint/eslintrc';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
@ -14,6 +15,21 @@ const eslintConfig = [
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { registry } from '@/lib/swagger';
|
||||
import { OpenApiGeneratorV3 } from '@asteasolutions/zod-to-openapi';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { registry } from '@/lib/swagger';
|
||||
|
||||
function recursiveFileSearch(dir: string, fileList: string[] = []): string[] {
|
||||
const files = fs.readdirSync(dir);
|
||||
files.forEach((file) => {
|
||||
|
|
|
@ -6,7 +6,7 @@ const nextConfig: NextConfig = {
|
|||
remotePatterns: [
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'i.gifer.com',
|
||||
hostname: 'img1.wikia.nocookie.net',
|
||||
port: '',
|
||||
pathname: '/**',
|
||||
},
|
||||
|
|
10
package.json
10
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "meetup",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev --turbopack",
|
||||
|
@ -73,17 +73,19 @@
|
|||
"devDependencies": {
|
||||
"@eslint/eslintrc": "3.3.1",
|
||||
"@tailwindcss/postcss": "4.1.11",
|
||||
"@types/node": "22.16.0",
|
||||
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
||||
"@types/node": "22.15.34",
|
||||
"@types/react": "19.1.8",
|
||||
"@types/react-big-calendar": "1.16.2",
|
||||
"@types/react-dom": "19.1.6",
|
||||
"@types/swagger-ui-react": "5.18.0",
|
||||
"@types/webpack-env": "1.18.8",
|
||||
"cypress": "14.5.1",
|
||||
"cypress": "14.5.0",
|
||||
"dotenv-cli": "8.0.0",
|
||||
"eslint": "9.30.1",
|
||||
"eslint": "9.30.0",
|
||||
"eslint-config-next": "15.3.4",
|
||||
"eslint-config-prettier": "10.1.5",
|
||||
"eslint-plugin-no-relative-import-paths": "^1.6.1",
|
||||
"orval": "7.10.0",
|
||||
"postcss": "8.5.6",
|
||||
"prettier": "3.6.2",
|
||||
|
|
|
@ -1,170 +0,0 @@
|
|||
-- 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;
|
|
@ -1,10 +0,0 @@
|
|||
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} />;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
import BlockedSlotForm from '@/components/forms/blocked-slot-form';
|
||||
|
||||
export default function NewBlockedSlotPage() {
|
||||
return <BlockedSlotForm />;
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
'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,20 +1,16 @@
|
|||
'use client';
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import Logo from '@/components/misc/logo';
|
||||
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 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 { ToastInner } from '@/components/misc/toast-inner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
|
@ -24,6 +20,13 @@ import {
|
|||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} 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() {
|
||||
const session = useSession();
|
||||
|
@ -34,21 +37,27 @@ export default function ShowEvent() {
|
|||
|
||||
// Fetch event data
|
||||
const { data: eventData, isLoading, error } = useGetApiEventEventID(eventID);
|
||||
const { data: userData, isLoading: userLoading } = useGetApiUserMe();
|
||||
const deleteEvent = useDeleteApiEventEventID();
|
||||
|
||||
if (isLoading) {
|
||||
if (isLoading || userLoading) {
|
||||
return (
|
||||
<div className='flex justify-center items-center h-full'>Loading...</div>
|
||||
<div className='flex justify-center items-center h-screen'>
|
||||
Loading...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (error || !eventData?.data?.event) {
|
||||
return (
|
||||
<div className='flex justify-center items-center h-full'>
|
||||
<div className='flex justify-center items-center h-screen'>
|
||||
Error loading event.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const event = eventData.data.event;
|
||||
const organiserName = userData?.data.user?.name || 'Unknown User';
|
||||
|
||||
// Format dates & times for display
|
||||
const formatDate = (isoString?: string) => {
|
||||
if (!isoString) return '-';
|
||||
|
@ -63,186 +72,167 @@ export default function ShowEvent() {
|
|||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<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' />
|
||||
<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>
|
||||
<div className='flex flex-col gap-5 w-full'>
|
||||
<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='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'>
|
||||
{eventData.data.event.title || 'Untitled Event'}
|
||||
</h1>
|
||||
</div>
|
||||
<div className='w-0 sm:w-[100px]'></div>
|
||||
<CardContent>
|
||||
<div className='flex flex-col gap-5 w-full'>
|
||||
<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='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||
<Logo colorType='monochrome' logoType='submark' width={50} />
|
||||
</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'>
|
||||
{eventData.data.event.start_time
|
||||
? `${formatDate(eventData.data.event.start_time)} ${formatTime(eventData.data.event.start_time)}`
|
||||
: '-'}
|
||||
</Label>
|
||||
</div>
|
||||
<div>
|
||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||
end Time
|
||||
</Label>
|
||||
<Label size='large'>
|
||||
{eventData.data.event.end_time
|
||||
? `${formatDate(eventData.data.event.end_time)} ${formatTime(eventData.data.event.end_time)}`
|
||||
: '-'}
|
||||
</Label>
|
||||
</div>
|
||||
<div className='w-54'>
|
||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||
Location
|
||||
</Label>
|
||||
<Label size='large'>
|
||||
{eventData.data.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>
|
||||
{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>
|
||||
</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'>
|
||||
<h1 className='text-center'>
|
||||
{event.title || 'Untitled Event'}
|
||||
</h1>
|
||||
</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'>
|
||||
Participants
|
||||
</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 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 className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
||||
<div className='w-[20%] grid max-sm:w-full'>
|
||||
{session.data?.user?.id ===
|
||||
eventData.data.event.organizer.id ? (
|
||||
<Dialog
|
||||
open={deleteDialogOpen}
|
||||
onOpenChange={setDeleteDialogOpen}
|
||||
>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant='destructive' className='w-full'>
|
||||
delete
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Delete Event</DialogTitle>
|
||||
<DialogDescription>
|
||||
Are you sure you want to delete the event “
|
||||
{eventData.data.event.title}”? This action
|
||||
cannot be undone.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
variant='secondary'
|
||||
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);
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
) : null}
|
||||
<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>
|
||||
{event.created_at ? formatDate(event.created_at) : '-'}
|
||||
</Label>
|
||||
</div>
|
||||
<div className='w-[20%] grid max-sm:w-full'>
|
||||
{session.data?.user?.id ===
|
||||
eventData.data.event.organizer.id ? (
|
||||
<RedirectButton
|
||||
redirectUrl={`/events/edit/${eventID}`}
|
||||
buttonText='edit'
|
||||
className='w-full'
|
||||
/>
|
||||
) : null}
|
||||
<div className='flex flex-row gap-2'>
|
||||
<Label className='w-[70px] text-[var(--color-neutral-300)]'>
|
||||
updated:
|
||||
</Label>
|
||||
<Label>
|
||||
{event.updated_at ? formatDate(event.updated_at) : '-'}
|
||||
</Label>
|
||||
</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 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'>{organiserName}</Label>
|
||||
</div>
|
||||
</div>
|
||||
<div className='h-full w-full'>
|
||||
<Label className='text-[var(--color-neutral-300)] mb-2'>
|
||||
Description
|
||||
</Label>
|
||||
<Label size='large'>{event.description || '-'}</Label>
|
||||
</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='w-[20%] grid max-sm:w-full'>
|
||||
{session.data?.user?.id === event.organizer.id ? (
|
||||
<Dialog
|
||||
open={deleteDialogOpen}
|
||||
onOpenChange={setDeleteDialogOpen}
|
||||
>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant='destructive' className='w-full'>
|
||||
delete
|
||||
</Button>
|
||||
</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
|
||||
variant='muted'
|
||||
onClick={() => {
|
||||
deleteEvent.mutate(
|
||||
{ eventID: event.id },
|
||||
{
|
||||
onSuccess: () => {
|
||||
router.push('/home');
|
||||
toast.custom((t) => (
|
||||
<ToastInner
|
||||
toastId={t}
|
||||
title='Event deleted'
|
||||
description={event?.title}
|
||||
variant='success'
|
||||
/>
|
||||
));
|
||||
},
|
||||
},
|
||||
);
|
||||
setDeleteDialogOpen(false);
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
) : null}
|
||||
</div>
|
||||
<div className='w-[20%] grid max-sm:w-full'>
|
||||
{session.data?.user?.id === event.organizer.id ? (
|
||||
<RedirectButton
|
||||
redirectUrl={`/events/edit/${eventID}`}
|
||||
buttonText='edit'
|
||||
className='w-full'
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
import EventForm from '@/components/forms/event-form';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
import EventForm from '@/components/forms/event-form';
|
||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
}: {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
import EventForm from '@/components/forms/event-form';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
import EventForm from '@/components/forms/event-form';
|
||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
|
||||
export default function NewEvent() {
|
||||
return (
|
||||
<div className='flex flex-col items-center justify-center h-full'>
|
||||
<div className='flex flex-col items-center justify-center h-screen'>
|
||||
<Card className='w-[80%] max-w-screen p-0 gap-0 max-xl:w-[95%] max-h-[90vh] overflow-auto'>
|
||||
<CardHeader className='p-0 m-0 gap-0' />
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import { RedirectButton } from '@/components/buttons/redirect-button';
|
||||
import EventListEntry from '@/components/custom-ui/event-list-entry';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { useGetApiEvent } from '@/generated/api/event/event';
|
||||
|
||||
export default function Events() {
|
||||
|
@ -17,10 +18,7 @@ export default function Events() {
|
|||
const events = eventsData?.data?.events || [];
|
||||
|
||||
return (
|
||||
<div
|
||||
className='relative h-full flex flex-col items-center'
|
||||
data-cy='events-page'
|
||||
>
|
||||
<div className='relative h-screen flex flex-col items-center'>
|
||||
{/* Heading */}
|
||||
<h1 className='text-3xl font-bold mt-8 mb-4 text-center z-10'>
|
||||
My Events
|
||||
|
@ -28,7 +26,7 @@ export default function Events() {
|
|||
|
||||
{/* Scrollable event list */}
|
||||
<div className='w-full flex justify-center overflow-hidden'>
|
||||
<div className='grid gap-8 not-visited:p-6 overflow-y-auto'>
|
||||
<div className='grid gap-8 w-[90%] sm:w-[80%] lg:w-[60%] xl:w-[50%] p-6 overflow-y-auto'>
|
||||
{events.length > 0 ? (
|
||||
events.map((event) => (
|
||||
<EventListEntry
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use client';
|
||||
|
||||
import Calendar from '@/components/calendar';
|
||||
|
||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||
|
||||
export default function Home() {
|
||||
|
@ -14,9 +15,7 @@ export default function Home() {
|
|||
<span style={{ whiteSpace: 'nowrap' }}>
|
||||
{isLoading
|
||||
? 'Loading...'
|
||||
: data?.data.user?.first_name ||
|
||||
data?.data.user?.name ||
|
||||
'Unknown User'}{' '}
|
||||
: data?.data.user?.first_name || 'Unknown User'}{' '}
|
||||
👋
|
||||
</span>
|
||||
</h1>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import React from 'react';
|
||||
import { cookies } from 'next/headers';
|
||||
import React from 'react';
|
||||
|
||||
import { AppSidebar } from '@/components/custom-ui/app-sidebar';
|
||||
import SidebarProviderWrapper from '@/components/wrappers/sidebar-provider';
|
||||
import Header from '@/components/misc/header';
|
||||
import SidebarProviderWrapper from '@/components/wrappers/sidebar-provider';
|
||||
|
||||
export default async function Layout({
|
||||
children,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { getApiDocs } from '@/lib/swagger';
|
||||
|
||||
import ReactSwagger from './react-swagger';
|
||||
|
||||
export default async function IndexPage() {
|
||||
|
|
|
@ -1,165 +0,0 @@
|
|||
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,
|
||||
},
|
||||
);
|
||||
});
|
|
@ -1,90 +0,0 @@
|
|||
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'],
|
||||
});
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
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,
|
||||
});
|
||||
});
|
|
@ -1,66 +0,0 @@
|
|||
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'],
|
||||
});
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
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,19 +1,23 @@
|
|||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
import { z } from 'zod/v4';
|
||||
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
import {
|
||||
userCalendarQuerySchema,
|
||||
UserCalendarResponseSchema,
|
||||
UserCalendarSchema,
|
||||
} from './validation';
|
||||
|
||||
import {
|
||||
ErrorResponseSchema,
|
||||
ZodErrorResponseSchema,
|
||||
} 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) {
|
||||
const authCheck = userAuthenticated(req);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import {
|
||||
userCalendarQuerySchema,
|
||||
UserCalendarResponseSchema,
|
||||
} from './validation';
|
||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
|
||||
import {
|
||||
notAuthenticatedResponse,
|
||||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
|
||||
import {
|
||||
UserCalendarResponseSchema,
|
||||
userCalendarQuerySchema,
|
||||
} from './validation';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import {
|
||||
eventEndTimeSchema,
|
||||
EventSchema,
|
||||
eventEndTimeSchema,
|
||||
eventStartTimeSchema,
|
||||
} from '@/app/api/event/validation';
|
||||
|
||||
|
@ -48,7 +49,6 @@ export const VisibleSlotSchema = EventSchema.omit({
|
|||
type: zod.literal('event'),
|
||||
users: zod.string().array(),
|
||||
user_id: zod.string().optional(),
|
||||
organizer_id: zod.string().optional(),
|
||||
})
|
||||
.openapi('VisibleSlotSchema', {
|
||||
description: 'Visible time slot in the user calendar',
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
import { prisma } from '@/prisma';
|
||||
import { auth } from '@/auth';
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
|
||||
import {
|
||||
ErrorResponseSchema,
|
||||
SuccessResponseSchema,
|
||||
ZodErrorResponseSchema,
|
||||
} from '@/app/api/validation';
|
||||
|
||||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
|
||||
import {
|
||||
ParticipantResponseSchema,
|
||||
updateParticipantSchema,
|
||||
} from '../validation';
|
||||
} from '@/app/api/event/[eventID]/participant/validation';
|
||||
|
||||
export const GET = auth(async (req, { params }) => {
|
||||
const authCheck = userAuthenticated(req);
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import zod from 'zod/v4';
|
||||
import {
|
||||
ParticipantResponseSchema,
|
||||
updateParticipantSchema,
|
||||
} from '../validation';
|
||||
|
||||
import {
|
||||
invalidRequestDataResponse,
|
||||
notAuthenticatedResponse,
|
||||
serverReturnedDataValidationErrorResponse,
|
||||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
|
||||
import {
|
||||
EventIdParamSchema,
|
||||
UserIdParamSchema,
|
||||
SuccessResponseSchema,
|
||||
UserIdParamSchema,
|
||||
} from '@/app/api/validation';
|
||||
|
||||
import {
|
||||
ParticipantResponseSchema,
|
||||
updateParticipantSchema,
|
||||
} from '@/app/api/event/[eventID]/participant/validation';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
method: 'get',
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
import { prisma } from '@/prisma';
|
||||
import { auth } from '@/auth';
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
|
||||
import {
|
||||
ErrorResponseSchema,
|
||||
ZodErrorResponseSchema,
|
||||
} from '@/app/api/validation';
|
||||
|
||||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
|
||||
import {
|
||||
inviteParticipantSchema,
|
||||
ParticipantResponseSchema,
|
||||
ParticipantsResponseSchema,
|
||||
inviteParticipantSchema,
|
||||
} from './validation';
|
||||
|
||||
export const GET = auth(async (req, { params }) => {
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import zod from 'zod/v4';
|
||||
import {
|
||||
ParticipantsResponseSchema,
|
||||
ParticipantResponseSchema,
|
||||
inviteParticipantSchema,
|
||||
} from './validation';
|
||||
|
||||
import {
|
||||
invalidRequestDataResponse,
|
||||
notAuthenticatedResponse,
|
||||
serverReturnedDataValidationErrorResponse,
|
||||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
|
||||
import { EventIdParamSchema } from '@/app/api/validation';
|
||||
|
||||
import {
|
||||
ParticipantResponseSchema,
|
||||
ParticipantsResponseSchema,
|
||||
inviteParticipantSchema,
|
||||
} from './validation';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
method: 'get',
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import {
|
||||
existingUserIdServerSchema,
|
||||
PublicUserSchema,
|
||||
existingUserIdServerSchema,
|
||||
} from '@/app/api/user/validation';
|
||||
|
||||
extendZodWithOpenApi(zod);
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
import { prisma } from '@/prisma';
|
||||
import { auth } from '@/auth';
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
|
||||
import {
|
||||
EventResponseSchema,
|
||||
updateEventSchema,
|
||||
} from '@/app/api/event/validation';
|
||||
import {
|
||||
ErrorResponseSchema,
|
||||
SuccessResponseSchema,
|
||||
ZodErrorResponseSchema,
|
||||
} from '../../validation';
|
||||
import { EventResponseSchema } from '../validation';
|
||||
import { updateEventSchema } from '../validation';
|
||||
} from '@/app/api/validation';
|
||||
|
||||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
|
||||
export const GET = auth(async (req, { params }) => {
|
||||
const authCheck = userAuthenticated(req);
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import { EventResponseSchema, updateEventSchema } from '../validation';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import {
|
||||
invalidRequestDataResponse,
|
||||
notAuthenticatedResponse,
|
||||
serverReturnedDataValidationErrorResponse,
|
||||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
|
||||
import {
|
||||
EventIdParamSchema,
|
||||
SuccessResponseSchema,
|
||||
} from '@/app/api/validation';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import { EventResponseSchema, updateEventSchema } from '@/app/api/event/validation';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
import { prisma } from '@/prisma';
|
||||
import { auth } from '@/auth';
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
import { ErrorResponseSchema, ZodErrorResponseSchema } from '../validation';
|
||||
|
||||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
|
||||
import { ErrorResponseSchema, ZodErrorResponseSchema } from '@/app/api/validation';
|
||||
import {
|
||||
createEventSchema,
|
||||
EventResponseSchema,
|
||||
EventsResponseSchema,
|
||||
createEventSchema,
|
||||
} from './validation';
|
||||
|
||||
export const GET = auth(async (req) => {
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import {
|
||||
EventResponseSchema,
|
||||
EventsResponseSchema,
|
||||
createEventSchema,
|
||||
} from './validation';
|
||||
|
||||
import {
|
||||
invalidRequestDataResponse,
|
||||
notAuthenticatedResponse,
|
||||
|
@ -11,6 +7,12 @@ import {
|
|||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
|
||||
import {
|
||||
EventResponseSchema,
|
||||
EventsResponseSchema,
|
||||
createEventSchema,
|
||||
} from './validation';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
method: 'get',
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import {
|
||||
existingUserIdServerSchema,
|
||||
PublicUserSchema,
|
||||
} from '../user/validation';
|
||||
existingUserIdServerSchema,
|
||||
} from '@/app/api/user/validation';
|
||||
import { ParticipantSchema } from './[eventID]/participant/validation';
|
||||
|
||||
extendZodWithOpenApi(zod);
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
import { signOut } from '@/auth';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export const GET = async () => {
|
||||
await signOut();
|
||||
|
||||
return NextResponse.redirect('/login');
|
||||
};
|
|
@ -1,15 +1,18 @@
|
|||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
import { searchUserSchema, searchUserResponseSchema } from './validation';
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
|
||||
import {
|
||||
ErrorResponseSchema,
|
||||
ZodErrorResponseSchema,
|
||||
} 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) {
|
||||
const authCheck = userAuthenticated(req);
|
||||
if (!authCheck.continue)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import { searchUserResponseSchema, searchUserSchema } from './validation';
|
||||
|
||||
import {
|
||||
invalidRequestDataResponse,
|
||||
notAuthenticatedResponse,
|
||||
|
@ -7,6 +7,8 @@ import {
|
|||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
|
||||
import { searchUserResponseSchema, searchUserSchema } from './validation';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
method: 'get',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import zod from 'zod/v4';
|
||||
import { PublicUserSchema } from '../../user/validation';
|
||||
|
||||
import { PublicUserSchema } from '@/app/api/user/validation';
|
||||
|
||||
export const searchUserSchema = zod.object({
|
||||
query: zod.string().optional().default(''),
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
import { PublicUserResponseSchema } from '../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 }) {
|
||||
const authCheck = userAuthenticated(req);
|
||||
if (!authCheck.continue)
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { PublicUserResponseSchema } from '../validation';
|
||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import {
|
||||
notAuthenticatedResponse,
|
||||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import zod from 'zod/v4';
|
||||
import { UserIdParamSchema } from '../../validation';
|
||||
|
||||
import { UserIdParamSchema } from '@/app/api/validation';
|
||||
import { PublicUserResponseSchema } from '@/app/api/user/validation';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
import { updateUserPasswordServerSchema } from '../validation';
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
import { FullUserResponseSchema } from '../../validation';
|
||||
|
||||
import {
|
||||
ErrorResponseSchema,
|
||||
ZodErrorResponseSchema,
|
||||
} 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) {
|
||||
const authCheck = userAuthenticated(req);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import { FullUserResponseSchema } from '../../validation';
|
||||
import { updateUserPasswordServerSchema } from '../validation';
|
||||
|
||||
import {
|
||||
invalidRequestDataResponse,
|
||||
notAuthenticatedResponse,
|
||||
|
@ -8,6 +7,9 @@ import {
|
|||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
|
||||
import { FullUserResponseSchema } from '@/app/api/user/validation';
|
||||
import { updateUserPasswordServerSchema } from '@/app/api/user/me/validation';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
method: 'patch',
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
import { auth } from '@/auth';
|
||||
import { prisma } from '@/prisma';
|
||||
import { updateUserServerSchema } from './validation';
|
||||
import {
|
||||
returnZodTypeCheckedResponse,
|
||||
userAuthenticated,
|
||||
} from '@/lib/apiHelpers';
|
||||
import { FullUserResponseSchema } from '../validation';
|
||||
|
||||
import {
|
||||
ErrorResponseSchema,
|
||||
SuccessResponseSchema,
|
||||
ZodErrorResponseSchema,
|
||||
} 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) {
|
||||
const authCheck = userAuthenticated(req);
|
||||
if (!authCheck.continue)
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import { FullUserResponseSchema } from '../validation';
|
||||
import { updateUserServerSchema } from './validation';
|
||||
|
||||
import {
|
||||
invalidRequestDataResponse,
|
||||
notAuthenticatedResponse,
|
||||
serverReturnedDataValidationErrorResponse,
|
||||
userNotFoundResponse,
|
||||
} 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) {
|
||||
registry.registerPath({
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import zod from 'zod/v4';
|
||||
|
||||
import {
|
||||
emailSchema,
|
||||
firstNameSchema,
|
||||
lastNameSchema,
|
||||
newUserEmailServerSchema,
|
||||
newUserNameServerSchema,
|
||||
passwordSchema,
|
||||
timezoneSchema,
|
||||
userNameSchema,
|
||||
} from '@/app/api/user/validation';
|
||||
|
||||
// ----------------------------------------
|
||||
|
@ -24,15 +23,6 @@ export const updateUserServerSchema = zod.object({
|
|||
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
|
||||
.object({
|
||||
current_password: zod.string().min(1, 'Current password is required'),
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||
import { prisma } from '@/prisma';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import { allTimeZones } from '@/lib/timezones';
|
||||
|
||||
import { prisma } from '@/prisma';
|
||||
|
||||
extendZodWithOpenApi(zod);
|
||||
|
||||
// ----------------------------------------
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { registry } from '@/lib/swagger';
|
||||
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import { registry } from '@/lib/swagger';
|
||||
|
||||
extendZodWithOpenApi(zod);
|
||||
|
||||
export const ErrorResponseSchema = zod
|
||||
|
@ -85,14 +86,3 @@ export const EventIdParamSchema = registry.registerParameter(
|
|||
example: '67890',
|
||||
}),
|
||||
);
|
||||
|
||||
export const SlotIdParamSchema = registry.registerParameter(
|
||||
'SlotIdParam',
|
||||
zod.string().openapi({
|
||||
param: {
|
||||
name: 'slotID',
|
||||
in: 'path',
|
||||
},
|
||||
example: 'abcde12345',
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
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 type { Metadata } from 'next';
|
||||
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 = {
|
||||
title: 'MeetUp',
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
import { auth, providerMap } from '@/auth';
|
||||
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 { redirect } from 'next/navigation';
|
||||
|
||||
import SSOLogin from '@/components/buttons/sso-login-button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardHeader,
|
||||
} 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 { Button } from '@/components/ui/button';
|
||||
import {
|
||||
HoverCard,
|
||||
HoverCardTrigger,
|
||||
HoverCardContent,
|
||||
HoverCardTrigger,
|
||||
} from '@/components/ui/hover-card';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
|
||||
import { auth, providerMap } from '@/auth';
|
||||
|
||||
export default async function LoginPage() {
|
||||
const session = await auth();
|
||||
|
@ -42,9 +44,7 @@ export default async function LoginPage() {
|
|||
<CardContent className='gap-6 flex flex-col items-center'>
|
||||
<LoginForm />
|
||||
|
||||
{providerMap.length > 0 && !process.env.DISABLE_PASSWORD_LOGIN ? (
|
||||
<Separator className='h-[1px] rounded-sm w-[60%] bg-border' />
|
||||
) : null}
|
||||
<Separator className='h-[1px] rounded-sm w-[60%] bg-border' />
|
||||
|
||||
{providerMap.map((provider) => (
|
||||
<SSOLogin
|
||||
|
@ -63,11 +63,10 @@ export default async function LoginPage() {
|
|||
</HoverCardTrigger>
|
||||
<HoverCardContent className='flex items-center justify-center'>
|
||||
<Image
|
||||
src='https://i.gifer.com/22CU.gif'
|
||||
src='https://img1.wikia.nocookie.net/__cb20140808110649/clubpenguin/images/a/a1/Action_Dance_Light_Blue.gif'
|
||||
width='150'
|
||||
height='150'
|
||||
alt='cat gif'
|
||||
unoptimized
|
||||
alt='dancing penguin'
|
||||
></Image>
|
||||
</HoverCardContent>
|
||||
</HoverCard>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { signOut } from '@/auth';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
|
@ -8,6 +7,8 @@ import {
|
|||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
|
||||
import { signOut } from '@/auth';
|
||||
|
||||
export default function SignOutPage() {
|
||||
return (
|
||||
<div className='flex flex-col items-center justify-center h-screen'>
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
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,7 @@
|
|||
import { auth } from '@/auth';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { auth } from '@/auth';
|
||||
|
||||
export default async function Home() {
|
||||
const session = await auth();
|
||||
|
||||
|
|
|
@ -1,5 +1,482 @@
|
|||
import SettingsPage from '@/components/settings/settings-page';
|
||||
import { Button } from '@/components/ui/button';
|
||||
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 Page() {
|
||||
return <SettingsPage />;
|
||||
export default function SettingsPage() {
|
||||
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'>
|
||||
<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,22 +1,21 @@
|
|||
import { PrismaAdapter } from '@auth/prisma-adapter';
|
||||
import NextAuth, { CredentialsSignin } from 'next-auth';
|
||||
|
||||
import { Prisma } from '@/generated/prisma';
|
||||
import type { Provider } from 'next-auth/providers';
|
||||
|
||||
import Credentials from 'next-auth/providers/credentials';
|
||||
import AuthentikProvider from 'next-auth/providers/authentik';
|
||||
import Credentials from 'next-auth/providers/credentials';
|
||||
import DiscordProvider from 'next-auth/providers/discord';
|
||||
import FacebookProvider from 'next-auth/providers/facebook';
|
||||
import GithubProvider from 'next-auth/providers/github';
|
||||
import GitlabProvider from 'next-auth/providers/gitlab';
|
||||
import GoogleProvider from 'next-auth/providers/google';
|
||||
import KeycloakProvider from 'next-auth/providers/keycloak';
|
||||
|
||||
import { PrismaAdapter } from '@auth/prisma-adapter';
|
||||
import { prisma } from '@/prisma';
|
||||
import { ZodError } from 'zod/v4';
|
||||
|
||||
import { loginSchema } from '@/lib/auth/validation';
|
||||
import { ZodError } from 'zod/v4';
|
||||
|
||||
import { Prisma } from '@/generated/prisma';
|
||||
|
||||
import { prisma } from '@/prisma';
|
||||
|
||||
class InvalidLoginError extends CredentialsSignin {
|
||||
constructor(code: string) {
|
||||
|
@ -95,27 +94,13 @@ const providers: Provider[] = [
|
|||
}
|
||||
},
|
||||
}),
|
||||
|
||||
process.env.AUTH_AUTHENTIK_ID && AuthentikProvider,
|
||||
process.env.AUTH_DISCORD_ID && DiscordProvider,
|
||||
process.env.AUTH_FACEBOOK_ID && FacebookProvider,
|
||||
process.env.AUTH_GITHUB_ID && GithubProvider,
|
||||
process.env.AUTH_GITLAB_ID && GitlabProvider,
|
||||
process.env.AUTH_GOOGLE_ID && GoogleProvider,
|
||||
process.env.AUTH_KEYCLOAK_ID && KeycloakProvider,
|
||||
|
||||
process.env.AUTH_AUTHENTIK_ID &&
|
||||
AuthentikProvider({
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.sub,
|
||||
name: profile.preferred_username,
|
||||
first_name: profile.given_name.split(' ')[0] || '',
|
||||
last_name: profile.given_name.split(' ')[1] || '',
|
||||
email: profile.email,
|
||||
image: profile.picture,
|
||||
};
|
||||
},
|
||||
}),
|
||||
].filter(Boolean) as Provider[];
|
||||
|
||||
export const providerMap = providers
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { LucideProps } from 'lucide-react';
|
||||
import React, { ForwardRefExoticComponent, RefAttributes } from 'react';
|
||||
|
||||
export function IconButton({
|
||||
icon,
|
||||
children,
|
||||
...props
|
||||
}: {
|
||||
icon?: ForwardRefExoticComponent<
|
||||
Omit<LucideProps, 'ref'> & RefAttributes<SVGSVGElement>
|
||||
>;
|
||||
children?: React.ReactNode;
|
||||
icon: IconProp;
|
||||
children: React.ReactNode;
|
||||
} & React.ComponentProps<typeof Button>) {
|
||||
return (
|
||||
<Button type='button' variant='secondary' {...props}>
|
||||
{icon && React.createElement(icon, { className: 'mr-2' })}
|
||||
<FontAwesomeIcon icon={icon} className='mr-2' />
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { NDot, NotificationDot } from '@/components/misc/notification-dot';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { NDot, NotificationDot } from '@/components/misc/notification-dot';
|
||||
|
||||
export function NotificationButton({
|
||||
dotVariant,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Button } from '@/components/ui/button';
|
||||
import Link from 'next/link';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
export function RedirectButton({
|
||||
redirectUrl,
|
||||
buttonText,
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { signIn } from '@/auth';
|
||||
import { faOpenid } from '@fortawesome/free-brands-svg-icons';
|
||||
|
||||
import { IconButton } from '@/components/buttons/icon-button';
|
||||
import { Fingerprint } from 'lucide-react';
|
||||
|
||||
import { signIn } from '@/auth';
|
||||
|
||||
export default function SSOLogin({
|
||||
provider,
|
||||
|
@ -22,7 +24,7 @@ export default function SSOLogin({
|
|||
className='w-full'
|
||||
type='submit'
|
||||
variant='secondary'
|
||||
icon={Fingerprint}
|
||||
icon={faOpenid}
|
||||
{...props}
|
||||
>
|
||||
Login with {providerDisplayName}
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
'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 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 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 { Button } from '@/components/ui/button';
|
||||
import { fromZodIssue } from 'zod-validation-error/v4';
|
||||
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 { usePatchApiBlockedSlotsSlotID } from '@/generated/api/blocked-slots/blocked-slots';
|
||||
import { usePatchApiEventEventID } from '@/generated/api/event/event';
|
||||
import { UserCalendarSchemaItem } from '@/generated/api/meetup.schemas';
|
||||
|
||||
moment.updateLocale('en', {
|
||||
week: {
|
||||
|
@ -48,7 +49,6 @@ const DaDRBCalendar = withDragAndDrop<
|
|||
end: Date;
|
||||
type: UserCalendarSchemaItem['type'];
|
||||
userId?: string;
|
||||
organizer?: string;
|
||||
},
|
||||
{
|
||||
id: string;
|
||||
|
@ -192,13 +192,6 @@ function CalendarWithUserEvents({
|
|||
},
|
||||
},
|
||||
});
|
||||
const { mutate: patchBlockedSlot } = usePatchApiBlockedSlotsSlotID({
|
||||
mutation: {
|
||||
throwOnError(error) {
|
||||
throw error.response?.data || 'Failed to update blocked slot';
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<DaDRBCalendar
|
||||
|
@ -227,19 +220,11 @@ function CalendarWithUserEvents({
|
|||
end: new Date(event.end_time),
|
||||
type: event.type,
|
||||
userId: event.users[0],
|
||||
organizer: event.type === 'event' ? event.organizer_id : undefined,
|
||||
})) ?? []),
|
||||
...(additionalEvents ?? []),
|
||||
]}
|
||||
onSelectEvent={(event) => {
|
||||
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}`);
|
||||
}
|
||||
router.push(`/events/${event.id}`);
|
||||
}}
|
||||
onSelectSlot={(slotInfo) => {
|
||||
router.push(
|
||||
|
@ -250,108 +235,56 @@ function CalendarWithUserEvents({
|
|||
resourceTitleAccessor={(event) => event.title}
|
||||
startAccessor={(event) => event.start}
|
||||
endAccessor={(event) => event.end}
|
||||
selectable={sesstion.data?.user?.id === userId}
|
||||
selectable={sesstion.data?.user?.id === userId && !additionalEvents}
|
||||
onEventDrop={(event) => {
|
||||
const { start, end, event: droppedEvent } = event;
|
||||
if (
|
||||
droppedEvent.type === 'blocked_private' ||
|
||||
(droppedEvent.organizer &&
|
||||
droppedEvent.organizer !== sesstion.data?.user?.id)
|
||||
)
|
||||
return;
|
||||
if (droppedEvent.type === 'blocked_private') return;
|
||||
const startISO = new Date(start).toISOString();
|
||||
const endISO = new Date(end).toISOString();
|
||||
if (droppedEvent.type === 'blocked_owned') {
|
||||
patchBlockedSlot(
|
||||
{
|
||||
slotID: droppedEvent.id,
|
||||
data: {
|
||||
start_time: startISO,
|
||||
end_time: endISO,
|
||||
},
|
||||
patchEvent(
|
||||
{
|
||||
eventID: droppedEvent.id,
|
||||
data: {
|
||||
start_time: startISO,
|
||||
end_time: endISO,
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Error updating blocked slot:', error);
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
);
|
||||
return;
|
||||
} else if (droppedEvent.type === 'event') {
|
||||
patchEvent(
|
||||
{
|
||||
eventID: droppedEvent.id,
|
||||
data: {
|
||||
start_time: startISO,
|
||||
end_time: endISO,
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Error updating event:', error);
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Error updating event:', error);
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}}
|
||||
onEventResize={(event) => {
|
||||
const { start, end, event: resizedEvent } = event;
|
||||
if (
|
||||
resizedEvent.type === 'blocked_private' ||
|
||||
(resizedEvent.organizer &&
|
||||
resizedEvent.organizer !== sesstion.data?.user?.id)
|
||||
)
|
||||
return;
|
||||
if (resizedEvent.type === 'blocked_private') return;
|
||||
const startISO = new Date(start).toISOString();
|
||||
const endISO = new Date(end).toISOString();
|
||||
if (startISO === endISO) {
|
||||
console.warn('Start and end times are the same, skipping resize.');
|
||||
return;
|
||||
}
|
||||
if (resizedEvent.type === 'blocked_owned') {
|
||||
patchBlockedSlot(
|
||||
{
|
||||
slotID: resizedEvent.id,
|
||||
data: {
|
||||
start_time: startISO,
|
||||
end_time: endISO,
|
||||
},
|
||||
patchEvent(
|
||||
{
|
||||
eventID: resizedEvent.id,
|
||||
data: {
|
||||
start_time: startISO,
|
||||
end_time: endISO,
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Error resizing blocked slot:', error);
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
);
|
||||
return;
|
||||
} else if (resizedEvent.type === 'event') {
|
||||
patchEvent(
|
||||
{
|
||||
eventID: resizedEvent.id,
|
||||
data: {
|
||||
start_time: startISO,
|
||||
end_time: endISO,
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Error resizing event:', error);
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Error resizing event:', error);
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import './custom-toolbar.css';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { NavigateAction } from 'react-big-calendar';
|
||||
import DatePicker from 'react-datepicker';
|
||||
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 {
|
||||
//Aktuell angezeigtes Datum
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
'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 {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
|
@ -13,34 +24,20 @@ import {
|
|||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
} from '@/components/custom-ui/sidebar';
|
||||
|
||||
import { CalendarMinus, CalendarMinus2, ChevronDown } from 'lucide-react';
|
||||
import Logo from '@/components/misc/logo';
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleContent,
|
||||
CollapsibleTrigger,
|
||||
} 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 = [
|
||||
{
|
||||
title: 'Calendar',
|
||||
url: '/home',
|
||||
icon: CalendarDays,
|
||||
},
|
||||
/*{
|
||||
{
|
||||
title: 'Friends',
|
||||
url: '#',
|
||||
icon: User,
|
||||
|
@ -49,17 +46,12 @@ const items = [
|
|||
title: 'Groups',
|
||||
url: '#',
|
||||
icon: Users,
|
||||
},*/
|
||||
},
|
||||
{
|
||||
title: 'Events',
|
||||
url: '/events',
|
||||
icon: CalendarClock,
|
||||
},
|
||||
{
|
||||
title: 'Blockers',
|
||||
url: '/blocker',
|
||||
icon: CalendarMinus,
|
||||
},
|
||||
];
|
||||
|
||||
export function AppSidebar() {
|
||||
|
@ -67,27 +59,25 @@ export function AppSidebar() {
|
|||
<>
|
||||
<Sidebar collapsible='icon' variant='sidebar'>
|
||||
<SidebarHeader className='overflow-hidden'>
|
||||
<Link href='/home'>
|
||||
<Logo
|
||||
colorType='colored'
|
||||
logoType='combo'
|
||||
height={50}
|
||||
className='group-data-[collapsible=icon]:hidden min-w-[203px]'
|
||||
></Logo>
|
||||
<Logo
|
||||
colorType='colored'
|
||||
logoType='submark'
|
||||
height={50}
|
||||
className='group-data-[collapsible=]:hidden group-data-[mobile=true]/mobile:hidden'
|
||||
></Logo>
|
||||
</Link>
|
||||
<Logo
|
||||
colorType='colored'
|
||||
logoType='combo'
|
||||
height={50}
|
||||
className='group-data-[collapsible=icon]:hidden min-w-[203px]'
|
||||
></Logo>
|
||||
<Logo
|
||||
colorType='colored'
|
||||
logoType='submark'
|
||||
height={50}
|
||||
className='group-data-[collapsible=]:hidden group-data-[mobile=true]/mobile:hidden'
|
||||
></Logo>
|
||||
</SidebarHeader>
|
||||
<SidebarContent className='grid grid-rows-[auto_1fr_auto] overflow-hidden'>
|
||||
<Collapsible defaultOpen className='group/collapsible'>
|
||||
<SidebarGroup>
|
||||
<SidebarGroupLabel asChild>
|
||||
<CollapsibleTrigger disabled>
|
||||
<span className='flex items-center gap-2 text-xl font-label text-disabled'>
|
||||
<CollapsibleTrigger>
|
||||
<span className='flex items-center gap-2 text-xl font-label text-neutral-100'>
|
||||
<Star className='size-8' />{' '}
|
||||
<span className='group-data-[collapsible=icon]:hidden'>
|
||||
Favorites
|
||||
|
@ -130,17 +120,6 @@ export function AppSidebar() {
|
|||
</span>
|
||||
</Link>
|
||||
</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>
|
||||
</SidebarContent>
|
||||
</Sidebar>
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
'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,20 +1,24 @@
|
|||
'use client';
|
||||
|
||||
import { Card } from '@/components/ui/card';
|
||||
import Logo from '@/components/misc/logo';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import Link from 'next/link';
|
||||
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 { useSession } from 'next-auth/react';
|
||||
|
||||
import { usePatchApiEventEventIDParticipantUser } from '@/generated/api/event-participant/event-participant';
|
||||
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '../ui/select';
|
||||
import { usePatchApiEventEventIDParticipantUser } from '@/generated/api/event-participant/event-participant';
|
||||
} from '@/components/ui/select';
|
||||
|
||||
type EventListEntryProps = zod.output<typeof EventSchema>;
|
||||
|
||||
|
@ -43,10 +47,7 @@ export default function EventListEntry({
|
|||
return (
|
||||
<Link href={`/events/${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]'
|
||||
data-cy='event-list-entry'
|
||||
>
|
||||
<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>
|
||||
|
|
|
@ -1,64 +1,29 @@
|
|||
import { Input, Textarea } from '@/components/ui/input';
|
||||
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({
|
||||
type,
|
||||
label,
|
||||
subtext,
|
||||
placeholder,
|
||||
value,
|
||||
defaultValue,
|
||||
name,
|
||||
icon,
|
||||
variantSize = 'default',
|
||||
autocomplete,
|
||||
error,
|
||||
'data-cy': dataCy,
|
||||
...rest
|
||||
}: {
|
||||
type: 'text' | 'email' | 'password';
|
||||
label: string;
|
||||
subtext?: string;
|
||||
placeholder?: string;
|
||||
value?: string;
|
||||
name?: string;
|
||||
icon?: ForwardRefExoticComponent<
|
||||
Omit<LucideProps, 'ref'> & RefAttributes<SVGSVGElement>
|
||||
>;
|
||||
variantSize?: 'default' | 'big' | 'textarea';
|
||||
autocomplete?: string;
|
||||
error?: string;
|
||||
'data-cy'?: string;
|
||||
} & 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 (
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor={name}>{label}</Label>
|
||||
{subtext && (
|
||||
<Label className='text-sm text-muted-foreground' htmlFor={name}>
|
||||
{subtext}
|
||||
</Label>
|
||||
)}
|
||||
{variantSize === 'textarea' ? (
|
||||
<Textarea
|
||||
placeholder={placeholder}
|
||||
|
@ -66,52 +31,22 @@ export default function LabeledInput({
|
|||
id={name}
|
||||
name={name}
|
||||
rows={3}
|
||||
data-cy={dataCy}
|
||||
/>
|
||||
) : (
|
||||
<span className='relative'>
|
||||
<Input
|
||||
className={cn(
|
||||
type === 'password' ? 'pr-[50px]' : '',
|
||||
variantSize === 'big'
|
||||
? 'h-12 file:h-10 text-lg placeholder:text-lg sm:text-2xl sm:placeholder:text-2xl'
|
||||
: '',
|
||||
icon && inputValue === '' ? 'pl-10' : '',
|
||||
'transition-all duration-300 ease-in-out',
|
||||
)}
|
||||
type={passwordVisible ? 'text' : type}
|
||||
placeholder={placeholder}
|
||||
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>
|
||||
<Input
|
||||
type={type}
|
||||
placeholder={placeholder}
|
||||
defaultValue={value}
|
||||
id={name}
|
||||
name={name}
|
||||
className={
|
||||
variantSize === 'big'
|
||||
? 'h-12 file:h-10 text-lg gplaceholder:text-lg sm:text-2xl sm:placeholder:text-2xl'
|
||||
: ''
|
||||
}
|
||||
autoComplete={autocomplete}
|
||||
{...rest}
|
||||
/>
|
||||
)}
|
||||
{error && <p className='text-red-500 text-sm mt-1'>{error}</p>}
|
||||
</div>
|
||||
|
|
|
@ -1,32 +1,21 @@
|
|||
import React from 'react';
|
||||
import Image from 'next/image';
|
||||
import { user_default_dark } from '@/assets/usericon/default/defaultusericon-export';
|
||||
import { user_default_light } from '@/assets/usericon/default/defaultusericon-export';
|
||||
import { useTheme } from 'next-themes';
|
||||
import Image from 'next/image';
|
||||
import React from 'react';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
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>;
|
||||
|
||||
export default function ParticipantListEntry({
|
||||
user,
|
||||
status,
|
||||
eventID,
|
||||
}: ParticipantListEntryProps & { eventID?: string }) {
|
||||
const session = useSession();
|
||||
}: ParticipantListEntryProps) {
|
||||
const { resolvedTheme } = useTheme();
|
||||
const defaultImage =
|
||||
resolvedTheme === 'dark' ? user_default_dark : user_default_light;
|
||||
const updateAttendance = usePatchApiEventEventIDParticipantUser();
|
||||
|
||||
const finalImageSrc = user.image ?? defaultImage;
|
||||
|
||||
|
@ -34,38 +23,7 @@ export default function ParticipantListEntry({
|
|||
<div className='flex items-center gap-2 py-1 ml-5'>
|
||||
<Image src={finalImageSrc} alt='Avatar' width={30} height={30} />
|
||||
<span>{user.name}</span>
|
||||
{user.id === session.data?.user?.id && eventID ? (
|
||||
<Select
|
||||
defaultValue={status}
|
||||
onValueChange={(value) => {
|
||||
updateAttendance.mutate({
|
||||
eventID: eventID,
|
||||
user: session.data?.user?.id || '',
|
||||
data: {
|
||||
status: value as
|
||||
| 'ACCEPTED'
|
||||
| 'TENTATIVE'
|
||||
| 'DECLINED'
|
||||
| 'PENDING',
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<SelectTrigger id='language'>
|
||||
<SelectValue placeholder='Select status' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='ACCEPTED'>Attending</SelectItem>
|
||||
<SelectItem value='TENTATIVE'>Maybe Attending</SelectItem>
|
||||
<SelectItem value='DECLINED'>Not Attending</SelectItem>
|
||||
<SelectItem value='PENDING' disabled>
|
||||
Pending Response
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
) : (
|
||||
<span className='text-sm text-gray-500'>{status}</span>
|
||||
)}
|
||||
<span className='text-sm text-gray-500'>{status}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
'use client';
|
||||
|
||||
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 { Slot } from '@radix-ui/react-slot';
|
||||
import { VariantProps, cva } from 'class-variance-authority';
|
||||
import { PanelLeftIcon } from 'lucide-react';
|
||||
import * as React from 'react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
|
@ -25,6 +24,8 @@ import {
|
|||
TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const SIDEBAR_COOKIE_NAME = 'sidebar_state';
|
||||
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
||||
const SIDEBAR_WIDTH = '16rem';
|
||||
|
|
|
@ -1,285 +0,0 @@
|
|||
'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,26 +1,30 @@
|
|||
'use client';
|
||||
import React from 'react';
|
||||
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||
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 {
|
||||
usePostApiEvent,
|
||||
useGetApiEventEventID,
|
||||
usePatchApiEventEventID,
|
||||
} from '@/generated/api/event/event';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
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 Logo from '@/components/misc/logo';
|
||||
import { ToastInner } from '@/components/misc/toast-inner';
|
||||
import { UserSearchInput } from '@/components/misc/user-search';
|
||||
import ParticipantListEntry from '../custom-ui/participant-list-entry';
|
||||
import TimePicker from '@/components/time-picker';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
import zod from 'zod/v4';
|
||||
import { PublicUserSchema } from '@/app/api/user/validation';
|
||||
import Calendar from '@/components/calendar';
|
||||
|
||||
import {
|
||||
useGetApiEventEventID,
|
||||
usePatchApiEventEventID,
|
||||
usePostApiEvent,
|
||||
} from '@/generated/api/event/event';
|
||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||
|
||||
import ParticipantListEntry from '@/components/custom-ui/participant-list-entry';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
|
@ -29,8 +33,7 @@ import {
|
|||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '../ui/dialog';
|
||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||
} from '@/components/ui/dialog';
|
||||
|
||||
type User = zod.output<typeof PublicUserSchema>;
|
||||
|
||||
|
@ -51,19 +54,17 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
|||
const startFromUrl = searchParams.get('start');
|
||||
const endFromUrl = searchParams.get('end');
|
||||
|
||||
const {
|
||||
mutateAsync: createEvent,
|
||||
status,
|
||||
isSuccess,
|
||||
error,
|
||||
} = usePostApiEvent();
|
||||
const { mutate: createEvent, status, isSuccess, error } = usePostApiEvent();
|
||||
const { data, isLoading, error: fetchError } = useGetApiUserMe();
|
||||
const { data: eventData } = useGetApiEventEventID(props.eventId!, {
|
||||
query: { enabled: props.type === 'edit' },
|
||||
});
|
||||
const { data, isLoading, isError } = useGetApiUserMe();
|
||||
const patchEvent = usePatchApiEventEventID();
|
||||
const router = useRouter();
|
||||
|
||||
// Extract event fields for form defaults
|
||||
const event = eventData?.data?.event;
|
||||
|
||||
// State for date and time fields
|
||||
const [startDate, setStartDate] = React.useState<Date | undefined>(undefined);
|
||||
const [startTime, setStartTime] = React.useState('');
|
||||
|
@ -84,24 +85,22 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
|||
|
||||
// Update state when event data loads
|
||||
React.useEffect(() => {
|
||||
if (props.type === 'edit' && eventData?.data?.event) {
|
||||
setTitle(eventData?.data?.event.title || '');
|
||||
if (props.type === 'edit' && event) {
|
||||
setTitle(event.title || '');
|
||||
// Parse start_time and end_time
|
||||
if (eventData?.data?.event.start_time) {
|
||||
const start = new Date(eventData?.data?.event.start_time);
|
||||
if (event.start_time) {
|
||||
const start = new Date(event.start_time);
|
||||
setStartDate(start);
|
||||
setStartTime(start.toTimeString().slice(0, 5)); // "HH:mm"
|
||||
}
|
||||
if (eventData?.data?.event.end_time) {
|
||||
const end = new Date(eventData?.data?.event.end_time);
|
||||
if (event.end_time) {
|
||||
const end = new Date(event.end_time);
|
||||
setEndDate(end);
|
||||
setEndTime(end.toTimeString().slice(0, 5)); // "HH:mm"
|
||||
}
|
||||
setLocation(eventData?.data?.event.location || '');
|
||||
setDescription(eventData?.data?.event.description || '');
|
||||
setSelectedParticipants(
|
||||
eventData?.data?.event.participants?.map((u) => u.user) || [],
|
||||
);
|
||||
setLocation(event.location || '');
|
||||
setDescription(event.description || '');
|
||||
setSelectedParticipants(event.participants?.map((u) => u.user) || []);
|
||||
} else if (props.type === 'create' && startFromUrl && endFromUrl) {
|
||||
// If creating a new event with URL params, set title and dates
|
||||
setTitle('');
|
||||
|
@ -112,7 +111,7 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
|||
setEndDate(end);
|
||||
setEndTime(end.toTimeString().slice(0, 5)); // "HH:mm"
|
||||
}
|
||||
}, [eventData?.data?.event, props.type, startFromUrl, endFromUrl]);
|
||||
}, [event, props.type, startFromUrl, endFromUrl]);
|
||||
|
||||
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
||||
e.preventDefault();
|
||||
|
@ -154,10 +153,8 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
|||
participants: selectedParticipants.map((u) => u.id),
|
||||
};
|
||||
|
||||
let eventID: string | undefined;
|
||||
|
||||
if (props.type === 'edit' && props.eventId) {
|
||||
const mutationResult = await patchEvent.mutateAsync({
|
||||
await patchEvent.mutateAsync({
|
||||
eventID: props.eventId,
|
||||
data: {
|
||||
title: data.title,
|
||||
|
@ -168,20 +165,18 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
|||
participants: data.participants,
|
||||
},
|
||||
});
|
||||
eventID = mutationResult.data.event.id;
|
||||
console.log('Updating event');
|
||||
} else {
|
||||
console.log('Creating event');
|
||||
const mutationResult = await createEvent({ data });
|
||||
eventID = mutationResult.data.event.id;
|
||||
createEvent({ data });
|
||||
}
|
||||
|
||||
toast.custom((t) => (
|
||||
<ToastInner
|
||||
toastId={t}
|
||||
title='Event saved'
|
||||
description={eventData?.data?.event.title}
|
||||
onAction={() => router.push(`/events/${eventID}`)}
|
||||
description={event?.title}
|
||||
onAction={() => router.push(`/events/${event?.id}`)}
|
||||
variant='success'
|
||||
buttonText='show'
|
||||
/>
|
||||
|
@ -190,216 +185,207 @@ const EventForm: React.FC<EventFormProps> = (props) => {
|
|||
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
|
||||
const createdAtValue =
|
||||
props.type === 'edit' && eventData?.data?.event?.created_at
|
||||
? eventData.data.event.created_at
|
||||
props.type === 'edit' && event?.created_at
|
||||
? event.created_at
|
||||
: new Date().toISOString();
|
||||
const updatedAtValue =
|
||||
props.type === 'edit' && eventData?.data?.event?.updated_at
|
||||
? eventData.data.event.updated_at
|
||||
props.type === 'edit' && event?.updated_at
|
||||
? event.updated_at
|
||||
: new Date().toISOString();
|
||||
|
||||
// Format date for display
|
||||
const createdAtDisplay = new Date(createdAtValue).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' && isError) return <div>Error loading event.</div>;
|
||||
if (props.type === 'edit' && fetchError)
|
||||
return <div>Error loading event.</div>;
|
||||
|
||||
return (
|
||||
<Dialog open={calendarOpen} onOpenChange={setCalendarOpen}>
|
||||
<form
|
||||
className='flex flex-col gap-5 w-full'
|
||||
onSubmit={handleSubmit}
|
||||
data-cy='event-form'
|
||||
>
|
||||
<div className='grid grid-row-start:auto gap-4 sm:gap-8 w-full'>
|
||||
<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='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'>
|
||||
<LabeledInput
|
||||
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)}
|
||||
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>
|
||||
<>
|
||||
<Dialog open={calendarOpen} onOpenChange={setCalendarOpen}>
|
||||
<form className='flex flex-col gap-5 w-full' onSubmit={handleSubmit}>
|
||||
<div className='grid grid-row-start:auto gap-4 sm:gap-8 w-full'>
|
||||
<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='w-[100px] max-sm:w-full max-sm:flex max-sm:justify-center'>
|
||||
<Logo colorType='monochrome' logoType='submark' width={50} />
|
||||
</div>
|
||||
<div className='flex flex-row gap-2'>
|
||||
<Label className='w-[70px]'>updated:</Label>
|
||||
<p className='text-[var(--color-neutral-300)]'>
|
||||
{updatedAtDisplay}
|
||||
</p>
|
||||
<div className='items-center ml-auto mr-auto max-sm:mb-6 max-sm:w-full'>
|
||||
<LabeledInput
|
||||
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='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='grid grid-cols-4 gap-4 h-full w-full max-lg:grid-cols-2 max-sm:grid-cols-1'>
|
||||
<div>
|
||||
<TimePicker
|
||||
dateLabel='start Time'
|
||||
timeLabel=' '
|
||||
date={startDate}
|
||||
setDate={setStartDate}
|
||||
time={startTime}
|
||||
setTime={setStartTime}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<TimePicker
|
||||
dateLabel='end Time'
|
||||
timeLabel=' '
|
||||
date={endDate}
|
||||
setDate={setEndDate}
|
||||
time={endTime}
|
||||
setTime={setEndTime}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-54'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Location'
|
||||
placeholder='where is the event?'
|
||||
name='eventLocation'
|
||||
value={location}
|
||||
onChange={(e) => setLocation(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex flex-col gap-4'>
|
||||
<div className='flex flex-row gap-2'>
|
||||
<Label>Organiser:</Label>
|
||||
<Label className='w-[70px]'>created:</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)]'>
|
||||
{!isClient || isLoading
|
||||
? 'Loading...'
|
||||
: data?.data.user.name || 'Unknown User'}
|
||||
{updatedAtDisplay}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='h-full w-full grid grid-cols-2 gap-4 max-sm:grid-cols-1'>
|
||||
<div className='h-full w-full grid grid-flow-row gap-4'>
|
||||
<div className='h-full w-full'>
|
||||
<div className='flex flex-row gap-2'>
|
||||
<Label>Organiser:</Label>
|
||||
<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'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Event Description'
|
||||
placeholder='What is the event about?'
|
||||
name='eventDescription'
|
||||
variantSize='textarea'
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
data-cy='event-description-input'
|
||||
></LabeledInput>
|
||||
<Label>Participants</Label>
|
||||
<UserSearchInput
|
||||
selectedUsers={selectedParticipants}
|
||||
addUserAction={(user) => {
|
||||
setSelectedParticipants((current) =>
|
||||
current.find((u) => u.id === user.id)
|
||||
? current
|
||||
: [...current, user],
|
||||
);
|
||||
}}
|
||||
removeUserAction={(user) => {
|
||||
setSelectedParticipants((current) =>
|
||||
current.filter((u) => u.id !== user.id),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<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 className='h-full w-full'>
|
||||
<Label>Participants</Label>
|
||||
<UserSearchInput
|
||||
selectedUsers={selectedParticipants}
|
||||
addUserAction={(user) => {
|
||||
setSelectedParticipants((current) =>
|
||||
current.find((u) => u.id === user.id)
|
||||
? current
|
||||
: [...current, user],
|
||||
);
|
||||
}}
|
||||
removeUserAction={(user) => {
|
||||
setSelectedParticipants((current) =>
|
||||
current.filter((u) => u.id !== user.id),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant='primary'>Calendar</Button>
|
||||
</DialogTrigger>
|
||||
<div className='grid grid-cols-1 mt-3'>
|
||||
{selectedParticipants.map((user) => (
|
||||
<ParticipantListEntry
|
||||
key={user.id}
|
||||
user={user}
|
||||
status='PENDING'
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||
<Button
|
||||
type='button'
|
||||
variant='secondary'
|
||||
onClick={() => {
|
||||
router.back();
|
||||
console.log('user aborted - no change in database');
|
||||
}}
|
||||
>
|
||||
cancel
|
||||
</Button>
|
||||
</div>
|
||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||
<Button
|
||||
type='submit'
|
||||
variant='primary'
|
||||
disabled={status === 'pending'}
|
||||
data-cy='event-save-button'
|
||||
>
|
||||
{status === 'pending' ? 'Saving...' : 'save event'}
|
||||
</Button>
|
||||
<div className='flex flex-row gap-2 justify-end mt-4 mb-6'>
|
||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||
<Button
|
||||
type='button'
|
||||
variant='secondary'
|
||||
onClick={() => {
|
||||
router.back();
|
||||
console.log('user aborted - no change in database');
|
||||
}}
|
||||
>
|
||||
cancel
|
||||
</Button>
|
||||
</div>
|
||||
<div className='w-[20%] grid max-sm:w-[40%]'>
|
||||
<Button
|
||||
type='submit'
|
||||
variant='primary'
|
||||
disabled={status === 'pending'}
|
||||
>
|
||||
{status === 'pending' ? 'Saving...' : 'save event'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{isSuccess && <p>Event created!</p>}
|
||||
{error && <p className='text-red-500'>Error: {error.message}</p>}
|
||||
</div>
|
||||
{isSuccess && <p>Event created!</p>}
|
||||
{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>
|
||||
</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,24 +1,15 @@
|
|||
'use client';
|
||||
|
||||
import React, { useState, useRef } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import React, { useRef, useState } from 'react';
|
||||
|
||||
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||
import useZodForm from '@/lib/hooks/useZodForm';
|
||||
import { loginSchema, registerSchema } from '@/lib/auth/validation';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
import { loginAction } from '@/lib/auth/login';
|
||||
import { registerAction } from '@/lib/auth/register';
|
||||
import { IconButton } from '../buttons/icon-button';
|
||||
import {
|
||||
FileKey,
|
||||
FileKey2,
|
||||
LogIn,
|
||||
MailOpen,
|
||||
RotateCcwKey,
|
||||
UserCheck,
|
||||
UserPen,
|
||||
UserPlus,
|
||||
} from 'lucide-react';
|
||||
import { loginSchema, registerSchema } from '@/lib/auth/validation';
|
||||
import useZodForm from '@/lib/hooks/useZodForm';
|
||||
|
||||
function LoginFormElement({
|
||||
setIsSignUp,
|
||||
|
@ -66,7 +57,6 @@ function LoginFormElement({
|
|||
<LabeledInput
|
||||
type='text'
|
||||
label='E-Mail or Username'
|
||||
icon={UserCheck}
|
||||
placeholder='What you are known as'
|
||||
error={formState.errors.email?.message}
|
||||
{...register('email')}
|
||||
|
@ -75,22 +65,16 @@ function LoginFormElement({
|
|||
<LabeledInput
|
||||
type='password'
|
||||
label='Password'
|
||||
icon={FileKey}
|
||||
placeholder="Let's hope you remember it"
|
||||
error={formState.errors.password?.message}
|
||||
{...register('password')}
|
||||
data-cy='password-input'
|
||||
/>
|
||||
<div className='grid grid-rows-2 gap-2'>
|
||||
<IconButton
|
||||
type='submit'
|
||||
variant='primary'
|
||||
data-cy='login-button'
|
||||
icon={LogIn}
|
||||
>
|
||||
<Button type='submit' variant='primary' data-cy='login-button'>
|
||||
Login
|
||||
</IconButton>
|
||||
<IconButton
|
||||
</Button>
|
||||
<Button
|
||||
type='button'
|
||||
variant='outline_primary'
|
||||
onClick={() => {
|
||||
|
@ -98,10 +82,9 @@ function LoginFormElement({
|
|||
setIsSignUp((v) => !v);
|
||||
}}
|
||||
data-cy='register-switch'
|
||||
icon={UserPlus}
|
||||
>
|
||||
Sign Up
|
||||
</IconButton>
|
||||
</Button>
|
||||
</div>
|
||||
<div>
|
||||
{formState.errors.root?.message && (
|
||||
|
@ -174,30 +157,27 @@ function RegisterFormElement({
|
|||
{...register('lastName')}
|
||||
data-cy='last-name-input'
|
||||
/>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Username'
|
||||
icon={UserPen}
|
||||
placeholder='Your username'
|
||||
autocomplete='username'
|
||||
error={formState.errors.username?.message}
|
||||
{...register('username')}
|
||||
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
|
||||
type='text'
|
||||
label='Username'
|
||||
placeholder='Your username'
|
||||
autocomplete='username'
|
||||
error={formState.errors.username?.message}
|
||||
{...register('username')}
|
||||
data-cy='username-input'
|
||||
/>
|
||||
<LabeledInput
|
||||
type='password'
|
||||
label='Password'
|
||||
icon={FileKey2}
|
||||
placeholder='Create a password'
|
||||
autocomplete='new-password'
|
||||
error={formState.errors.password?.message}
|
||||
|
@ -207,7 +187,6 @@ function RegisterFormElement({
|
|||
<LabeledInput
|
||||
type='password'
|
||||
label='Confirm Password'
|
||||
icon={RotateCcwKey}
|
||||
placeholder='Repeat your password'
|
||||
autocomplete='new-password'
|
||||
error={formState.errors.confirmPassword?.message}
|
||||
|
@ -215,25 +194,19 @@ function RegisterFormElement({
|
|||
data-cy='confirm-password-input'
|
||||
/>
|
||||
<div className='grid grid-rows-2 gap-2'>
|
||||
<IconButton
|
||||
type='submit'
|
||||
variant='primary'
|
||||
data-cy='register-button'
|
||||
icon={UserPlus}
|
||||
>
|
||||
<Button type='submit' variant='primary' data-cy='register-button'>
|
||||
Sign Up
|
||||
</IconButton>
|
||||
<IconButton
|
||||
</Button>
|
||||
<Button
|
||||
type='button'
|
||||
variant='outline_primary'
|
||||
onClick={() => {
|
||||
formRef?.current?.reset();
|
||||
setIsSignUp((v) => !v);
|
||||
}}
|
||||
icon={LogIn}
|
||||
>
|
||||
Back to Login
|
||||
</IconButton>
|
||||
</Button>
|
||||
</div>
|
||||
<div>
|
||||
{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 { 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';
|
||||
|
||||
const items = [
|
||||
{
|
||||
title: 'Inbox',
|
||||
title: 'Calendar',
|
||||
url: '#',
|
||||
icon: Inbox,
|
||||
},
|
||||
{
|
||||
title: 'Notifications',
|
||||
title: 'Friends',
|
||||
url: '#',
|
||||
icon: BellRing,
|
||||
},
|
||||
|
@ -25,21 +25,17 @@ export default function Header({
|
|||
}>) {
|
||||
return (
|
||||
<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'
|
||||
data-cy='header'
|
||||
>
|
||||
<header className='border-b-1 grid-cols-[1fr_3fr_1fr] grid items-center px-2 shadow-md'>
|
||||
<span className='flex justify-start'>
|
||||
<SidebarTrigger variant='outline_primary' size='icon' />
|
||||
</span>
|
||||
<span className='flex justify-center'></span>
|
||||
<span className='flex justify-center'>Search</span>
|
||||
<span className='flex gap-1 justify-end'>
|
||||
<ThemePicker />
|
||||
{items.map((item) => (
|
||||
<NotificationButton
|
||||
disabled
|
||||
key={item.title}
|
||||
variant='outline_muted'
|
||||
variant='outline_primary'
|
||||
dotVariant='hidden'
|
||||
size='icon'
|
||||
>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import Image, { ImageProps } from 'next/image';
|
||||
|
||||
import * as logoAssets from '@/assets/logo/logo-export';
|
||||
import { useTheme } from 'next-themes';
|
||||
import Image, { ImageProps } from 'next/image';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
type ColorType = 'colored' | 'monochrome';
|
||||
type LogoType = 'combo' | 'primary' | 'secondary' | 'submark';
|
||||
|
|
|
@ -9,6 +9,12 @@ import {
|
|||
Sparkles,
|
||||
} from 'lucide-react';
|
||||
|
||||
import {
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
useSidebar,
|
||||
} from '@/components/custom-ui/sidebar';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import {
|
||||
DropdownMenu,
|
||||
|
@ -19,12 +25,6 @@ import {
|
|||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
useSidebar,
|
||||
} from '@/components/custom-ui/sidebar';
|
||||
|
||||
export function NavUser({
|
||||
user,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { cn } from '@/lib/utils';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import { type VariantProps, cva } from 'class-variance-authority';
|
||||
import { CircleSmall } from 'lucide-react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const dotVariants = cva('', {
|
||||
variants: {
|
||||
variant: {
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
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,4 +1,5 @@
|
|||
import React from 'react';
|
||||
|
||||
import { ThemePicker } from '@/components/misc/theme-picker';
|
||||
import { ThemeProvider } from '@/components/wrappers/theme-provider';
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { Moon, Sun } from 'lucide-react';
|
||||
import { useTheme } from 'next-themes';
|
||||
import * as React from 'react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
|
|
|
@ -39,12 +39,54 @@ import { Button } from '@/components/ui/button';
|
|||
|
||||
'use client';
|
||||
|
||||
import { toast } from 'sonner';
|
||||
import { X } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import * as Icons from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
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';
|
||||
|
||||
interface ToastInnerProps {
|
||||
title: string;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||
import { Avatar } from '@/components/ui/avatar';
|
||||
import Image from 'next/image';
|
||||
import { User } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
|
||||
import { Avatar } from '@/components/ui/avatar';
|
||||
|
||||
import { useGetApiUserMe } from '@/generated/api/user/user';
|
||||
|
||||
export default function UserCard() {
|
||||
const { data } = useGetApiUserMe();
|
||||
|
@ -21,7 +23,7 @@ export default function UserCard() {
|
|||
)}
|
||||
</Avatar>
|
||||
<div className='flex justify-center'>{data?.data.user.name}</div>
|
||||
<div className='flex justify-center text-text-muted text-[12px]'>
|
||||
<div className='flex justify-center text-text-muted'>
|
||||
{data?.data.user.email}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
'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 { Button } from '@/components/ui/button';
|
||||
import {
|
||||
|
@ -9,15 +14,11 @@ import {
|
|||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
|
||||
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() {
|
||||
const { data } = useGetApiUserMe();
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
|
@ -42,13 +43,11 @@ export default function UserDropdown() {
|
|||
<UserCard />
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<Link href='/settings'>
|
||||
<DropdownMenuItem>Settings</DropdownMenuItem>
|
||||
</Link>
|
||||
<DropdownMenuItem>Settings</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<Link href='/logout'>
|
||||
<DropdownMenuItem>Logout</DropdownMenuItem>
|
||||
</Link>
|
||||
<DropdownMenuItem>
|
||||
<Link href='/logout'>Logout</Link>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import * as React from 'react';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Command,
|
||||
|
@ -18,10 +18,13 @@ import {
|
|||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from '@/components/ui/popover';
|
||||
import { useGetApiSearchUser } from '@/generated/api/search/search';
|
||||
import zod from 'zod/v4';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { PublicUserSchema } from '@/app/api/user/validation';
|
||||
|
||||
import { useGetApiSearchUser } from '@/generated/api/search/search';
|
||||
|
||||
type User = zod.output<typeof PublicUserSchema>;
|
||||
|
||||
export function UserSearchInput({
|
||||
|
|
|
@ -1,165 +0,0 @@
|
|||
'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>
|
||||
);
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
'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>
|
||||
);
|
||||
}
|
|
@ -1,287 +0,0 @@
|
|||
'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>
|
||||
);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
'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>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -1,226 +0,0 @@
|
|||
'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>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
'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>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
'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>
|
||||
);
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
'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';
|
||||
|
||||
import * as React from 'react';
|
||||
import { ChevronDownIcon } from 'lucide-react';
|
||||
import * as React from 'react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Calendar } from '@/components/ui/calendar';
|
||||
|
@ -20,7 +20,6 @@ export default function TimePicker({
|
|||
setDate,
|
||||
time,
|
||||
setTime,
|
||||
...props
|
||||
}: {
|
||||
dateLabel?: string;
|
||||
timeLabel?: string;
|
||||
|
@ -28,12 +27,12 @@ export default function TimePicker({
|
|||
setDate?: (date: Date | undefined) => void;
|
||||
time?: string;
|
||||
setTime?: (time: string) => void;
|
||||
} & React.HTMLAttributes<HTMLDivElement>) {
|
||||
}) {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
||||
return (
|
||||
<div className='grid grid-cols-2 gap-4' {...props}>
|
||||
<div className='grid grid-rows-2 gap-2'>
|
||||
<div className='flex gap-4'>
|
||||
<div className='flex flex-col gap-3'>
|
||||
<Label htmlFor='date' className='px-1'>
|
||||
{dateLabel}
|
||||
</Label>
|
||||
|
@ -69,7 +68,7 @@ export default function TimePicker({
|
|||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
<div className='grid grid-rows-2 gap-2'>
|
||||
<div className='flex flex-col gap-3'>
|
||||
<Label htmlFor='time' className='px-1'>
|
||||
{timeLabel}
|
||||
</Label>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
||||
import * as React from 'react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import * as React from 'react';
|
||||
import { Slot } from '@radix-ui/react-slot';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import { type VariantProps, cva } from 'class-variance-authority';
|
||||
import * as React from 'react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
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-nonef",
|
||||
"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",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
} from 'lucide-react';
|
||||
import * as React from 'react';
|
||||
import { DayButton, DayPicker, getDefaultClassNames } from 'react-day-picker';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Button, buttonVariants } from '@/components/ui/button';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
function Calendar({
|
||||
className,
|
||||
classNames,
|
||||
|
|
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