diff --git a/.eslintrc.json b/.eslintrc.json index bffb357a7..92da9a123 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,496 @@ { - "extends": "next/core-web-vitals" + "extends": [ + "next/core-web-vitals", + "eslint:recommended", + "plugin:@typescript-eslint/recommended" + ], + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "root": true, + "rules": { + "indent": [ + "error", + 4, + { + "SwitchCase": 1, + "VariableDeclarator": 1 + } + ], + // require function expressions to have a name + "func-names": "warn", + // enforce newline at the end of file, with no multiple empty lines + "eol-last": "error", + // disallow padding inside computed properties, ie. obj[ "fjie"] not allowed + "computed-property-spacing": [ + "error", + "never" + ], + "comma-style": [ + "error", + "last" + ], + // suggest using arrow functions as callbacks + "prefer-arrow-callback": "error", + // suggest using template literals instead of string concatenation + "prefer-template": "error", + // disallow modifying variables that are declared using const + "no-const-assign": "error", + // disallow symbol constructor + "no-new-symbol": "error", + // disallow to use this/super before super() calling in constructors. + "no-this-before-super": "error", + // require let or const instead of var + "no-var": "error", + // disallow unnecessary constructor + "no-useless-constructor": "error", + // require method and property shorthand syntax for object literals + // ie write obj = { x }, not obj = {x: x} + "object-shorthand": [ + "error", + "always" + ], + // disallow deletion of variables + "no-delete-var": "error", + // disallow labels that share a name with a variable + "no-label-var": "error", + // disallow self assignment + "no-self-assign": "error", + // disallow shadowing of names such as arguments + "no-shadow-restricted-names": "error", + // disallow declaration of variables already declared in the outer scope + "no-shadow": "error", + // disallow use of undeclared variables unless mentioned in a /*global */ block + "no-undef": "error", + // disallow declaration of variables that are not used in the code + "no-unused-vars": [ + "error", + { + "vars": "local", + "args": "after-used" + } + ], + // disallow use of variables before they are defined + "no-use-before-define": "error", + // enforces no braces where they can be omitted + "arrow-body-style": [ + "error", + "as-needed" + ], + // require space before/after arrow function"s arrow + "arrow-spacing": [ + "error", + { + "before": true, + "after": true + } + ], + // verify super() callings in constructors + "constructor-super": "error", + // disallow modifying variables of class declarations + "no-class-assign": "error", + // disallow arrow functions where they could be confused with comparisons + "no-confusing-arrow": [ + "error", + { + "allowParens": true + } + ], + // Require or disallow spaces before/after unary operators + "space-unary-ops": [ + "error", + { + "words": true, + "nonwords": false + } + ], + "quotes": [ + "error", + "single", + "avoid-escape" + ], + "jsx-quotes": ["error", "prefer-double"], + // require camel case names + "camelcase": [ + "error", + { + "properties": "never" + } + ], + // enforce spacing before and after comma + "comma-spacing": [ + "error", + { + "before": false, + "after": true + } + ], + // enforce one true comma style + "comma-style": [ + "error", + "last" + ], + "key-spacing": [ + "error", + { + "beforeColon": false, + "afterColon": true + } + ], + // require a space before & after certain keywords + "keyword-spacing": [ + "error", + { + "before": true, + "after": true, + "overrides": { + "return": { "after": true }, + "throw": { "after": true }, + "case": { "after": true } + } + } + ], + // disallow mixed "LF" and "CRLF" as linebreaks + "linebreak-style": [ + "error", + "unix" + ], + // specify the maximum length of a line in your program + "max-len": [ + "error", + 100, + 4, + { + "ignoreUrls": true, + "ignoreComments": false, + "ignoreTemplateLiterals": true, + "ignoreStrings": true, + "ignoreRegExpLiterals": true + } + ], + // specify the maximum depth callbacks can be nested + "max-nested-callbacks": [ + "error", + 3 + ], + // disallow the omission of parentheses when invoking a constructor with no arguments + "new-parens": "error", + // enforces new line after each method call in the chain to make it + // more readable and easy to maintain + "newline-per-chained-call": [ + "error", + { + "ignoreChainWithDepth": 4 + } + ], + // disallow use of the Array constructor + "no-array-constructor": "error", + // disallow use of the continue statement + "no-continue": "warn", + // disallow if as the only statement in an else block + "no-lonely-if": "error", + // disallow mixed spaces and tabs for indentation + "no-mixed-spaces-and-tabs": "error", + // disallow multiple empty lines and only one newline at the end + "no-multiple-empty-lines": [ + "error", + { + "max": 2, + "maxEOF": 1 + } + ], + // disallow nested ternary expressions + "no-nested-ternary": "error", + // disallow use of the Object constructor + "no-new-object": "error", + // disallow space between function identifier and application + "no-spaced-func": "error", + // disallow trailing whitespace at the end of lines + "no-trailing-spaces": "error", + // disallow the use of Boolean literals in conditional expressions + // also, prefer `a || b` over `a ? a : b` + "no-unneeded-ternary": [ + "error", + { + "defaultAssignment": true + } + ], + // disallow whitespace before properties + "no-whitespace-before-property": "error", + // require padding inside curly braces + "object-curly-spacing": [ + "error", + "always" + ], + // require a newline around variable declaration + "one-var-declaration-per-line": [ + "error", + "always" + ], + // enforce padding within blocks + "padded-blocks": [ + "error", + "never" + ], + // require quotes around object literal property names + "quote-props": [ + "warn", + "as-needed", + { + "keywords": false, + "unnecessary": true, + "numbers": false + } + ], + // specify whether double or single quotes should be used + // require or disallow use of semicolons instead of ASI + "semi": [ + "error", + "never" + ], + // require or disallow space before blocks + "space-before-blocks": "error", + // require or disallow space before function opening parenthesis + "space-before-function-paren": [ + "error", + { + "anonymous": "always", + "named": "never" + } + ], + // require or disallow spaces inside parentheses + "space-in-parens": [ + "error", + "never" + ], + // require spaces around operators + "space-infix-ops": "error", + // enforces return statements in callbacks of array"s methods + "array-callback-return": "error", + // require return statements to either always or never specify values + "consistent-return": "error", + // specify curly brace conventions for all control statements + "curly": [ + "error", + "multi-line" + ], + // require default case in switch statements + "default-case": "error", + // encourages use of dot notation whenever possible + "dot-notation": "error", + // require the use of === and !== + "eqeqeq": "error", + // make sure for-in loops have an if statement + "guard-for-in": "error", + // disallow the use of alert, confirm, and prompt + "no-alert": "warn", + // disallow use of arguments.caller or arguments.callee + "no-caller": "error", + // disallow lexical declarations in case/default clauses + "no-case-declarations": "error", + // disallow else after a return in an if + "no-else-return": "error", + // disallow Unnecessary Labels + "no-extra-label": "error", + // disallow comparisons to null without a type-checking operator + "no-eq-null": "error", + // disallow use of eval() + "no-eval": "error", + // disallow adding to native types + "no-extend-native": "error", + // disallow unnecessary function binding + "no-extra-bind": "error", + // disallow fallthrough of case statements + "no-fallthrough": "error", + // disallow the use of leading or trailing decimal points in numeric literals + "no-floating-decimal": "error", + // disallow use of eval()-like methods + "no-implied-eval": "error", + // disallow this keywords outside of classes or class-like objects + "no-iterator": "error", + // disallow use of labels for anything other then loops and switches + "no-labels": [ + "error", + { + "allowLoop": false, + "allowSwitch": false + } + ], + // disallow unnecessary nested blocks + "no-lone-blocks": "error", + // disallow creation of functions within loops + "no-loop-func": "error", + // disallow use of multiple spaces + "no-multi-spaces": "error", + // disallow use of multiline strings + "no-multi-str": "error", + // disallow reassignments of native objects + "no-native-reassign": "error", + // disallow use of new operator when not part of the assignment or comparison + "no-new": "error", + // disallow use of new operator for Function object + "no-new-func": "error", + // disallows creating new instances of String,Number, and Boolean + "no-new-wrappers": "error", + // disallow use of (old style) octal literals + "no-octal": "error", + // disallow use of octal escape sequences in string literals, such as + // var foo = "Copyright \251"; + "no-octal-escape": "error", + // disallow reassignment of function parameters + // disallow parameter object manipulation + "no-param-reassign": [ + "warn", + { + "props": false + } + ], + // disallow usage of __proto__ property + "no-proto": "error", + // disallow declaring the same variable more then once + "no-redeclare": "error", + // disallow use of assignment in return statement + "no-return-assign": "error", + // disallow use of `javascript:` urls. + "no-script-url": "error", + // disallow comparisons where both sides are exactly the same + "no-self-compare": "error", + // disallow use of comma operator + "no-sequences": "error", + // disallow usage of expressions in statement position + "no-unused-expressions": "error", + // disallow unused labels + "no-unused-labels": "error", + // disallow usage of configurable warning terms in comments: e.g. todo + "no-warning-comments": [ + "warn", + { + "terms": ["todo", "fixme", "xxx"], + "location": "start" + } + ], + // disallow use of the with statement + "no-with": "error", + // require use of the second argument for parseInt() + "radix": "error", + // require immediate function invocation to be wrapped in parentheses + "wrap-iife": [ + "error", + "outside" + ], + // require or disallow Yoda conditions + "yoda": "error", + // disallow assignment in conditional expressions + "no-cond-assign": [ + "error", + "always" + ], + // disallow use of constant expressions in conditions + "no-constant-condition": "warn", + // disallow control characters in regular expressions + "no-control-regex": "error", + // disallow use of debugger + "no-debugger": "warn", + // disallow duplicate arguments in functions + "no-dupe-args": "error", + // disallow duplicate keys when creating object literals + "no-dupe-keys": "error", + // disallow a duplicate case label. + "no-duplicate-case": "error", + // disallow the use of empty character classes in regular expressions + "no-empty-character-class": "error", + // disallow empty statements + "no-empty": "error", + // disallow assigning to the exception in a catch block + "no-ex-assign": "error", + // disallow double-negation boolean casts in a boolean context + "no-extra-boolean-cast": "error", + // disallow unnecessary parentheses + "no-extra-parens": [ + "error", + "functions" + ], + // disallow unnecessary semicolons + "no-extra-semi": "error", + // disallow overwriting functions written as function declarations + "no-func-assign": "error", + // disallow function or variable declarations in nested blocks + "no-inner-declarations": "error", + // disallow invalid regular expression strings in the RegExp constructor + "no-invalid-regexp": "error", + // disallow irregular whitespace outside of strings and comments + "no-irregular-whitespace": "error", + // disallow negation of the left operand of an in expression + "no-negated-in-lhs": "error", + // disallow the use of object properties of the global object (Math and JSON) as functions + "no-obj-calls": "error", + // disallow multiple spaces in a regular expression literal + "no-regex-spaces": "error", + // disallow sparse arrays + "no-sparse-arrays": "error", + // disallow unreachable statements after a return, throw, continue, or break statement + "no-unreachable": "error", + // disallow comparisons with the value NaN + "use-isnan": "error", + // ensure JSDoc comments are valid + "valid-jsdoc": "warn", + // ensure that the results of typeof are compared against a valid string + "valid-typeof": "error", + // Avoid code that looks like two expressions but is actually one + "no-unexpected-multiline": "error", + // specify the maximum depth that blocks can be nested + "max-depth": [ + "error", + 4 + ], + // limits the number of parameters that can be used in the function declaration. + "max-params": [ + "error", + 4 + ], + // disallow use of bitwise operators + "no-bitwise": "warn", + // enforce return after a callback + "callback-return": "error", + // enforces error handling in callbacks (node environment) + "handle-callback-err": "error", + // disallow mixing regular variable and require declarations + "no-mixed-requires": [ + "error", + { + "grouping": true, + "allowCall": true + } + ], + // disallow use of new operator with the require function + "no-new-require": "error", + // disallow string concatenation with __dirname and __filename + "no-path-concat": "error", + // disallow process.exit() + "no-process-exit": "error", + // disallow use of synchronous methods (off by default) + "no-sync": "error", + // enforce spacing inside array brackets + "array-bracket-spacing": [ + "error", + "never" + ], + // enforce one true brace style + "brace-style": [ + "error", + "1tbs", + { + "allowSingleLine": true + } + ], + + //SOME ODD OPTIONS: + // suggest using the spread operator instead of .apply() + "prefer-spread": "error", + // suggest using Reflect methods where applicable + "prefer-reflect": "error", + // use rest parameters instead of arguments + "prefer-rest-params": "error", + // enforce usage of spacing in template strings + "template-curly-spacing": "error" + } } diff --git a/package-lock.json b/package-lock.json index 99edbed35..692339056 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,8 @@ "@types/react": "^18.2.33", "@types/react-dom": "^18.2.14", "@types/uuid": "^9.0.6", + "@typescript-eslint/eslint-plugin": "^6.9.1", + "@typescript-eslint/parser": "^6.9.1", "prisma": "^5.4.2", "typescript": "^5.2.2" } @@ -450,6 +452,12 @@ "@types/react": "*" } }, + "node_modules/@types/json-schema": { + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.14.tgz", + "integrity": "sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -496,21 +504,62 @@ "integrity": "sha512-s/FPdYRmZR8SjLWGMCuax7r3qCWQw9QKHzXVukAuuIJkXkDRwp+Pu5LMIVFi0Fxbav35WURicYr8u1QsoybnQw==", "dev": true }, + "node_modules/@types/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==", + "dev": true + }, "node_modules/@types/uuid": { "version": "9.0.6", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==", "dev": true }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.1.tgz", + "integrity": "sha512-w0tiiRc9I4S5XSXXrMHOWgHgxbrBn1Ro+PmiYhSg2ZVdxrAJtQgzU5o2m1BfP6UOn7Vxcc6152vFjQfmZR4xEg==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/type-utils": "6.9.1", + "@typescript-eslint/utils": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@typescript-eslint/parser": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.1.tgz", - "integrity": "sha512-610G6KHymg9V7EqOaNBMtD1GgpAmGROsmfHJPXNLCU9bfIuLrkdOygltK784F6Crboyd5tBFayPB7Sf0McrQwg==", - "dependencies": { - "@typescript-eslint/scope-manager": "6.4.1", - "@typescript-eslint/types": "6.4.1", - "@typescript-eslint/typescript-estree": "6.4.1", - "@typescript-eslint/visitor-keys": "6.4.1", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.1.tgz", + "integrity": "sha512-C7AK2wn43GSaCUZ9do6Ksgi2g3mwFkMO3Cis96kzmgudoVaKyt62yNzJOktP0HDLb/iO2O0n2lBOzJgr6Q/cyg==", + "dependencies": { + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4" }, "engines": { @@ -530,12 +579,31 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.4.1.tgz", - "integrity": "sha512-p/OavqOQfm4/Hdrr7kvacOSFjwQ2rrDVJRPxt/o0TOWdFnjJptnjnZ+sYDR7fi4OimvIuKp+2LCkc+rt9fIW+A==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", + "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", + "dependencies": { + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.1.tgz", + "integrity": "sha512-eh2oHaUKCK58qIeYp19F5V5TbpM52680sB4zNSz29VBQPTWIlE/hCj5P5B1AChxECe/fmZlspAWFuRniep1Skg==", + "dev": true, "dependencies": { - "@typescript-eslint/types": "6.4.1", - "@typescript-eslint/visitor-keys": "6.4.1" + "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/utils": "6.9.1", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -543,12 +611,20 @@ "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, "node_modules/@typescript-eslint/types": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.4.1.tgz", - "integrity": "sha512-zAAopbNuYu++ijY1GV2ylCsQsi3B8QvfPHVqhGdDcbx/NK5lkqMnCGU53amAjccSpk+LfeONxwzUhDzArSfZJg==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", + "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", "engines": { "node": "^16.0.0 || >=18.0.0" }, @@ -558,12 +634,12 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.4.1.tgz", - "integrity": "sha512-xF6Y7SatVE/OyV93h1xGgfOkHr2iXuo8ip0gbfzaKeGGuKiAnzS+HtVhSPx8Www243bwlW8IF7X0/B62SzFftg==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", + "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", "dependencies": { - "@typescript-eslint/types": "6.4.1", - "@typescript-eslint/visitor-keys": "6.4.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -583,12 +659,37 @@ } } }, + "node_modules/@typescript-eslint/utils": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.1.tgz", + "integrity": "sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.4.1.tgz", - "integrity": "sha512-y/TyRJsbZPkJIZQXrHfdnxVnxyKegnpEvnRGNam7s3TRR2ykGefEWOhaef00/UUN3IZxizS7BTO3svd3lCOJRQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", + "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", "dependencies": { - "@typescript-eslint/types": "6.4.1", + "@typescript-eslint/types": "6.9.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { diff --git a/package.json b/package.json index 50e8bc4a6..466ae0fe8 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,8 @@ "@types/react": "^18.2.33", "@types/react-dom": "^18.2.14", "@types/uuid": "^9.0.6", + "@typescript-eslint/eslint-plugin": "^6.9.1", + "@typescript-eslint/parser": "^6.9.1", "prisma": "^5.4.2", "typescript": "^5.2.2" } diff --git a/src/app/(auth)/CsrfToken.tsx b/src/app/(auth)/CsrfToken.tsx index 4f08fefb6..df591ada7 100644 --- a/src/app/(auth)/CsrfToken.tsx +++ b/src/app/(auth)/CsrfToken.tsx @@ -1,6 +1,6 @@ -"use client" +'use client' -import { getCsrfToken } from "next-auth/react" +import { getCsrfToken } from 'next-auth/react' async function CsrfToken() { // getCsrfToken må kjøres på klientsiden* @@ -15,4 +15,4 @@ async function CsrfToken() { ) } -export default CsrfToken \ No newline at end of file +export default CsrfToken diff --git a/src/app/(auth)/login/page.tsx b/src/app/(auth)/login/page.tsx index 6538e158e..afd282bba 100644 --- a/src/app/(auth)/login/page.tsx +++ b/src/app/(auth)/login/page.tsx @@ -1,25 +1,25 @@ import FormInput from '@/components/FormInput/FormInput' import styles from './page.module.scss' -import magiskHatt from "@/images/magisk_hatt.png" +import magiskHatt from '@/images/magisk_hatt.png' import Image from 'next/image' import PrimaryButton from '@/components/PrimaryButton/PrimaryButton' import CsrfToken from '../CsrfToken' export default async function LogIn() { - return ( -
-
-
- - - + return ( +
+
+ + + + - - -
- en kappemann sin hatt + + +
+ en kappemann sin hatt +
-
- ) -} \ No newline at end of file + ) +} diff --git a/src/app/(auth)/logout/page.tsx b/src/app/(auth)/logout/page.tsx index ec1fc79b8..f5204fe8a 100644 --- a/src/app/(auth)/logout/page.tsx +++ b/src/app/(auth)/logout/page.tsx @@ -1,25 +1,21 @@ -import { getCsrfToken } from "next-auth/react" - import styles from './page.module.scss' -import magiskHatt from "@/images/magisk_hatt.png" +import magiskHatt from '@/images/magisk_hatt.png' import Image from 'next/image' import PrimaryButton from '@/components/PrimaryButton/PrimaryButton' import CsrfToken from '../CsrfToken' export default async function LogOut() { - const csrfToken = await getCsrfToken() - - return ( -
-
-
- - - -
- en kappemann sin hatt + return ( +
+
+
+ + + +
+ en kappemann sin hatt +
-
- ) -} \ No newline at end of file + ) +} diff --git a/src/app/(home)/InfoBubbles.tsx b/src/app/(home)/InfoBubbles.tsx index 1490cbf7b..5d77e2b08 100644 --- a/src/app/(home)/InfoBubbles.tsx +++ b/src/app/(home)/InfoBubbles.tsx @@ -1,4 +1,4 @@ -import styles from './InfoBubbles.module.scss'; +import styles from './InfoBubbles.module.scss' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faCircle, @@ -8,43 +8,44 @@ import { } from '@fortawesome/free-solid-svg-icons' function InfoBubbles() { - return ( -
-
-
- - -
-
Sosialt
-
- Sct. Omega Broderskaps mål er å skape et fargerikt sosialt liv for studenter + return ( +
+
+
+ + +
+
Sosialt
+
+ Sct. Omega Broderskaps mål er å skape et fargerikt sosialt liv for studenter ved studiene for Elektronisk Systemdesign og Innovasjon, og Kybernetikk og Robotikk. +
-
-
-
- - -
-
Komitéer
-
- Linjeforeningen består av 17 komitéer som alle inkluderer studenter på et bredt spekter, +
+
+ + +
+
Komitéer
+
+ Linjeforeningen består av 17 komitéer som alle inkluderer + studenter på et bredt spekter, med alt fra revy til store fester som Phaestum Immatricularis. +
-
-
-
- - -
-
Næringsliv
-
- Omega har kontakt med mange bedrifter og jobber kontinuerlig med å skape +
+
+ + +
+
Næringsliv
+
+ Omega har kontakt med mange bedrifter og jobber kontinuerlig med å skape et godt forhold mellom studenten og en fremtidig arbeidsplass. +
-
- ) + ) } -export default InfoBubbles \ No newline at end of file +export default InfoBubbles diff --git a/src/app/(home)/Section.tsx b/src/app/(home)/Section.tsx index 90423420b..fe5773639 100644 --- a/src/app/(home)/Section.tsx +++ b/src/app/(home)/Section.tsx @@ -1,3 +1,4 @@ +import React from 'react' import Image, { StaticImageData } from 'next/image' import Link from 'next/link' import styles from './Section.module.scss' @@ -12,15 +13,15 @@ type PropTypes = { id?: string, } -function Section({children, img, name, lesMer, right, imgWidth, id}: PropTypes) { - const alt = "image of " + name +function Section({ children, img, name, lesMer, right, imgWidth, id }: PropTypes) { + const alt = `image of ${name}` const imgContainer = ( -
- + {alt} + />
) return ( @@ -38,4 +39,4 @@ function Section({children, img, name, lesMer, right, imgWidth, id}: PropTypes) ) } -export default Section \ No newline at end of file +export default Section diff --git a/src/app/(home)/page.tsx b/src/app/(home)/page.tsx index 122322fce..cbc92b42e 100644 --- a/src/app/(home)/page.tsx +++ b/src/app/(home)/page.tsx @@ -16,62 +16,66 @@ import GoogleMap from '@/components/GoogleMap/GoogleMap' import YouTube from '@/components/YouTube/YouTube' export default function Home() { - return ( -
-
-
-
- omega logo - Logg inn - Ny student -
- -
- - - -
-
-
- Sct. Omega Broderskab ble offisielt stiftet 21. november 1919 av et kull elektrostudenter - som må ha hatt et svært godt kameratskap og sosialt miljø. Til å begynne med var det en - eksklusiv klubb forbeholdt 3. og 4. årskurs, og for å bli tatt opp måtte man sende inn - en fyldig søknad. Dette har endret seg gjennom årene, og i dag blir medlemmene tatt + return ( +
+
+
+
+ omega logo + Logg inn + Ny student +
+ +
+ + + +
+
+
+ Sct. Omega Broderskab ble offisielt stiftet 21. november 1919 av et kull elektrostudenter + som må ha hatt et svært godt kameratskap og sosialt miljø. Til å begynne med var det en + eksklusiv klubb forbeholdt 3. og 4. årskurs, og for å bli tatt opp måtte man sende inn + en fyldig søknad. Dette har endret seg gjennom årene, og i dag blir medlemmene tatt opp automatisk fra 1. klasse. -
- -
- Omega Verksted er en forening for elektronikk- og hobbyinteresserte studenter ved - Norges Teknisk-Naturvitenskapelige Universitet (NTNU) stiftet i 1971. Omega Verksted holder - til i kjelleren i det gamle elektrobygget på Gløshaugen (G 016 A). Verkstedet inneholder - det meste av verktøy for små og store prosjekter, i tillegg til et knippe +
+ +
+ Omega Verksted er en forening for elektronikk- og hobbyinteresserte studenter ved + Norges Teknisk-Naturvitenskapelige + Universitet (NTNU) stiftet i 1971. Omega Verksted holder + til i kjelleren i det gamle elektrobygget på Gløshaugen (G 016 A). + Verkstedet inneholder + det meste av verktøy for små og store prosjekter, i tillegg til et knippe datamaskiner samt et solid utvalg av brus og sjokolade. -
-
-
-
- -
+
+
+
+
+ +
Altså omega er helt fantastisk for bedrifter.... tro meg 100%. Bare å ta kontakt med contactor ellerno... Lorem ipsium bla lofrgin fofkewivj irjvioer firegjoireg g jfirejgergo rjgijgoieg jgirejgioe geroigjkoiegoekg kogkpeogkg rgierg -
-
+
+
Ohma Electra er Omega sin stolthet, og hennes historie strekker seg helt tilbake til 1908. - Ohma er verdens første(!) fungerende vekselstrøm-lokomotiv, og har en lang historie fra både - gruvedrift, sabotasje under 2. verdenskrig, og som glamourmodell på utsiden av elektrobygget. - Det er ingen hemmelighet at Ohma er det fineste lokomotivet i hele Norge, og hvis du er + Ohma er verdens første(!) fungerende + vekselstrøm-lokomotiv, og har en lang historie fra både + gruvedrift, sabotasje under 2. verdenskrig, og som + glamourmodell på utsiden av elektrobygget. + Det er ingen hemmelighet at Ohma er det fineste lokomotivet i hele Norge, og hvis du er heldig får du kanskje bli med på en kjøretur. -
-
-
-
- -
-
- ) +
+
+
+
+ +
+
+ ) } diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts index 629b898d8..9c9ac1175 100644 --- a/src/app/api/auth/[...nextauth]/route.ts +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -1,6 +1,6 @@ -import NextAuth from "next-auth" +import NextAuth from 'next-auth' import authOptions from '@/auth' const handler = NextAuth(authOptions) -export { handler as GET, handler as POST } \ No newline at end of file +export { handler as GET, handler as POST } diff --git a/src/app/api/users/[id]/route.ts b/src/app/api/users/[id]/route.ts index 785691139..31a0c7006 100644 --- a/src/app/api/users/[id]/route.ts +++ b/src/app/api/users/[id]/route.ts @@ -1,5 +1,5 @@ -import prisma from "@/prisma" -import { NextRequest, NextResponse } from "next/server" +import prisma from '@/prisma' +import { NextRequest, NextResponse } from 'next/server' type ParamType = { params: { @@ -13,8 +13,10 @@ export async function GET(request: NextRequest, { params }: ParamType) { id: Number(params.id) } }) - if (!user) return new NextResponse("user not found", { - status: 404, - }) + if (!user) { + return new NextResponse('user not found', { + status: 404, + }) + } return NextResponse.json(user) -} \ No newline at end of file +} diff --git a/src/app/api/users/route.ts b/src/app/api/users/route.ts index 61a22a028..143f0705d 100644 --- a/src/app/api/users/route.ts +++ b/src/app/api/users/route.ts @@ -1,6 +1,6 @@ import { Prisma } from '@prisma/client' -import prisma from "@/prisma" +import prisma from '@/prisma' import { NextRequest, NextResponse } from 'next/server' export async function GET() { @@ -9,11 +9,11 @@ export async function GET() { return NextResponse.json(users) } -export async function POST(req: NextRequest) { +export async function POST(req: NextRequest) { const body = await req.json() - - const { username, password, email, firstname, lastname } = body; - + + const { username, password, email, firstname, lastname } = body + if (!username || !password || !email || !firstname || !lastname) { return NextResponse.json({}, { status: 400 }) } @@ -21,25 +21,24 @@ export async function POST(req: NextRequest) { try { const user = await prisma.user.create({ data: { - username: username, - email: email, - password: password, - firstname: firstname, - lastname: lastname + username, + email, + password, + firstname, + lastname, } }) return NextResponse.json(user) - } catch (error) { + } catch (error) { // synes dette er en veldig stygg måte å håndtere feil på if ( error instanceof Prisma.PrismaClientKnownRequestError && error.code === 'P2002' - ) - { + ) { return NextResponse.json({}, { status: 409 }) - } - + } + return NextResponse.json({}, { status: 500 }) - } -} \ No newline at end of file + } +} diff --git a/src/app/components/Checkbox/Checkbox.tsx b/src/app/components/Checkbox/Checkbox.tsx index bb35af206..e5342c2cd 100644 --- a/src/app/components/Checkbox/Checkbox.tsx +++ b/src/app/components/Checkbox/Checkbox.tsx @@ -1,12 +1,12 @@ import { v4 as uuid } from 'uuid' -import styles from "./Checkbox.module.scss"; +import styles from './Checkbox.module.scss' type PropTypes = { label: string } function Checkbox({ label }: PropTypes) { - const id = "id_input_" + uuid(); + const id = `id_input_${uuid()}` return
@@ -14,4 +14,4 @@ function Checkbox({ label }: PropTypes) {
} -export default Checkbox \ No newline at end of file +export default Checkbox diff --git a/src/app/components/Footer/Footer.tsx b/src/app/components/Footer/Footer.tsx index 7a6274cfe..1e8ab28c4 100644 --- a/src/app/components/Footer/Footer.tsx +++ b/src/app/components/Footer/Footer.tsx @@ -9,45 +9,46 @@ import logo from '@/images/omega_logo_white.png' import nordic from '@/images/nordic.png' function Footer() { - return ( -
-
- sct. omega broderskab -

- Linjeforeningen for Elektronisk Systemdesign og Innovasjon (MTELSYS) og Kybernetikk og - Robotikk (MTTK) ved Norges Tekniske-Naturvitenskapelige Universitet (NTNU) -

-
- - add to homescreen - -
- + return ( +
+
+ sct. omega broderskab +

+ Linjeforeningen for Elektronisk Systemdesign + og Innovasjon (MTELSYS) og Kybernetikk og + Robotikk (MTTK) ved Norges Tekniske-Naturvitenskapelige Universitet (NTNU) +

+
+ + add to homescreen + +
+ +
+
-
-
-
-

Kontakt:

-

Bedrift: post@contactor.no

-

Teknisk: vevcom@omega.ntnu.no

-

PR: blaest@omega.ntnu.no

-

Annet: hs@omega.ntnu.no

-

Tlf: 73 59 42 11

-
-
-

Adresse:

-

Sct.Omega Broderskab

-

NTNU Gløshaugen

-

Elektro-bygget

-

7491 Trondheim

-
-
- - nordic logo - -
-
- ) +
+

Kontakt:

+

Bedrift: post@contactor.no

+

Teknisk: vevcom@omega.ntnu.no

+

PR: blaest@omega.ntnu.no

+

Annet: hs@omega.ntnu.no

+

Tlf: 73 59 42 11

+
+
+

Adresse:

+

Sct.Omega Broderskab

+

NTNU Gløshaugen

+

Elektro-bygget

+

7491 Trondheim

+
+
+ + nordic logo + +
+ + ) } -export default Footer \ No newline at end of file +export default Footer diff --git a/src/app/components/FormInput/FormInput.tsx b/src/app/components/FormInput/FormInput.tsx index d95fa712b..d11c55123 100644 --- a/src/app/components/FormInput/FormInput.tsx +++ b/src/app/components/FormInput/FormInput.tsx @@ -1,5 +1,5 @@ import { v4 as uuid } from 'uuid' -import styles from "./FormInput.module.scss" +import styles from './FormInput.module.scss' type PropTypes = { label?: string, @@ -8,16 +8,15 @@ type PropTypes = { name: string, } -function FormInput({label, type, id, name} : PropTypes) { - label ??= '' - type ??= (type !== undefined) ? type : 'text' - id ??= "id_input_" + uuid() +function FormInput({ label, type, id, name } : PropTypes) { + label ??= '' + type ??= (type !== undefined) ? type : 'text' + id ??= `id_input_${uuid()}` return
- } -export default FormInput \ No newline at end of file +export default FormInput diff --git a/src/app/components/GoogleMap/GoogleMap.tsx b/src/app/components/GoogleMap/GoogleMap.tsx index 4af943509..b8384ccba 100644 --- a/src/app/components/GoogleMap/GoogleMap.tsx +++ b/src/app/components/GoogleMap/GoogleMap.tsx @@ -1,7 +1,7 @@ 'use client' import styles from './GoogleMap.module.scss' -import GoogleMapReact from "google-map-react"; -import { Coords } from 'google-map-react'; +import GoogleMapReact from 'google-map-react' +import { Coords } from 'google-map-react' type PropTypes = { location: Coords, @@ -10,14 +10,14 @@ type PropTypes = { function GoogleMap({ location, height } : PropTypes) { return ( -
- +
) } -export default GoogleMap; \ No newline at end of file +export default GoogleMap diff --git a/src/app/components/Loader/Loader.tsx b/src/app/components/Loader/Loader.tsx index 79f12c363..1c5a4e2b7 100644 --- a/src/app/components/Loader/Loader.tsx +++ b/src/app/components/Loader/Loader.tsx @@ -5,9 +5,9 @@ import Image from 'next/image' function Loader() { return (
- omega-logo + omega-logo
) } -export default Loader \ No newline at end of file +export default Loader diff --git a/src/app/components/NavBar/BurgerItem.tsx b/src/app/components/NavBar/BurgerItem.tsx index 03c4d7bf7..c21be2752 100644 --- a/src/app/components/NavBar/BurgerItem.tsx +++ b/src/app/components/NavBar/BurgerItem.tsx @@ -11,7 +11,7 @@ type PropTypes = { } function BurgerItem({ href, name, icon, shortName } : PropTypes) { - shortName ??= name; + shortName ??= name return ( @@ -21,4 +21,4 @@ function BurgerItem({ href, name, icon, shortName } : PropTypes) { ) } -export default BurgerItem \ No newline at end of file +export default BurgerItem diff --git a/src/app/components/NavBar/BurgerMenu.tsx b/src/app/components/NavBar/BurgerMenu.tsx index ba3f4c987..ddefe49e2 100644 --- a/src/app/components/NavBar/BurgerMenu.tsx +++ b/src/app/components/NavBar/BurgerMenu.tsx @@ -14,7 +14,7 @@ import { faQuestionCircle, faAddressCard, faGraduationCap, -} from "@fortawesome/free-solid-svg-icons" +} from '@fortawesome/free-solid-svg-icons' import styles from './BurgerMenu.module.scss' @@ -33,7 +33,7 @@ function BurgerMenu({ isLoggedIn, applicationPeriod }:PropTypes) { {!isLoggedIn && } - {isLoggedIn && + {isLoggedIn && <> @@ -52,4 +52,4 @@ function BurgerMenu({ isLoggedIn, applicationPeriod }:PropTypes) { ) } -export default BurgerMenu \ No newline at end of file +export default BurgerMenu diff --git a/src/app/components/NavBar/Dropdown.tsx b/src/app/components/NavBar/Dropdown.tsx index 1686fa3a4..909ffac5e 100644 --- a/src/app/components/NavBar/Dropdown.tsx +++ b/src/app/components/NavBar/Dropdown.tsx @@ -1,8 +1,8 @@ -import Link from "next/link" -import styles from "./Dropdown.module.scss" +import Link from 'next/link' +import styles from './Dropdown.module.scss' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { v4 as uuid } from 'uuid' -import { IconProp } from "@fortawesome/fontawesome-svg-core" +import { IconProp } from '@fortawesome/fontawesome-svg-core' type PropTypes = { name: string, @@ -18,10 +18,10 @@ function DropDown({ name, items } : PropTypes) {
  • { name }
    - {items.map(item => + {items.map(item =>
    - - + +

    {item.name}

    @@ -31,4 +31,4 @@ function DropDown({ name, items } : PropTypes) { ) } -export default DropDown \ No newline at end of file +export default DropDown diff --git a/src/app/components/NavBar/Item.tsx b/src/app/components/NavBar/Item.tsx index ac76cbdb8..fa1c96f14 100644 --- a/src/app/components/NavBar/Item.tsx +++ b/src/app/components/NavBar/Item.tsx @@ -1,5 +1,5 @@ -import Link from "next/link" -import styles from "./Item.module.scss" +import Link from 'next/link' +import styles from './Item.module.scss' type PropTypes = { href: string, @@ -16,4 +16,4 @@ function Item({ href, name }: PropTypes) { ) } -export default Item \ No newline at end of file +export default Item diff --git a/src/app/components/NavBar/MobileNavBar.tsx b/src/app/components/NavBar/MobileNavBar.tsx index ab5f102aa..6a158a4aa 100644 --- a/src/app/components/NavBar/MobileNavBar.tsx +++ b/src/app/components/NavBar/MobileNavBar.tsx @@ -1,4 +1,4 @@ -"use client" +'use client' import Image from 'next/image' import Link from 'next/link' import BurgerMenu from './BurgerMenu' @@ -11,9 +11,9 @@ import { faNewspaper, faSuitcase, faCalendar -} from "@fortawesome/free-solid-svg-icons" +} from '@fortawesome/free-solid-svg-icons' import styles from './MobileNavBar.module.scss' -import { Session } from "next-auth" +import { Session } from 'next-auth' type PropTypes = { session: Session | null @@ -22,20 +22,20 @@ type PropTypes = { function MobileNavBar({ session } : PropTypes) { const [burgerOpen, setBurgerOpen] = useState(false) - const isLoggedIn = Boolean(session?.user); + const isLoggedIn = Boolean(session?.user) const applicationPeriod = true return ( ) } -export default MobileNavBar \ No newline at end of file +export default MobileNavBar diff --git a/src/app/components/NavBar/NavBar.tsx b/src/app/components/NavBar/NavBar.tsx index 9b61ad1f0..b62dc374a 100644 --- a/src/app/components/NavBar/NavBar.tsx +++ b/src/app/components/NavBar/NavBar.tsx @@ -1,10 +1,10 @@ -import Image from "next/image" -import Link from "next/link" -import Item from "./Item" -import DropDown from "./Dropdown" -import magiskHatt from "@/images/magisk_hatt.png" -import simpleLogo from "@/images/logo_simple.png" -import styles from "./NavBar.module.scss" +import Image from 'next/image' +import Link from 'next/link' +import Item from './Item' +import DropDown from './Dropdown' +import magiskHatt from '@/images/magisk_hatt.png' +import simpleLogo from '@/images/logo_simple.png' +import styles from './NavBar.module.scss' import { faNewspaper, faPoo, @@ -17,15 +17,14 @@ import { faUsers, faCircleInfo, faGamepad -} from "@fortawesome/free-solid-svg-icons" -import { Session } from "next-auth" +} from '@fortawesome/free-solid-svg-icons' +import { Session } from 'next-auth' type PropTypes = { session: Session | null } -async function NavBar({session}: PropTypes) { - +async function NavBar({ session }: PropTypes) { const isLoggedIn = Boolean(session?.user) const applicationPeriod = false @@ -34,7 +33,7 @@ async function NavBar({session}: PropTypes) {
    • - omega logo
    • {isLoggedIn && } - {!isLoggedIn && } - - {!isLoggedIn && + {!isLoggedIn && } + + {!isLoggedIn && <> - - + + } - {isLoggedIn && + {isLoggedIn && <> - - {applicationPeriod && - + + {applicationPeriod && + } }
    • - + log in button
    • @@ -125,4 +124,4 @@ async function NavBar({session}: PropTypes) { } -export default NavBar \ No newline at end of file +export default NavBar diff --git a/src/app/components/PrimaryButton/PrimaryButton.tsx b/src/app/components/PrimaryButton/PrimaryButton.tsx index 6d8bffeef..6f05be4eb 100644 --- a/src/app/components/PrimaryButton/PrimaryButton.tsx +++ b/src/app/components/PrimaryButton/PrimaryButton.tsx @@ -1,11 +1,10 @@ -import styles from "./PrimaryButton.module.scss" +import styles from './PrimaryButton.module.scss' type PropTypes = { text: string, } function PrimaryButton({ text }:PropTypes) { - return } -export default PrimaryButton \ No newline at end of file +export default PrimaryButton diff --git a/src/app/components/SocialIcons/SocialIcons.tsx b/src/app/components/SocialIcons/SocialIcons.tsx index 74c5ee56f..c96980577 100644 --- a/src/app/components/SocialIcons/SocialIcons.tsx +++ b/src/app/components/SocialIcons/SocialIcons.tsx @@ -1,15 +1,14 @@ -import styles from './SocialIcons.module.scss' import Link from 'next/link' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { - faXTwitter, - faFacebookSquare, - faInstagram + faXTwitter, + faFacebookSquare, + faInstagram } from '@fortawesome/free-brands-svg-icons' function SocialIcons() { - return ( + return ( <> @@ -21,7 +20,7 @@ function SocialIcons() { - ) + ) } -export default SocialIcons \ No newline at end of file +export default SocialIcons diff --git a/src/app/components/YouTube/YouTube.tsx b/src/app/components/YouTube/YouTube.tsx index b17b78bf5..e853d3292 100644 --- a/src/app/components/YouTube/YouTube.tsx +++ b/src/app/components/YouTube/YouTube.tsx @@ -4,11 +4,10 @@ type PropTypes = { src: string, } -function YouTube({src}: PropTypes) { - - return ( - - ) +function YouTube({ src }: PropTypes) { + return ( + + ) } -export default YouTube \ No newline at end of file +export default YouTube diff --git a/src/app/events/page.tsx b/src/app/events/page.tsx index c265f71e3..b1ab5d905 100644 --- a/src/app/events/page.tsx +++ b/src/app/events/page.tsx @@ -49,4 +49,4 @@ export default function Events() { projectnextiejiejiwjfijwfoekfoewkfowkefokewf
    ) -} \ No newline at end of file +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index fe1c7c625..890783d3d 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,5 +1,5 @@ import { Inter } from 'next/font/google' - +import React from 'react' import MobileNavBar from '@/components/NavBar/MobileNavBar' import NavBar from '@/components/NavBar/NavBar' import Footer from '@/components/Footer/Footer' @@ -18,32 +18,32 @@ config.autoAddCss = false const inter = Inter({ subsets: ['latin'] }) export const metadata = { - title: 'projectnext', - description: '', - charset: 'utf-8', + title: 'projectnext', + description: '', + charset: 'utf-8', } export default async function RootLayout({ children } : { children: React.ReactNode}) { - const session = await getServerSession(authOptions) - - return ( - - -
    -
    - -
    -
    - {children} -
    -
    -
    -
    -
    - -
    -
    - - - ) + const session = await getServerSession(authOptions) + + return ( + + +
    +
    + +
    +
    + {children} +
    +
    +
    +
    +
    + +
    +
    + + + ) } diff --git a/src/app/loading.tsx b/src/app/loading.tsx index cf1bbdf68..15e8c93e3 100644 --- a/src/app/loading.tsx +++ b/src/app/loading.tsx @@ -2,4 +2,4 @@ export default function loading() { return ( <>Loading ) -} \ No newline at end of file +} diff --git a/src/app/users/[username]/page.tsx b/src/app/users/[username]/page.tsx index e9e7fa7d2..b49166400 100644 --- a/src/app/users/[username]/page.tsx +++ b/src/app/users/[username]/page.tsx @@ -1,10 +1,10 @@ import { redirect } from 'next/navigation' -import { getServerSession } from "next-auth"; +import { getServerSession } from 'next-auth' -import authOptions from '@/auth'; +import authOptions from '@/auth' -import prisma from "@/prisma" -import Link from 'next/link'; +import prisma from '@/prisma' +import Link from 'next/link' type PropTypes = { params: { @@ -22,12 +22,12 @@ async function AuthTest({ params }: PropTypes) { redirect('/login') } - const me = params.username === "me" - let username = me ? session.user.username : params.username + const me = params.username === 'me' + const username = me ? session.user.username : params.username const user = await prisma.user.findUnique({ where: { - username: username + username } }) @@ -44,4 +44,4 @@ async function AuthTest({ params }: PropTypes) { ) } -export default AuthTest \ No newline at end of file +export default AuthTest diff --git a/src/auth/index.ts b/src/auth/index.ts index 288e241ce..cde4bbcd0 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -1,17 +1,17 @@ -import CredentialsProvider from "next-auth/providers/credentials" -import { AuthOptions, User } from "next-auth" +import CredentialsProvider from 'next-auth/providers/credentials' +import { AuthOptions } from 'next-auth' -import prisma from "@/prisma" +import prisma from '@/prisma' const authOptions : AuthOptions = { providers: [ CredentialsProvider({ - name: "Credentials", + name: 'Credentials', credentials: { - username: { label: "Username", type: "text" }, - password: { label: "Password", type: "password" } + username: { label: 'Username', type: 'text' }, + password: { label: 'Password', type: 'password' } }, - authorize: async (credentials, req) => { + authorize: async (credentials) => { const user = await prisma.user.findUnique({ where: { username: credentials?.username @@ -19,33 +19,40 @@ const authOptions : AuthOptions = { }) // TODO - faktisk gjør encryption, legg til hashing på POST if (user?.password === credentials?.password) { - if (typeof user?.id == 'number') { - return {...user} + if (typeof user?.id === 'number') { + return { ...user } } } return null } - }) + }) ], session: { - strategy: "jwt" + strategy: 'jwt' }, callbacks: { async session({ session, token }) { - session.user = token.user; - return session; + session.user = token.user + return session }, async jwt({ token, user }) { - if (user) { - token.user = user + if (typeof user?.id === 'number' && user?.email) { + token.user = { + id: user.id, + username: user.username, + email: user.email, + password: user.password, + firstname: user.firstname, + lastname: user.lastname + } } - return token; + return token }, }, pages: { signIn: '/login', - signOut: '/logout' + signOut: '/logout' } } -export default authOptions \ No newline at end of file +export default authOptions diff --git a/src/prisma/index.ts b/src/prisma/index.ts index d15e73d87..dda84f8cb 100644 --- a/src/prisma/index.ts +++ b/src/prisma/index.ts @@ -2,6 +2,6 @@ import { PrismaClient } from '@prisma/client' const prisma = global.prisma || new PrismaClient() -if (process.env.NODE_ENV !== "production") global.prisma = prisma +if (process.env.NODE_ENV !== 'production') global.prisma = prisma -export default prisma \ No newline at end of file +export default prisma diff --git a/src/prisma/seed.ts b/src/prisma/seed.ts index 5a61df1a7..65d96b0e6 100644 --- a/src/prisma/seed.ts +++ b/src/prisma/seed.ts @@ -1,29 +1,29 @@ import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() -console.log("seed starting...") +console.log('seed starting...') async function main() { - const harambe = await prisma.user.upsert({ - where: { - email: 'harambe@harambesen.io' - }, - update: { + const harambe = await prisma.user.upsert({ + where: { + email: 'harambe@harambesen.io' + }, + update: { - }, - create: { - firstname: 'Harambe', - lastname: 'Harambesen', - email: 'harambe@harambesen.io', - password: 'password', - username: 'Harambe104', - }, - }) - console.log({ harambe }) + }, + create: { + firstname: 'Harambe', + lastname: 'Harambesen', + email: 'harambe@harambesen.io', + password: 'password', + username: 'Harambe104', + }, + }) + console.log({ harambe }) } main().then(async () => { await prisma.$disconnect() }).catch(async (e) => { console.error(e) await prisma.$disconnect() - process.exit(1) -}) \ No newline at end of file + throw Error('seeding failed.... container closing') +}) diff --git a/src/typings/global.d.ts b/src/typings/global.d.ts index 8f6fcabb1..e8304a157 100644 --- a/src/typings/global.d.ts +++ b/src/typings/global.d.ts @@ -1,6 +1,7 @@ -import { Prisma, PrismaClient } from "@prisma/client"; -import { DefaultArgs } from "@prisma/client/runtime/library"; +import { Prisma, PrismaClient } from '@prisma/client' +import { DefaultArgs } from '@prisma/client/runtime/library' declare global { + // eslint-disable-next-line no-var var prisma: PrismaClient -} \ No newline at end of file +} diff --git a/src/typings/next-auth.d.ts b/src/typings/next-auth.d.ts index 9c28dd072..7f67391f4 100644 --- a/src/typings/next-auth.d.ts +++ b/src/typings/next-auth.d.ts @@ -1,17 +1,17 @@ -import type { User as prismaUser } from "@prisma/client" +import type { User as prismaUser } from '@prisma/client' import 'next-auth' +import 'next-auth/adapters' -declare module "next-auth" { +declare module 'next-auth' { interface User extends prismaUser {id: number} interface Session { user: prismaUser; } } - -declare module "next-auth/jwt" { +declare module 'next-auth/jwt' { interface JWT { - user: User + user: prismaUser } }