Skip to content

Commit

Permalink
update fetch revalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
avibn committed Apr 12, 2024
1 parent b1d5fd5 commit 1db7103
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function InviteClient({
if (leaseTenant) {
refreshLeases();
router.push(`/leases/${leaseTenant.leaseId}`);
router.refresh();
toast.success("You have joined the lease!");
} else {
router.push("/leases");
Expand Down
1 change: 1 addition & 0 deletions client/src/app/login/login-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function LoginClient() {
toast.success("Logged in successfully!");
setUser(data);
router.push("/home");
router.refresh();
}

return <LoginForm onSubmit={onSubmit} loading={isPending} />;
Expand Down
1 change: 1 addition & 0 deletions client/src/app/login/signup-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function SignupClient() {
toast.success("Account created!");
setUser(data);
router.push("/home");
router.refresh();
}

return <SignupForm onSubmit={onSubmit} loading={isPending} />;
Expand Down
1 change: 1 addition & 0 deletions client/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function Sidebar({ sideBarItems }: SidebarProps) {
setUser(null);
toast.success("Logged out successfully");
router.push("/login");
router.refresh();
}

const closeSidebar = () => {
Expand Down
4 changes: 2 additions & 2 deletions client/src/network/server/announcements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getAnnouncements(
`/leases/${leaseId}/announcements` + (max ? `?max=${max}` : ""),
{
next: {
revalidate: 20,
revalidate: 0,
tags: ["LeaseAnnouncements"],
},
}
Expand All @@ -24,7 +24,7 @@ export async function getLatestAnnouncements(
`/announcements/latest` + (max ? `?max=${max}` : ""),
{
next: {
revalidate: 20,
revalidate: 0,
tags: ["Announcements"],
},
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/network/server/leases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fetchDataServer } from "../helpers/fetch-data-server";
export async function getLeases(): Promise<Lease[]> {
const response = await fetchDataServer("/leases", {
next: {
revalidate: 20,
revalidate: 0,
tags: ["leases"],
},
});
Expand All @@ -14,7 +14,7 @@ export async function getLeases(): Promise<Lease[]> {
export async function getLeasesList(): Promise<Partial<Lease>[]> {
const response = await fetchDataServer("/leases/list", {
next: {
revalidate: 20,
revalidate: 0,
tags: ["leases"],
},
});
Expand All @@ -24,7 +24,7 @@ export async function getLeasesList(): Promise<Partial<Lease>[]> {
export async function getLease(id: string): Promise<Lease> {
const response = await fetchDataServer(`/leases/${id}`, {
next: {
revalidate: 20,
revalidate: 0,
tags: ["leases"],
},
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/network/server/maintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function getMaintenanceRequestTypes(): Promise<
> {
const response = await fetchDataServer("/maintenance/types", {
next: {
revalidate: 1 * 60 * 60, // 1 hour
revalidate: 0,
tags: ["MaintenanceTypes"],
},
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/network/server/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fetchDataServer } from "../helpers/fetch-data-server";
export async function getPayments(leaseId: string): Promise<Payment[]> {
const response = await fetchDataServer(`/leases/${leaseId}/payments`, {
next: {
revalidate: 20,
revalidate: 0,
tags: ["LeasePayments"],
},
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/network/server/tenants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fetchDataServer } from "../helpers/fetch-data-server";
export async function getAllTenants(): Promise<LeaseTenant[]> {
const response = await fetchDataServer("/leases/tenants", {
next: {
revalidate: 10,
revalidate: 0,
},
});
return await response.json();
Expand Down

0 comments on commit 1db7103

Please sign in to comment.