Skip to content

Commit

Permalink
Tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Feb 14, 2024
1 parent a37de1a commit b5c2dcc
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 44 deletions.
14 changes: 7 additions & 7 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
"@midday/ui": "workspace:*",
"@next/bundle-analyzer": "^14.1.0",
"@novu/headless": "^0.23.1",
"@tanstack/react-table": "^8.11.8",
"@tanstack/react-table": "^8.12.0",
"@todesktop/client-active-win": "^0.15.0",
"@todesktop/client-core": "^1.2.4",
"@todesktop/client-core": "^1.2.5",
"@trigger.dev/nextjs": "^2.3.18",
"@uidotdev/usehooks": "^2.4.1",
"@vercel/edge-config": "^1.0.0",
"@vercel/speed-insights": "^1.0.9",
"@zip.js/zip.js": "2.7.34",
"base64-arraybuffer": "^1.0.2",
"change-case": "^5.4.2",
"change-case": "^5.4.3",
"dub": "^0.7.0",
"fast-csv": "^5.0.0",
"framer-motion": "^11.0.3",
"fast-csv": "^5.0.1",
"framer-motion": "^11.0.5",
"geist": "^1.2.2",
"headless-currency-input": "^1.1.0",
"loops": "0.2.1",
Expand All @@ -45,7 +45,7 @@
"next-international": "1.2.4",
"next-safe-action": "6.1.0",
"next-themes": "^0.2.1",
"nuqs": "^1.16.1",
"nuqs": "^1.17.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-dropzone": "^14.2.3",
Expand All @@ -54,7 +54,7 @@
"react-intersection-observer": "^9.8.0",
"react-pin-field": "^3.1.5",
"recharts": "^2.12.0",
"resend": "^3.1.0",
"resend": "^3.2.0",
"sharp": "^0.33.2",
"tus-js-client": "^4.0.1",
"use-long-press": "^3.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeLanguage } from "@/components/change-language";
// import { ChangeLanguage } from "@/components/change-language";
import { ChangeTheme } from "@/components/change-theme";
import { DeleteAccount } from "@/components/delete-account";
import { DisplayName } from "@/components/display-name";
Expand All @@ -21,7 +21,7 @@ export default async function Account() {
avatarUrl={userData?.avatar_url}
/>
<DisplayName fullName={userData.full_name} />
<ChangeLanguage />
{/* <ChangeLanguage /> */}
<ChangeTheme />
<DeleteAccount />
</div>
Expand Down
12 changes: 6 additions & 6 deletions apps/dashboard/src/components/command-menu/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const navigation = [
name: "Invoices",
path: "/invoices",
},
{
name: "Tracker",
path: "/tracker",
},
// {
// name: "Tracker",
// path: "/tracker",
// },
{
name: "Vault",
path: "/vault",
Expand Down Expand Up @@ -79,10 +79,10 @@ export function CommandRoot() {
</span>
</div>
</CommandItem>
<CommandItem onSelect={() => setMenu(MenuOption.Tracker)}>
{/* <CommandItem onSelect={() => setMenu(MenuOption.Tracker)}>
<Icons.Tracker className="mr-2 h-[20px] w-[20px]" />
<span>Time Tracker</span>
</CommandItem>
</CommandItem> */}
{isDesktopApp() && (
<CommandItem onSelect={() => window.location.replace("midday://")}>
<MoveUpRight className="mr-2 h-4 w-4" />
Expand Down
15 changes: 13 additions & 2 deletions apps/dashboard/src/components/tracker-day-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function TrackerDayCard({
disableHover,
isActive,
isTracking,
selectProject,
}) {
const totalDuration = data?.reduce(
(duration, item) => item.duration + duration,
Expand All @@ -24,13 +25,21 @@ export function TrackerDayCard({

const hoverEnabled = !disableHover && data;

const handleOnClick = () => {
if (selectProject) {
onSelect({ date, projectId: "new" });
} else {
onSelect({ date });
}
};

return (
<HoverCard openDelay={250} closeDelay={150}>
<HoverCardTrigger asChild>
<button
className="w-[35px] flex items-center justify-center group relative"
type="button"
onClick={() => onSelect({ date, projectId: "new" })}
onClick={handleOnClick}
>
<div
className={cn(
Expand Down Expand Up @@ -94,7 +103,9 @@ export function TrackerDayCard({
<button
className="flex flex-col"
type="button"
onClick={() => onSelect({ id: record.project.id, date })}
onClick={() =>
onSelect({ projectId: record.project.id, date })
}
>
<span className="text-xs">{record.project?.name}</span>
<span className="text-xs text-[#878787]">
Expand Down
28 changes: 21 additions & 7 deletions apps/dashboard/src/components/tracker-graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createClient } from "@midday/supabase/client";
import { getTrackerRecordsByRange } from "@midday/supabase/queries";
import {
eachDayOfInterval,
eachMonthOfInterval,
eachWeekOfInterval,
endOfMonth,
endOfWeek,
Expand Down Expand Up @@ -68,9 +69,6 @@ export function TrackerGraph() {
setParams(params);
};

const firstDay = startOfMonth(subMonths(currentDate, 6));
const lastDay = endOfMonth(currentDate);

const weeks = eachWeekOfInterval(
{
start,
Expand All @@ -79,6 +77,11 @@ export function TrackerGraph() {
{ weekStartsOn }
);

const months = eachMonthOfInterval({
start,
end,
});

const days = eachDayOfInterval({
start: startOfWeek(currentDate, { weekStartsOn }),
end: lastDayOfWeek(currentDate, { weekStartsOn }),
Expand All @@ -95,7 +98,7 @@ export function TrackerGraph() {
</div>
</div>

<div className="flex gap-4 mt-8 justify-between">
<div className="flex gap-2 mt-8 justify-between">
<div className="flex flex-col justify-between mr-4">
{days.map((day) => (
<div className="h-[28px]" key={day}>
Expand All @@ -112,14 +115,15 @@ export function TrackerGraph() {

return (
<div key={day.toISOString()}>
<div className="flex flex-col gap-6">
<div className="flex flex-col gap-4">
{daysInWeek.map((dayInWeek) => {
const isoDate = formatISO(dayInWeek, {
representation: "date",
});

return (
<TrackerDayCard
selectProject
key={isoDate}
date={isoDate}
data={data && data[isoDate]}
Expand All @@ -129,8 +133,7 @@ export function TrackerGraph() {
isSameDay(new Date(dayInWeek), currentDate)
}
outOfRange={
isBefore(dayInWeek, firstDay) ||
isAfter(dayInWeek, lastDay)
isBefore(dayInWeek, start) || isAfter(dayInWeek, end)
}
/>
);
Expand All @@ -140,6 +143,17 @@ export function TrackerGraph() {
);
})}
</div>

<div className="flex w-full mt-6 pl-10">
{months.map((month) => (
<div
key={month.toDateString()}
className="basis-1/6 text-center text-[#878787] text-sm"
>
{format(month, "MMM")}
</div>
))}
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/tracker-month-graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function TrackerMonthGraph({
const handleOnSelect = (params) => {
if (onSelect) {
onSelect({
projectId: params.id || projectId,
projectId: params.projectId || projectId,
date: formatISO(params.date, { representation: "date" }),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function InboxWidget({ filter, disabled }) {
const { data } = disabled
? inboxData
: await getInbox({
to: 3,
to: 2,
from: 0,
status: filter,
});
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/locales/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { createI18nClient } from "next-international/client";

export const languages = ["en", "sv"];
export const languages = ["en"];

export const {
useScopedI18n,
Expand All @@ -12,5 +12,5 @@ export const {
useI18n,
} = createI18nClient({
en: () => import("./en"),
sv: () => import("./sv"),
// sv: () => import("./sv"),
});
2 changes: 1 addition & 1 deletion apps/dashboard/src/locales/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { createI18nServer } from "next-international/server";

export const { getI18n, getScopedI18n, getStaticParams } = createI18nServer({
en: () => import("./en"),
sv: () => import("./sv"),
// sv: () => import("./sv"),
});
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/jobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@trigger.dev/resend": "^2.3.18",
"@trigger.dev/sdk": "^2.3.18",
"@trigger.dev/supabase": "^2.3.18",
"langchain": "0.1.17",
"langchain": "0.1.18",
"nanoid": "^5.0.5",
"pdf-parse": "^1.1.1"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/supabase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@supabase/ssr": "^0.1.0",
"@supabase/supabase-js": "^2.39.3",
"@supabase/supabase-js": "^2.39.6",
"supabase": "^1.142.2"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"./utils": "./src/utils"
},
"dependencies": {
"@mui/icons-material": "^5.15.9",
"@mui/icons-material": "^5.15.10",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
Expand All @@ -99,15 +99,15 @@
"@radix-ui/react-tooltip": "^1.0.7",
"@storybook/addon-postcss": "^2.0.0",
"@storybook/addon-styling": "^1.3.7",
"@storybook/addon-themes": "^7.6.14",
"@storybook/manager-api": "^7.6.14",
"@storybook/addon-themes": "^7.6.15",
"@storybook/manager-api": "^7.6.15",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cmdk": "^0.2.1",
"date-fns": "^3.3.1",
"embla-carousel-react": "^8.0.0-rc22",
"jsonfile": "^6.1.0",
"lucide-react": "^0.325.0",
"lucide-react": "^0.330.0",
"postcss": "^8.4.35",
"react-day-picker": "^8.10.0",
"react-icons": "^5.0.1",
Expand Down
20 changes: 11 additions & 9 deletions packages/ui/src/components/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-lg border backdrop-filter border dark:border-[#2C2C2C] backdrop-blur-lg dark:bg-[#1A1A1A]/95 px-4 py-3 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-lg border backdrop-filter border dark:border-[#2C2C2C] backdrop-blur-lg dark:bg-[#1A1A1A]/95 px-4 py-3 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
</TooltipPrimitive.Portal>
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;

Expand Down

0 comments on commit b5c2dcc

Please sign in to comment.