Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
avibn committed Apr 12, 2024
1 parent 113add8 commit ddf65b6
Show file tree
Hide file tree
Showing 26 changed files with 106 additions and 50 deletions.
2 changes: 1 addition & 1 deletion client/.env.production.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
NEXT_PUBLIC_BASE_URL=https://lanten.site/api

# Server URL
SERVER_BASE_URL=http://server:5000
SERVER_BASE_URL=https://lanten.site/api
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function LatestLeasesCard() {
<Link
key={lease.id}
href={`/leases/${lease.id}`}
prefetch={false}
passHref
>
<div className="rounded-md border whitespace-nowrap p-3 hover-card">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function LatestMessagesCard() {
</p>
)}
{messageChannels.map((user) => (
<Link key={user.id} href={`/messages/${user.id}`} passHref>
<Link key={user.id} href={`/messages/${user.id}`} prefetch={false} passHref>
<div className="flex flex-row gap-2 items-center justify-between border rounded p-3 text-sm hover-card">
<div className="flex gap-2 items-center">
<MessageCircle size={16} />
Expand Down
5 changes: 5 additions & 0 deletions client/src/app/(dashboard)/(both)/home/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingSpinner from "@/components/loading-spinner";

export default function Loading() {
return <LoadingSpinner />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function LeaseDetailsCard({ lease }: LeaseDetailsCardProps) {
<Link
href={`/properties/${lease.propertyId}`}
className="link-primary"
prefetch={false}
>
{lease.property?.name}
</Link>
Expand Down
5 changes: 5 additions & 0 deletions client/src/app/(dashboard)/(both)/leases/invite/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingSpinner from "@/components/loading-spinner";

export default function Loading() {
return <LoadingSpinner />;
}
5 changes: 4 additions & 1 deletion client/src/app/(dashboard)/(both)/leases/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ export default async function Page() {
</WithAuthorized>
</div>
<div className="mt-5 flex flex-col gap-4">
{activeLeases.length === 0 && (
<p className="text-gray-500">No active leases found.</p>
)}
{activeLeases.map((lease) => (
<Link key={lease.id} href={`/leases/${lease.id}`}>
<Link key={lease.id} prefetch={false} href={`/leases/${lease.id}`}>
<Card className="hover-card">
<CardHeader className="flex flex-row items-center justify-between">
<div className="flex flex-col gap-2">
Expand Down
5 changes: 5 additions & 0 deletions client/src/app/(dashboard)/(both)/maintenance/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingSpinner from "@/components/loading-spinner";

export default function Loading() {
return <LoadingSpinner />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const columns: ColumnDef<MaintenanceRequest>[] = [
const lease = row.getValue("lease") as Partial<Lease>;
return (
<Button variant="link" asChild className="p-0">
<Link href={`/leases/${lease?.id}`}>
<Link href={`/leases/${lease?.id}`} prefetch={false}>
{lease?.property?.name}
</Link>
</Button>
Expand Down
5 changes: 5 additions & 0 deletions client/src/app/(dashboard)/(both)/messages/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingSpinner from "@/components/loading-spinner";

export default function Loading() {
return <LoadingSpinner />;
}
2 changes: 1 addition & 1 deletion client/src/app/(dashboard)/(both)/messages/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default async function Page() {
</p>
)}
{messageChannels.map((channel) => (
<Link key={channel.id} href={`/messages/${channel.id}`}>
<Link key={channel.id} href={`/messages/${channel.id}`} prefetch={false}>
<Card
key={channel.id}
className="hover:bg-gray-100 duration-500"
Expand Down
5 changes: 5 additions & 0 deletions client/src/app/(dashboard)/(both)/settings/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingSpinner from "@/components/loading-spinner";

export default function Loading() {
return <LoadingSpinner />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function DeletePropertyClient({
<ol className="list-decimal list-inside">
{leases.map((lease) => (
<li key={lease.id}>
<Link href={`/leases/${lease.id}`}>
<Link href={`/leases/${lease.id}`} prefetch={false}>
{" "}
{formatTimeToDateString(
lease.startDate
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/(dashboard)/(landlord)/properties/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default async function Page() {
<Link
href="/properties/create"
className="hover:underline hover:text-green-700"
prefetch={false}
>
Create
</Link>{" "}
Expand All @@ -57,6 +58,7 @@ export default async function Page() {
key={property.id}
href={`/properties/${property.id}`}
className="flex-grow flex-shrink basis-0 max-w-80"
prefetch={false}
>
<Card className="hover-card h-full">
<div className="relative aspect-video overflow-hidden rounded-t-lg h-[150px] w-full">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const columns: ColumnDef<LeaseTenant>[] = [
const lease = row.getValue("lease") as Partial<Lease>;
return (
<Button variant="link" asChild className="p-0">
<Link href={`/leases/${lease?.id}`}>
<Link href={`/leases/${lease?.id}`} prefetch={false}>
{lease?.property?.name}
</Link>
</Button>
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/documents/[documentID]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function Page({ params: { documentID } }: PageProps) {
<div className="text-sm text-gray-500">
If the document does not open, click{" "}
<Button variant="link" className="p-0" asChild>
<Link href={link}>here</Link>
<Link href={link} prefetch={false}>here</Link>
</Button>
.
</div>
Expand All @@ -46,7 +46,7 @@ export default async function Page({ params: { documentID } }: PageProps) {
<div className="text-sm text-gray-500">
Click{" "}
<Button variant="link" className="p-0" asChild>
<Link href="/home">here</Link>
<Link href="/home" prefetch={false}>here</Link>
</Button>{" "}
to go back to the dashboard.
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default async function Page({ searchParams }: PageProps) {
return (
<>
<div className="flex items-center justify-between w-full px-6 py-4">
<Link href="/">
<Link href="/" prefetch={false}>
<div className="flex items-center space-x-4">
<Image
alt="Logo"
Expand Down
8 changes: 4 additions & 4 deletions client/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default async function Home() {
return (
<>
<div className="flex items-center justify-between w-full px-6 py-4">
<Link href="/">
<Link href="/" prefetch={false}>
<div className="flex items-center space-x-4">
<Image
alt="Logo"
Expand All @@ -22,10 +22,10 @@ export default async function Home() {
</Link>
<div className="flex items-center gap-2">
<Button asChild variant="ghost">
<Link href="/login">Login</Link>
<Link href="/login" prefetch={false}>Login</Link>
</Button>
<Button asChild>
<Link href="/login?tab=signup">Signup</Link>
<Link href="/login?tab=signup" prefetch={false}>Signup</Link>
</Button>
</div>
</div>
Expand All @@ -42,7 +42,7 @@ export default async function Home() {
</p>
</div>
<Button asChild>
<Link href="/login?tab=signup">Get started</Link>
<Link href="/login?tab=signup" prefetch={false}>Get started</Link>
</Button>
</div>
<Image
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/buttons/icon-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function IconButton({
<a href={href} target="_blank" rel="noreferrer noopener">
{icon}
</a>
)) || <Link href={href}>{icon}</Link>
)) || <Link href={href} prefetch={false}>{icon}</Link>
) : (
icon
)}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/buttons/main-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function MainButton({
icon,
href,
onClick,
linkPrefetch = true,
linkPrefetch = false,
linkProps = {},
}: MainButtonProps) {
const buttonContent = (
Expand Down
1 change: 1 addition & 0 deletions client/src/components/forms/create-lease-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function CreateLeaseForm({
<Link
href="/properties/create"
className="link-primary"
prefetch={false}
>
create a new property
</Link>
Expand Down
19 changes: 17 additions & 2 deletions client/src/components/loading-spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import { cn } from "@/utils/tw-merge";

interface LoadingSpinnerProps {
size?: number;
size?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
loadingText?: string;
textOff?: boolean;
className?: string;
}

// Specify tailwind classes so tailwind builds these classes
// https://stackoverflow.com/questions/71886011/why-tailwind-dynamic-class-is-not-present
const sizeToTwClasses = {
1: "w-1 h-1",
2: "w-2 h-2",
3: "w-3 h-3",
4: "w-4 h-4",
5: "w-5 h-5",
6: "w-6 h-6",
7: "w-7 h-7",
8: "w-8 h-8",
9: "w-9 h-9",
10: "w-10 h-10",
};

export default function LoadingSpinner({
size = 8,
loadingText = "Loading...",
Expand All @@ -21,7 +36,7 @@ export default function LoadingSpinner({
<div role="status">
<svg
aria-hidden="true"
className={`inline w-${size} h-${size} mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-gray-600 dark:fill-gray-300`}
className={`inline ${sizeToTwClasses[size]} mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-gray-600 dark:fill-gray-300`}
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
Expand Down
9 changes: 7 additions & 2 deletions client/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ export function Sidebar({ sideBarItems }: SidebarProps) {
<div className="px-3 lg:py-2 flex flex-col justify-between h-full">
<div>
<div className="flex items-center justify-between lg:mb-5 max-lg:mb-2 px-4">
<Link href="/home" onClick={closeSidebar}>
<Link
href="/home"
onClick={closeSidebar}
prefetch={false}
>
<div className="flex items-center space-x-2">
<Image
alt="Logo"
Expand Down Expand Up @@ -129,6 +133,7 @@ export function Sidebar({ sideBarItems }: SidebarProps) {
<Link
href={item.href}
onClick={closeSidebar}
prefetch={false}
>
{createIcon(item.icon)}
{item.name}
Expand All @@ -146,7 +151,7 @@ export function Sidebar({ sideBarItems }: SidebarProps) {
className="w-full justify-start"
asChild
>
<Link href="/settings" onClick={closeSidebar}>
<Link href="/settings" onClick={closeSidebar} prefetch={false}>
<Settings
size={20}
strokeWidth={1}
Expand Down
2 changes: 2 additions & 0 deletions client/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const protectedRoutes = [
"/leases",
"/tenants",
"/maintenance",
"/messages",
"/settings",
];

export function middleware(request: NextRequest) {
Expand Down
3 changes: 2 additions & 1 deletion client/src/network/server/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import { redirect } from "next/navigation";
export const getSessionUser = async (): Promise<User> => {
const cookie = cookies().get("connect.sid");
if (!cookie) {
console.error("No cookie found");
throw new UnauthorizedError("Not logged in");
}

const response = await fetchDataServer("/users/me", {
next: {
revalidate: 30,
revalidate: 0,
},
});
return await response.json();
Expand Down
58 changes: 29 additions & 29 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,37 @@ services:
ports:
- ${REDIS_INSIGHT_PORT}:8001

server:
build: ./server
ports:
- 5000:5000
depends_on:
- db
- redis
env_file:
- ./.env.server
networks:
- backend
# server:
# build: ./server
# ports:
# - 5000:5000
# depends_on:
# - db
# - redis
# env_file:
# - ./.env.server
# networks:
# - backend

client:
build: ./client
ports:
- 3000:3000
depends_on:
- server
networks:
- backend
# client:
# build: ./client
# ports:
# - 3000:3000
# depends_on:
# - server
# networks:
# - backend

azure-function:
build: ./azure
ports:
- "7071:80"
env_file:
- ./.env.azure
volumes:
- ./etc/test-secrets:/azure-functions-host/Secrets
networks:
- backend
# azure-function:
# build: ./azure
# ports:
# - "7071:80"
# env_file:
# - ./.env.azure
# volumes:
# - ./etc/test-secrets:/azure-functions-host/Secrets
# networks:
# - backend
# depends_on:
# - azurite

Expand Down

0 comments on commit ddf65b6

Please sign in to comment.