Skip to content

Commit

Permalink
Merge pull request #161 from midday-ai/feature/delete-team
Browse files Browse the repository at this point in the history
Delete team
  • Loading branch information
pontusab committed Jun 18, 2024
2 parents 3602984 + 79488fe commit 983bb00
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 6 deletions.
16 changes: 16 additions & 0 deletions apps/dashboard/src/actions/delete-user-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@

import { LogEvents } from "@midday/events/events";
import { setupAnalytics } from "@midday/events/server";
import { getUser } from "@midday/supabase/cached-queries";
import { deleteUser } from "@midday/supabase/mutations";
import { createClient } from "@midday/supabase/server";
import { redirect } from "next/navigation";

export const deleteUserAction = async () => {
const supabase = createClient();
const user = await getUser();

const { data: membersData } = await supabase
.from("users_on_team")
.select("team_id, team:team_id(id, name, members:users_on_team(id))")
.eq("user_id", user?.data?.id);

const teamIds = membersData
?.filter(({ team }) => team?.members.length === 1)
.map(({ team_id }) => team_id);

if (teamIds?.length) {
// Delete all teams with only one member
await supabase.from("teams").delete().in("id", teamIds);
}

const userId = await deleteUser(supabase);

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { MobileMenu } from "./mobile-menu";

export function Header() {
return (
<header className="-ml-4 -mr-4 md:m-0 z-10 px-4 md:px-4 md:border-b-[1px] flex justify-between pt-4 pb-2 md:pb-4 items-center todesktop:sticky todesktop:top-0 todesktop:bg-background todesktop:border-none sticky md:static top-0 backdrop-filter backdrop-blur-xl md:backdrop-filter md:backdrop-blur-none dark:bg-[#121212] bg-[#fff] bg-opacity-70 ">
<header className="-ml-4 -mr-4 md:m-0 z-10 px-4 md:pr-0 md:border-b-[1px] flex justify-between pt-4 pb-2 md:pb-4 items-center todesktop:sticky todesktop:top-0 todesktop:bg-background todesktop:border-none sticky md:static top-0 backdrop-filter backdrop-blur-xl md:backdrop-filter md:backdrop-blur-none dark:bg-[#121212] bg-[#fff] bg-opacity-70 ">
<MobileMenu />

{isDesktopApp() && <DesktopTrafficLight />}
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/select-attachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function SelectAttachment({ placeholder, onSelect }: Props) {

return (
<Combobox
className="border border-border rounded-md p-2 pl-10"
className="border border-border p-2 pl-10"
placeholder={placeholder}
onValueChange={(query) => {
setLoading(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function DataTable<TData, TValue>({
}, [initialData]);

return (
<div className="rounded-md mb-8 relative">
<div className="mb-8 relative">
<Table>
<DataTableHeader table={table} />

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/tracker-pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function TrackerPagination({ numberOfMonths, onChange, startDate }) {
};

return (
<div className="flex items-center border rounded-md h-9">
<div className="flex items-center border h-9">
<Button
variant="ghost"
size="icon"
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/tracker-select-project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function TrackerSelectProject({ setParams, teamId }) {
<Combobox
placeholder="Search or create project"
classNameList="-top-[4px] border-t-0 rounded-none rounded-b-md"
className="w-full bg-transparent px-12 border py-3 rounded-md"
className="w-full bg-transparent px-12 border py-3"
value={value}
onValueChange={onChangeValue}
onSelect={onSelect}
Expand Down
Binary file added apps/website/public/images/engine.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed apps/website/public/images/engine.png
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/website/src/app/updates/posts/engine.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Midday Engine"
publishedAt: "2024-06-18"
summary: "The core of Midday is based on our customers transactions. Using this data, we can do a lot to help you run your business smarter when it comes to financial insights, reconciling receipts, and more."
image: "/images/engine.png"
image: "/images/engine.jpg"
tag: "Updates"
---

Expand Down

0 comments on commit 983bb00

Please sign in to comment.