Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update init environment script #26

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.local.example

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- run: cp .env.local.example .env.local
- run: pnpm install
- run: pnpm build
- name: Build the application
env:
BACK_END_SERVER: "http://localhost:8080"
run: pnpm build
31 changes: 22 additions & 9 deletions scripts/init_environments.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# Define file paths
template_file=".env.local.example"
output_file=".env.local"
backup_file=".env.local.backup"

# Check if the output file already exists
if [ -f "$output_file" ]; then
Expand All @@ -12,17 +12,30 @@ if [ -f "$output_file" ]; then
echo "Aborting. $output_file will not be replaced."
exit 0
fi
fi

# Copy content from .env.example to .env
if [ -f "$template_file" ]; then
cp "$template_file" "$output_file"
echo "Copied content from $template_file to $output_file."
else
echo "Template file $template_file not found. Exiting."
exit 1
# Backup the existing file
echo "Backing up $output_file to $backup_file..."
cp "$output_file" "$backup_file"
fi

# Create an empty file
echo "Creating an empty $output_file..."
> "$output_file" # Use > to truncate and create an empty file

# Prompt user for backend server URL (with optional port)
while true; do
read -p "Enter the Flexwork back-end server URL address (e.g., http://localhost or http://localhost:8080). This is the server hosting the Flexwork back-end services: " backend_server
if [[ $backend_server =~ ^http(s)?://[a-zA-Z0-9.-]+(:[0-9]{1,5})?$ ]]; then
break
else
echo "Invalid input. Please enter a valid URL (e.g., http://localhost or http://localhost:8080)."
fi
done

# Append to the .env.local file
echo "BACK_END_SERVER=\"$backend_server\"" >> "$output_file"


# Run npx auth and append its output to .env
npx auth secret >> "$output_file"

Expand Down
7 changes: 2 additions & 5 deletions src/components/dashboard/notifications-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ const UserNotifications = () => {
}, [userId, currentPage]);

const handleMarkAsRead = async (notificationId: number) => {
try {
await markNotificationsAsRead([notificationId]);
markNotificationsAsRead([notificationId]).finally(() => {
setNotifications((prev) =>
prev.map((n) => (n.id === notificationId ? { ...n, isRead: true } : n)),
);
} catch (error) {
console.error("Failed to mark notification as read", error);
}
});
};

return (
Expand Down
1 change: 0 additions & 1 deletion src/lib/actions/teams-request.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export async function searchTeamRequests(
pagination: Pagination,
) {
noStore();
console.log(`Filters ${JSON.stringify(query)}`);
return doAdvanceSearch<TeamRequestDTO>(
`${BACKEND_API}/api/team-requests/search`,
query,
Expand Down
Loading