diff --git a/src/routes/settings/admin/+page.server.ts b/src/routes/settings/admin/+page.server.ts
index 3a2a8cb..3518fd1 100644
--- a/src/routes/settings/admin/+page.server.ts
+++ b/src/routes/settings/admin/+page.server.ts
@@ -98,6 +98,13 @@ export const actions: Actions = {
const formData = await event.request.formData();
const formUsername = formData.get("username");
let username = formUsername?.toString().toLocaleLowerCase();
+ let role = formData.get("role");
+ if (!role) {
+ role = "user";
+ } else {
+ role = "admin";
+ }
+ console.log("role", role);
if (typeof formUsername !== "string") {
return fail(400, { message: "Invalid username" });
@@ -187,18 +194,11 @@ export const actions: Actions = {
last_name: lastName,
hashed_password: hashedPassword,
signup_date: new Date(),
- role: "admin",
+ role: role,
last_login: new Date(),
} as DatabaseUser)
.execute();
- const session = await lucia.createSession(userId, {});
- const sessionCookie = lucia.createSessionCookie(session.id);
- event.cookies.set(sessionCookie.name, sessionCookie.value, {
- path: ".",
- ...sessionCookie.attributes,
- });
-
return { success: true };
},
};
diff --git a/src/routes/worldtravel/[countrycode]/+page.server.ts b/src/routes/worldtravel/[countrycode]/+page.server.ts
index da4a840..27425fc 100644
--- a/src/routes/worldtravel/[countrycode]/+page.server.ts
+++ b/src/routes/worldtravel/[countrycode]/+page.server.ts
@@ -1,20 +1,29 @@
-import { db } from '$lib/db/db.server.js';
-import { userVisitedWorldTravel, worldTravelCountryRegions } from '$lib/db/schema.js';
-import { and, eq } from 'drizzle-orm';
-import type { PageServerLoad } from './$types';
-
-export const load: PageServerLoad = async ({ params, locals }) => {
+import { db } from "$lib/db/db.server.js";
+import {
+ userVisitedWorldTravel,
+ worldTravelCountries,
+ worldTravelCountryRegions,
+} from "$lib/db/schema.js";
+import { and, eq } from "drizzle-orm";
+import type { PageServerLoad } from "./$types";
+export const load: PageServerLoad = async ({ params, locals }) => {
const { countrycode } = params;
- let data = await db
+ let data = await db
.select()
.from(worldTravelCountryRegions)
- .where(eq(worldTravelCountryRegions.country_code, countrycode))
+ .where(eq(worldTravelCountryRegions.country_code, countrycode));
- let visitedRegions: { id: number; userId: string; region_id: string; }[] = [];
- if (locals.user) {
- let countryCode = params.countrycode
- visitedRegions = await db
+ let countryName = await db
+ .select()
+ .from(worldTravelCountries)
+ .where(eq(worldTravelCountries.country_code, countrycode))
+ .execute();
+
+ let visitedRegions: { id: number; userId: string; region_id: string }[] = [];
+ if (locals.user) {
+ let countryCode = params.countrycode;
+ visitedRegions = await db
.select()
.from(userVisitedWorldTravel)
.where(
@@ -24,11 +33,12 @@ export const load: PageServerLoad = async ({ params, locals }) => {
)
)
.execute();
- }
+ }
return {
- regions : data,
- countrycode: countrycode,
- visitedRegions: visitedRegions,
+ regions: data,
+ countrycode: countrycode,
+ visitedRegions: visitedRegions,
+ countryName: countryName[0].name,
};
-}
\ No newline at end of file
+};
diff --git a/src/routes/worldtravel/[countrycode]/+page.svelte b/src/routes/worldtravel/[countrycode]/+page.svelte
index c54c10b..941b10a 100644
--- a/src/routes/worldtravel/[countrycode]/+page.svelte
+++ b/src/routes/worldtravel/[countrycode]/+page.svelte
@@ -1,7 +1,6 @@
- Regions in {countryCodeToName(data.countrycode)}
+ Regions in {data.countryName}
- {countryCodeToName(data.countrycode)} Regions | AdventureLog
+ {data.countryName} Regions | AdventureLog