diff --git a/POLICY_API_SETUP.md b/POLICY_API_SETUP.md new file mode 100644 index 00000000..28e256d6 --- /dev/null +++ b/POLICY_API_SETUP.md @@ -0,0 +1,444 @@ +# Policy API Setup - Complete Guide + +## 🎉 Summary + +Successfully created a comprehensive Policy Management System with: +- **3 Policy Types**: Privacy Policy, Terms of Use, Support Policy +- **Professional Enterprise Content**: 13-15 sections per policy with detailed legal and operational information +- **Full CRUD API**: RESTful API endpoints for managing policies +- **Dynamic Frontend**: React-based policy viewer with loading states and error handling + +--- + +## 📋 What Was Created + +### Backend (Django) + +#### 1. **Models** (`backend/policies/models.py`) +- `Policy`: Main policy document with metadata (type, title, version, effective date) +- `PolicySection`: Individual sections within each policy + +#### 2. **API Views** (`backend/policies/views.py`) +- `PolicyViewSet`: RESTful viewset for policy CRUD operations +- Endpoints support filtering by type +- Retrieve by ID or policy type + +#### 3. **Serializers** (`backend/policies/serializers.py`) +- `PolicySerializer`: Full policy with all sections +- `PolicyListSerializer`: Simplified list view +- `PolicySectionSerializer`: Individual section data + +#### 4. **Admin Interface** (`backend/policies/admin.py`) +- Full admin panel integration +- Inline section editing +- List filters and search functionality + +#### 5. **Management Command** (`backend/policies/management/commands/populate_policies.py`) +- Command: `python manage.py populate_policies` +- Creates/updates all 3 policies with professional content +- 42 total sections across all policies + +### Frontend (Next.js) + +#### 1. **API Service** (`lib/api/policyService.ts`) +- `getPolicies()`: Fetch all policies +- `getPolicyByType(type)`: Fetch specific policy +- `getPolicyById(id)`: Fetch by ID + +#### 2. **React Hook** (`lib/hooks/usePolicy.ts`) +- `usePolicies()`: Hook for all policies +- `usePolicy(type)`: Hook for specific policy +- `usePolicyById(id)`: Hook for policy by ID + +#### 3. **Policy Page** (`app/policy/page.tsx`) +- Dynamic page showing policy content +- Query parameter: `?type=privacy|terms|support` +- Loading and error states +- Responsive design +- Styled with inline styles + +#### 4. **Support Center Integration** (`components/pages/support/SupportCenterHero.tsx`) +- Added 3 new clickable cards: + - Privacy Policy → `/policy?type=privacy` + - Terms of Use → `/policy?type=terms` + - Support Policy → `/policy?type=support` + +--- + +## 🚀 Setup Complete! + +### What Was Done: + +```bash +# 1. Created migrations +python manage.py makemigrations policies +✅ Created: policies/migrations/0001_initial.py + +# 2. Applied migrations +python manage.py migrate policies +✅ Created database tables + +# 3. Populated with content +python manage.py populate_policies +✅ Privacy Policy: 13 sections +✅ Terms of Use: 14 sections +✅ Support Policy: 15 sections +``` + +--- + +## 📡 API Endpoints + +### Base URL +``` +http://localhost:8000/api/policies/ +``` + +### Available Endpoints + +#### 1. **List All Policies** +``` +GET /api/policies/ +``` +**Response:** +```json +[ + { + "id": 1, + "type": "privacy", + "title": "Privacy Policy", + "slug": "privacy", + "description": "Our commitment to protecting your privacy and personal data", + "last_updated": "2025-10-08", + "version": "2.1" + }, + ... +] +``` + +#### 2. **Get Specific Policy by Type** +``` +GET /api/policies/privacy/ +GET /api/policies/terms/ +GET /api/policies/support/ +``` +**Response:** +```json +{ + "id": 1, + "type": "privacy", + "title": "Privacy Policy", + "slug": "privacy", + "description": "Our commitment to protecting your privacy and personal data", + "last_updated": "2025-10-08", + "version": "2.1", + "effective_date": "2025-10-08", + "sections": [ + { + "id": 1, + "heading": "1. Introduction and Scope", + "content": "GNX Software Solutions...", + "order": 1 + }, + ... + ] +} +``` + +#### 3. **Get Policy by ID** +``` +GET /api/policies/{id}/ +``` + +--- + +## 🎨 Frontend Usage + +### 1. **Direct Navigation** +```typescript +// Link to policies from anywhere +Privacy Policy +Terms of Use +Support Policy +``` + +### 2. **Using the Hook** +```typescript +import { usePolicy } from '@/lib/hooks/usePolicy'; + +function MyComponent() { + const { data: policy, isLoading, error } = usePolicy('privacy'); + + if (isLoading) return
{section.content}
+{error?.message || 'The requested policy could not be found.'}
+ Return to Support Center ++ Last Updated: {new Date(policy.last_updated).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric' + })} +
+Version {policy.version}
++ Effective Date: {new Date(policy.effective_date).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric' + })} +
+{policy.description}
+ )} +If you have any questions about this policy, please don't hesitate to contact us.
+ Contact Us +- {bannerData?.description || "Trusted by Fortune 500 companies worldwide, we deliver enterprise-grade software solutions with 99.9% uptime SLA, SOC 2 Type II certification, and 24/7 dedicated support. Our mission-critical platforms power digital transformation across industries."} + {bannerData?.description || "GNX Soft Ltd delivers enterprise-grade software solutions for mission-critical industries with 99.9% uptime SLA and 24/7 dedicated support. Our platforms power digital transformation across Defense & Aerospace, Healthcare, Banking, Telecommunication, and other highly regulated sectors."}
{/* Key Metrics */} @@ -220,30 +220,6 @@ const AboutBanner = () => { - - {/* Trust Badges */} -SOC 2 Type II Certified
+Defense-Grade Protection
Create and track support requests
Find answers to common questions
Monitor your ticket progress