diff --git a/.github/workflows/anchor-deploy.yaml b/.github/workflows/anchor-deploy.yaml
index 40ef30d1f..c6e2e6e8a 100644
--- a/.github/workflows/anchor-deploy.yaml
+++ b/.github/workflows/anchor-deploy.yaml
@@ -87,7 +87,7 @@ jobs:
cd boilerplate-frontend
rm -rf *
tar -xzf /tmp/python/boilerplate.tar.gz
- mv /tmp/python/.env.java .env
+ mv /tmp/python/.env.python .env
rm -f /tmp/python/boilerplate.tar.gz
cp -r .next/standalone/* .
pm2 restart python-boilerplate --update-env
diff --git a/src/actions/switchOrganization.ts b/src/actions/switchOrganization.ts
new file mode 100644
index 000000000..fc98b846d
--- /dev/null
+++ b/src/actions/switchOrganization.ts
@@ -0,0 +1,23 @@
+"use server";
+
+import axios from "axios";
+
+import { auth } from "~/lib/auth";
+import { getApiUrl } from "./getApiUrl";
+
+export const getCurrentOrgApi = async ({ orgId }: { orgId: string }) => {
+ const payload = { isActive: true };
+ const apiUrl = await getApiUrl();
+ const session = await auth();
+ const response = await axios.put(
+ `${apiUrl}/api/v1/users/organisations/${orgId}`,
+ payload,
+ {
+ headers: {
+ Authorization: `Bearer ${session?.access_token}`,
+ },
+ },
+ );
+ return response.data;
+};
+// `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiIwZjc4ZGExMy0xYTc2LTQyYWItOTg0My1hNTBmNDY2ODBiNjUiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9lbWFpbGFkZHJlc3MiOiJkZWppd2lsbGlhbXM5QGdtYWlsLmNvbSIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJEZWppIiwiZXhwIjoxNzIzNzA4ODUzfQ.qm8sOMQ-EMkyE8no_Dz22UD5N0qqn3nImjvkVWG1UK4`
diff --git a/src/app/dashboard/(user-dashboard)/_components/layout/navbar/organisation-switcher.tsx b/src/app/dashboard/(user-dashboard)/_components/layout/navbar/organisation-switcher.tsx
index 6cd9508d6..a047888c1 100644
--- a/src/app/dashboard/(user-dashboard)/_components/layout/navbar/organisation-switcher.tsx
+++ b/src/app/dashboard/(user-dashboard)/_components/layout/navbar/organisation-switcher.tsx
@@ -2,6 +2,7 @@
import { useEffect, useState } from "react";
+import { getCurrentOrgApi } from "~/actions/switchOrganization";
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar";
import { Button } from "~/components/ui/button";
import {
@@ -22,13 +23,22 @@ export const OrganisationSwitcher = () => {
"",
);
- const { organizations, isLoading } = useOrgContext();
+ const { organizations, isLoading, switchOrganization } = useOrgContext();
+ // eslint-disable-next-line unicorn/consistent-function-scoping
useEffect(() => {
if (!currentOrgId && organizations.length > 0) {
setCurrentOrgId(organizations[0].organisation_id);
+ switchOrganization(organizations[0].organisation_id);
}
- }, [currentOrgId, organizations, setCurrentOrgId]);
+ // console.log(organizations);
+ }, [currentOrgId, organizations, setCurrentOrgId, switchOrganization]);
+
+ const handleOrgChange = (currentOrg: string) => {
+ setCurrentOrgId(currentOrg);
+ switchOrganization(currentOrg);
+ getCurrentOrgApi({ orgId: currentOrg });
+ };
const currentOrg =
organizations.length > 0
@@ -42,9 +52,7 @@ export const OrganisationSwitcher = () => {