Skip to content

Commit

Permalink
Merge pull request #27 from kcoderhtml/new-signup
Browse files Browse the repository at this point in the history
New signup
  • Loading branch information
kcoderhtml authored Apr 29, 2024
2 parents 5cc2177 + b41378b commit 5b041a0
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 6 deletions.
6 changes: 6 additions & 0 deletions auth.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default defineConfig({
clientSecret: import.meta.env.SLACK_CLIENT_SECRET,
checks: ["pkce", "nonce"],
async profile(profile) {
let newUser = false;
profile["https://slack.com/team_id"] =
"slack-" + profile["https://slack.com/team_id"];

Expand Down Expand Up @@ -92,6 +93,7 @@ export default defineConfig({
});

role[0].role = "admin";
newUser = true;
} else {
await db.insert(User).values({
userId: profile["https://slack.com/user_id"],
Expand Down Expand Up @@ -138,6 +140,7 @@ export default defineConfig({
});

role[0].role = "user";
newUser = true;
}
} else {
role[0].role = "guest";
Expand Down Expand Up @@ -176,6 +179,7 @@ export default defineConfig({
teamName: profile["https://slack.com/team_name"],
teamImage: profile["https://slack.com/team_image_230"],
role: role[0].role || "guest",
newUser: newUser,
};
},
}),
Expand All @@ -189,6 +193,7 @@ export default defineConfig({
token.teamImage = user.teamImage;
token.role = user.role;
token.id = user.id;
token.newUser = user.newUser;
}
return token;
},
Expand All @@ -200,6 +205,7 @@ export default defineConfig({
session.teamImage = token.teamImage;
session.user.role = token.role;
session.user.id = token.id;
session.newUser = token.newUser;
}
return session;
},
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"@astrojs/node": "^8.2.5",
"@astrojs/tailwind": "^5.1.0",
"@auth/core": "^0.18.6",
"@types/canvas-confetti": "^1.6.4",
"astro": "^4.5.10",
"auth-astro": "^4.1.1",
"canvas-confetti": "^1.9.2",
"jwt-decode": "^4.0.0",
"logsnag": "^1.0.0",
"magick.css": "^1.0.5",
Expand Down
8 changes: 8 additions & 0 deletions src/pages/dashboard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ExtendedSession = {
user: {
role: string;
};
newUser: boolean;
};
const session = (await getSession(Astro.request)) as Session & ExtendedSession;
Expand Down Expand Up @@ -193,6 +194,13 @@ const users = await db.select().from(User).where(like(User.team, session.team));
} events
</p>
</section>
{
session.newUser && (
<section>
<p>Since you are a new user we recommend that you first fillout your allergies <a href="/settings">here</a> then come back and set your availability!</p>
</section>
)
}
{
session.user.role === "admin" && (
<section>
Expand Down
75 changes: 69 additions & 6 deletions src/pages/join/[joinCode].astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { SignIn } from "auth-astro/components";
import { getSession } from "auth-astro/server";
import { type Session } from "@auth/core/types";
import { db } from "astro:db";
import { Invite } from "astro:db";
import { like } from "astro:db";
import { Organization } from "astro:db";
import { db, like, Event, Invite, Organization } from "astro:db";
import { LogSnag } from "logsnag";
Expand Down Expand Up @@ -82,7 +79,16 @@ if (session && session.user.role === "guest") {
name: session.teamName,
image: session.teamImage,
});
await db.insert(Event).values({
name: "Welcome to MagicSnap! 🎉",
date: new Date(Date.now() + 1000 * 60 * 60 * 2),
team: session.team,
comments: "A default event created by workspace connection",
location: "MagicSnap",
statusGoing: session.user.id,
statusNotGoing: "",
statusMaybe: "",
});
await logsnag.track({
channel: "join-code",
event: "create-team",
Expand Down Expand Up @@ -119,7 +125,7 @@ if (session && session.user.role === "guest") {
{
session && session.user.role === "guest" && (
<>
<section>
<section id="successful">
<p>
You have successfully connected your team {team.teamName} to
MagicSnap! You can now sign in to MagicSnap using your account and
Expand All @@ -136,6 +142,63 @@ if (session && session.user.role === "guest") {
}
</Base>

<script>
// @ts-ignore
import confetti from "canvas-confetti";

if (document.getElementById("successful")) {
await new Promise<void>((resolve) => {
setTimeout(() => {
resolve();
}, 100);
});

var count = 200;
var defaults = {
origin: { y: 0.7 },
};

function fire(
particleRatio: number,
opts: {
spread: number;
startVelocity?: number;
decay?: number;
scalar?: number;
}
) {
confetti({
...defaults,
...opts,
particleCount: Math.floor(count * particleRatio),
});
}

fire(0.25, {
spread: 26,
startVelocity: 55,
});
fire(0.2, {
spread: 60,
});
fire(0.35, {
spread: 100,
decay: 0.91,
scalar: 0.8,
});
fire(0.1, {
spread: 120,
startVelocity: 25,
decay: 0.92,
scalar: 1.2,
});
fire(0.1, {
spread: 120,
startVelocity: 45,
});
}
</script>

<style>
.signin-button {
display: flex;
Expand Down

0 comments on commit 5b041a0

Please sign in to comment.