diff --git a/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.html b/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.html
index 0f255fe6e..79b6d2bef 100644
--- a/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.html
+++ b/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.html
@@ -1,5 +1,42 @@
Edit Translations
+ @if(translationRow){
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ } @else if(dataLoadError) {
+ {{dataLoadError}}
+ } @else {
+ Loading...
+ }
+ @if(editActionFeedbackMessage){
+ {{editActionFeedbackMessage}}
+ }
+
\ No newline at end of file
diff --git a/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.scss b/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.scss
index e69de29bb..ab42dae12 100644
--- a/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.scss
+++ b/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.scss
@@ -0,0 +1,26 @@
+.form-content{
+ display: flex;
+ flex-direction: column;
+ gap: 1.4rem;
+}
+.submitButton{
+ width: 7rem;
+ margin-bottom: 1rem;
+}
+.form-data{
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+
+}
+input {
+ padding: 8px;
+ color: var(--color-primary);
+ outline-color: var(--color-primary);
+ max-width: 300px;
+ display: block;
+ font-size: 0.9rem;
+ white-space: pre-wrap;
+ word-wrap: break-word;
+
+ }
\ No newline at end of file
diff --git a/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.ts b/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.ts
index f5075d86d..b110d3a5d 100644
--- a/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.ts
+++ b/apps/picsa-apps/dashboard/src/app/modules/translations/pages/edit/translations-edit.component.ts
@@ -1,33 +1,55 @@
import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';
- import { FormBuilder, FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
+import { FormBuilder, FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
// eslint-disable-next-line @nx/enforce-module-boundaries
- import type { Database } from '@picsa/server-types';
- import { PICSAFormValidators } from '@picsa/shared/modules/forms/validators';
+import type { Database } from '@picsa/server-types';
+import { PICSAFormValidators } from '@picsa/shared/modules/forms/validators';
- import { DashboardMaterialModule } from '../../../../material.module';
+import { DashboardMaterialModule } from '../../../../material.module';
// import { DashboardResourcesStorageLinkComponent } from '../../components/storage-link/storage-link.component';
import { TranslationDashboardService } from '../../translations.service';
-// type IResourceEntry = Database['public']['Tables']['resources']['Row'];
+type ITranslationEntry = Database['public']['Tables']['translations']['Row'];
@Component({
selector: 'dashboard-translations-edit',
standalone: true,
- imports: [
- CommonModule,
- DashboardMaterialModule,
- FormsModule,
- ReactiveFormsModule,
- ],
+ imports: [CommonModule, DashboardMaterialModule, FormsModule, ReactiveFormsModule],
templateUrl: './translations-edit.component.html',
styleUrls: ['./translations-edit.component.scss'],
})
export class TranslationsEditComponent {
- constructor(
- private service: TranslationDashboardService,
- private route: ActivatedRoute
- ) {}
+ translationRow: ITranslationEntry;
+ dataLoadError: string;
+ editActionFeedbackMessage: string;
+ constructor(private service: TranslationDashboardService, private route: ActivatedRoute) {
+ this.service.ready();
+ this.route.params.subscribe((params) => {
+ const id = params['id'];
+ this.service
+ .getTranslationById(id)
+ .then((data) => {
+ this.translationRow = data;
+ })
+ .catch((error) => {
+ console.error('Error fetching translation:', error);
+ this.dataLoadError = 'Failed to fetch translation.';
+ });
+ });
+ }
+ submitForm() {
+ this.service
+ .updateTranslationById(this.translationRow.id, this.translationRow)
+ .then((data) => {
+ if (data === 'Updated successfully') {
+ this.editActionFeedbackMessage = 'Updated successfully';
+ }
+ })
+ .catch((error) => {
+ console.error('Error editing translation:', error);
+ this.editActionFeedbackMessage = 'Failed to edit translation.';
+ });
+ }
}
diff --git a/apps/picsa-apps/dashboard/src/app/modules/translations/pages/home/translations.page.ts b/apps/picsa-apps/dashboard/src/app/modules/translations/pages/home/translations.page.ts
index 3e6d42056..30952b222 100644
--- a/apps/picsa-apps/dashboard/src/app/modules/translations/pages/home/translations.page.ts
+++ b/apps/picsa-apps/dashboard/src/app/modules/translations/pages/home/translations.page.ts
@@ -21,11 +21,8 @@ export class TranslationsPageComponent implements OnInit {
constructor(public service: TranslationDashboardService, private router: Router) {}
ngOnInit(): void {
this.service.ready();
-
}
goToRecord(row:ITranslationRow){
- console.log(row)
- this.router.navigate([`/`, row.id]);
-
+ this.router.navigate([`/translations`, row.id]);
}
}
diff --git a/apps/picsa-apps/dashboard/src/app/modules/translations/translations.service.ts b/apps/picsa-apps/dashboard/src/app/modules/translations/translations.service.ts
index 758941b9c..d727315a7 100644
--- a/apps/picsa-apps/dashboard/src/app/modules/translations/translations.service.ts
+++ b/apps/picsa-apps/dashboard/src/app/modules/translations/translations.service.ts
@@ -38,4 +38,24 @@ export class TranslationDashboardService extends PicsaAsyncService {
}
this.translations = data || [];
}
+
+ // update a translation record by ID
+ public async updateTranslationById(id: number, updatedData: Partial): Promise {
+ const { data, error } = await this.supabaseService.db.table('translations').update(updatedData).eq('id', id);
+ if (error) {
+ throw error;
+ }
+ return "Updated successfully";
+ }
+
+ // Fetch a translation record by ID
+ public async getTranslationById(id: number): Promise {
+ const { data, error } = await this.supabaseService.db.table('translations').select('*').eq('id', id).single();
+ if (error) {
+ throw error;
+ }
+
+ return data;
+ }
+
}