Skip to content

Commit

Permalink
Merge pull request #83 from dotslashf/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
dotslashf authored Sep 29, 2024
2 parents 350bcbc + ed0c31a commit 3291cbe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
15 changes: 11 additions & 4 deletions src/app/_components/CreateCollectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,17 @@ export default function CreateCollection() {
className="w-full items-center"
disabled={form.formState.isSubmitting}
>
{form.formState.isSubmitting
? "Membuat Koleksi..."
: "Tambah Koleksi"}
<PlusIcon className="ml-2 h-4 w-4" />
{form.formState.isSubmitting ? (
<>
Membuat Koleksi...
<LoaderCircle className="ml-2 w-4 animate-spin" />
</>
) : (
<>
Tambah Koleksi
<PlusIcon className="ml-2 h-4 w-4" />
</>
)}
</Button>
</div>
</form>
Expand Down
14 changes: 11 additions & 3 deletions src/app/_components/CreateCopyPastaPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { Input } from "~/components/ui/input";
import { Textarea } from "~/components/ui/textarea";
import { api } from "~/trpc/react";
import { PlusIcon } from "lucide-react";
import { LoaderCircle, PlusIcon } from "lucide-react";
import {
determineSource,
formatDateToHuman,
Expand Down Expand Up @@ -437,8 +437,16 @@ export default function CreateCopyPasta() {
className="w-full items-center"
disabled={form.formState.isSubmitting}
>
{form.formState.isSubmitting ? "Mengarsipkan..." : "Tambah"}
<PlusIcon className="ml-2 h-4 w-4" />
{form.formState.isSubmitting ? (
<>
Mengarsipkan...
<LoaderCircle className="ml-2 w-4 animate-spin" />
</>
) : (
<>
Arsipkan <PlusIcon className="ml-2 h-4 w-4" />
</>
)}
</Button>
</div>
</form>
Expand Down
10 changes: 7 additions & 3 deletions src/server/api/routers/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AchievementType, type PrismaClient, type User } from "@prisma/client";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { getJakartaDate, getJakartaDateString } from "~/lib/utils";
import {
createTRPCRouter,
protectedProcedure,
Expand All @@ -20,13 +21,16 @@ export async function updateUserStreak(userId: string, db: PrismaClient) {
});
}

const now = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const now = getJakartaDate();
const todayString = getJakartaDateString(now);

let newStreak = user.currentStreak || 0;
let isStreakUpdated = false;

if (!user.lastPostedAt || user.lastPostedAt < today) {
if (
!user.lastPostedAt ||
getJakartaDateString(user.lastPostedAt) < todayString
) {
// If last post was before today, increment the streak
newStreak += 1;
isStreakUpdated = true;
Expand Down

0 comments on commit 3291cbe

Please sign in to comment.