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

feat(congregations): support import and export data #3225

Merged
merged 7 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ VITE_FIREBASE_APIKEY=
VITE_FIREBASE_APPID=
VITE_FIREBASE_AUTHDOMAIN=
VITE_FIREBASE_AUTH_EMULATOR_HOST=http://127.0.0.1:9099
VITE_FIREBASE_MEASUREMENTID=
VITE_FIREBASE_MESSAGINGSENDERID=
VITE_FIREBASE_PROJECTID=
29 changes: 13 additions & 16 deletions LOCAL_ENVIRONMENT_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,14 @@ Firebase Emulators require a storage rule file to set up Firebase Storage locall

Now, let’s assign values to these variables:

1. Starting with the **USER_PARSER_API_KEY,** go to [userparser.com](https://www.userparser.com). This API helps us better authorize users by collecting the user agent data of their devices. Log in to your account if you already have one, or create a new one if you don’t. It’s completely free.
2. After completing the authentication, navigate to **Dashboard,** where you should see the API key at the top of the page. Copy that API key to the **USER_PARSER_API_KEY** variable.
3. Next, we have three environment variables: **GMAIL_ADDRESS, GMAIL_APP_PASSWORD,** and **GMAIL_SENDER_NAME.** We won’t use these during local development, so we can skip them for now.
4. Let’s move on to the Firebase environment variables. For **FIREBASE_APP_NAME,** use the project id assigned to your firebase project. You can get it from the URL (ie: `organized-app-47c7u` from `https://console.firebase.google.com/u/1/project/organized-app-47c7u/overview`). Alternatively, you can go to **Settings,** then **General,** and find the `Project ID`.
5. For the **GOOGLE_CONFIG_BASE64,** there are many approaches to get this base64 string of the private key. We’re just showing one way of getting it.
6. In this example, we’ll use Node directly in the Terminal window by typing `node`.
7. Let’s create a variable to store our private key JSON contents. Open the JSON file we downloaded earlier and copy its contents. Then, type `const firebaseConfig =` and right after this paste all the JSON content into the Terminal. Press Enter. Remember, it’s just the JSON data saved in this newly defined variable.
8. To convert it to a base64 string, we use the command `Buffer.from(JSON.stringify(firebaseConfig)).toString('base64')`. Please, note that we recommend using the local converting command rather than online base64 converter tools, because of security reasons. Then, press **Enter.**
9. You should now have the base64 encoded string of your Firebase private key. Copy that text to the **GOOGLE_CONFIG_BASE64** variable.
10. Additionally, create .firebaserc file with `cp .firebaserc.example .firebaserc` command and update the default field **your-organized-project-id** with your Firebase project ID.
1. Let’s move on to the Firebase environment variables. For **FIREBASE_APP_NAME,** use the project id assigned to your firebase project. You can get it from the URL (ie: `organized-app-47c7u` from `https://console.firebase.google.com/u/1/project/organized-app-47c7u/overview`). Alternatively, you can go to **Settings,** then **General,** and find the `Project ID`.
2. For the **GOOGLE_CONFIG_BASE64,** there are many approaches to get this base64 string of the private key. We’re just showing one way of getting it.
3. In this example, we’ll use Node directly in the Terminal window by typing `node`.
4. Let’s create a variable to store our private key JSON contents. Open the JSON file we downloaded earlier and copy its contents. Then, type `const firebaseConfig =` and right after this paste all the JSON content into the Terminal. Press Enter. Remember, it’s just the JSON data saved in this newly defined variable.
5. To convert it to a base64 string, we use the command `Buffer.from(JSON.stringify(firebaseConfig)).toString('base64')`. Please, note that we recommend using the local converting command rather than online base64 converter tools, because of security reasons. Then, press **Enter.**
6. You should now have the base64 encoded string of your Firebase private key. Copy that text to the **GOOGLE_CONFIG_BASE64** variable.
7. The three environment variables: **MAIL_ADDRESS, MAIL_PASSWORD,** and **MAIL_SENDER_NAME.** are not used during local development, so we can skip them for now.
8. Additionally, create .firebaserc file with `cp .firebaserc.example .firebaserc` command and update the default field **your-organized-project-id** with your Firebase project ID.
rhahao marked this conversation as resolved.
Show resolved Hide resolved

#### Setup the Firebase emulators

Expand Down Expand Up @@ -174,12 +172,11 @@ _That completes the setup of the backend project for the local environment. The
_Now, let’s add the required environment variables for the frontend application._

1. Create an `.env` file for this frontend project. You can do it starting from the example file `cp .env.example .env`.
2. Write all the required variables. We need the **VITE_FIREBASE_APIKEY, VITE_FIREBASE_AUTHDOMAIN, VITE_FIREBASE_PROJECTID, VITE_FIREBASE_APPID,**, **VITE_FIREBASE_MEASUREMENTID.**, and **VITE_FIREBASE_MESSAGINGSENDERID**.
3. To get these values, go back to the Firebase Console and open your project.
4. Navigate to **Project Settings.** Find “Your apps” or “Add an app” area and hit the “Web” button. Then create and register a new Web App.
5. Give a nickname for the web app. For example, ‘Organized web app’.
6. We don’t need to set up Firebase Hosting for this app, so continue.
7. In this section, we get all the required values for our environment variables like **apiKey, authDomain, projectId, appId,** and **measurementId.** Copy these values from the Firebase console to our `.env` file.
2. Write all the required variables. We need the **VITE_FIREBASE_APIKEY, VITE_FIREBASE_AUTHDOMAIN, VITE_FIREBASE_PROJECTID**, and **VITE_FIREBASE_APPID.** To get these values, go back to the Firebase Console and open your project.
3. Navigate to **Project Settings.** Find “Your apps” or “Add an app” area and hit the “Web” button. Then create and register a new Web App.
4. Give a nickname for the web app. For example, ‘Organized web app’.
5. We don’t need to set up Firebase Hosting for this app, so continue.
6. In this section, we get all the required values for our environment variables like **apiKey, authDomain, projectId,** and **appId.** Copy these values from the Firebase console to our `.env` file.

_All the dependencies were installed, and the environment variables are all ready. We can now start the frontend application._

Expand Down
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/assets/img/netlify_darkmode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/netlify_lightmode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/definition/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ export type ReleaseNoteType = {
export type UpdateStatusType = {
[version: string]: boolean;
};

export type BackupFileType = 'CPE' | 'Organized' | '';
226 changes: 226 additions & 0 deletions src/definition/backup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
export type BackupOrganizedType = {
name: string;
exported: string;
version: string;
data: {
[table: string]: object[];
};
};

export type BackupCPEType = {
persons: {
person_uid: string;
person_name: string;
person_displayName: string;
isMale: boolean;
isFemale: boolean;
rhahao marked this conversation as resolved.
Show resolved Hide resolved
isUnavailable: boolean;
assignments: { code: number }[];
isMoved: boolean;
isDisqualified: boolean;
birthDate: string;
isAnointed: boolean;
isOtherSheep: boolean;
isBaptized: boolean;
immersedDate: string;
email: string;
address: string;
phone: string;
spiritualStatus: {
statusId: string;
status: string;
startDate: string;
endDate: string;
}[];
otherService: {
serviceId: string;
service: string;
startDate: string;
endDate: string;
}[];
firstMonthReport: string;
}[];
fieldServiceGroup: {
fieldServiceGroup_uid: string;
isCurrent: boolean;
groups: {
group_uid: string;
persons: {
person_uid: string;
isOverseer: boolean;
isAssistant: boolean;
}[];
}[];
deleted: boolean;
}[];
visiting_speakers: {
cong_name: string;
cong_number: number;
cong_speakers: {
person_uid: string;
person_name: string;
person_displayName: string;
is_elder: boolean;
is_ms: boolean;
talks: number[];
is_unavailable: boolean;
is_deleted: boolean;
email: string;
phone: string;
}[];
is_local: boolean;
is_deleted: boolean;
request_status: string;
}[];
branchReports: {
report_uid: string;
report: string;
service_year: string;
month: string;
details: {
isFinalized: boolean;
isSubmitted: boolean;
activePublishers: number;
weekendMeetingAttendanceAvg: number;
totalReports: number;
totalPlacements: number;
totalVideos: number;
totalHours: number;
totalReturnVisits: number;
totalBibleStudies: number;
publishersReports: number;
publishersPlacements: number;
publishersVideos: number;
publishersHours: number;
publishersReturnVisits: number;
publishersBibleStudies: number;
auxPioneersReports: number;
auxPioneersPlacements: number;
auxPioneersVideos: number;
auxPioneersHours: number;
auxPioneersReturnVisits: number;
auxPioneersBibleStudies: number;
FRReports: number;
FRPlacements: number;
FRVideos: number;
FRHours: number;
FRReturnVisits: number;
FRBibleStudies: number;
};
}[];
fieldServiceReports: {
uid: string;
service_year: string;
person_uid: string;
months: {
uid: string;
month_value: string;
hours: string;
hourCredit: string;
bibleStudies: number;
minutes: string;
placements: string;
returnVisits: string;
videos: string;
comments: string;
}[];
}[];
meetingAttendance: {
uid: string;
service_year: string;
month_value: string;
midweek_meeting: { index: number; count: string }[];
weekend_meeting: { index: number; count: string }[];
}[];
sources: {
weekOf: string;
mwb_week_date_locale: { [lang: string]: string };
mwb_weekly_bible_reading: { [lang: string]: string };
mwb_song_first: number;
mwb_tgw_talk: { [lang: string]: string };
mwb_tgw_bread: { [lang: string]: string };
mwb_ayf_count: number;
mwb_ayf_part1_type: { [lang: string]: number };
mwb_ayf_part1_time: number;
mwb_ayf_part1: { [lang: string]: string };
mwb_ayf_part2_type: { [lang: string]: number };
mwb_ayf_part2_time: number;
mwb_ayf_part2: { [lang: string]: string };
mwb_ayf_part3_type: { [lang: string]: number };
mwb_ayf_part3_time: number;
mwb_ayf_part3: { [lang: string]: string };
mwb_ayf_part4_type: { [lang: string]: number };
mwb_ayf_part4_time: number;
mwb_ayf_part4: { [lang: string]: string };
mwb_song_middle: number;
mwb_lc_count: number;
mwb_lc_count_override: number;
mwb_lc_part1_time: number;
mwb_lc_part1: { [lang: string]: string };
mwb_lc_part1_content: { [lang: string]: string };
mwb_lc_part1_time_override: number;
mwb_lc_part1_override: { [lang: string]: string };
mwb_lc_part1_content_override: { [lang: string]: string };
mwb_lc_part2_time: number;
mwb_lc_part2: { [lang: string]: string };
mwb_lc_part2_content: { [lang: string]: string };
mwb_lc_part2_time_override: number;
mwb_lc_part2_override: { [lang: string]: string };
mwb_lc_part2_content_override: { [lang: string]: string };
mwb_lc_cbs: { [lang: string]: string };
mwb_lc_cbs_time_override: string;
mwb_co_talk_title: string;
mwb_song_conclude: number;
mwb_song_conclude_override: string;
w_study_date_locale: { [lang: string]: string };
w_co_talk_title: string;
w_talk_title_override: string;
w_study_title: { [lang: string]: string };
w_study_opening_song: string;
w_study_concluding_song: string;
}[];
sched: {
weekOf: string;
week_type: number;
noMMeeting: boolean;
noWMeeting: boolean;
chairmanMM_A: string;
chairmanMM_B: string;
cbs_conductor: string;
tgw_talk: string;
tgw_gems: string;
lc_part1: string;
lc_part2: string;
lc_part3: string;
cbs_reader: string;
opening_prayerMM: string;
closing_prayerMM: string;
bRead_stu_A: string;
bRead_stu_B: string;
ass1_stu_A: string;
ass1_stu_B: string;
ass1_ass_A: string;
ass1_ass_B: string;
ass2_stu_A: string;
ass2_stu_B: string;
ass2_ass_A: string;
ass2_ass_B: string;
ass3_stu_A: string;
ass3_stu_B: string;
ass3_ass_A: string;
ass3_ass_B: string;
ass4_stu_A: string;
ass4_stu_B: string;
ass4_ass_A: string;
ass4_ass_B: string;
public_talk: number;
public_talk_title: string;
speaker_1: string;
speaker_2: string;
substitute_speaker: string;
chairman_WM: string;
opening_prayerWM: string;
wtstudy_reader: string;
is_visiting_speaker: boolean;
}[];
};
1 change: 1 addition & 0 deletions src/definition/meeting_attendance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type WeeklyAttendance = {
};

export type MeetingAttendanceType = {
_deleted: { value: boolean; updatedAt: string };
month_date: string;
week_1: WeeklyAttendance;
week_2: WeeklyAttendance;
Expand Down
Loading
Loading