Snippets Collections
#include <stdio.h>

void draw_inverted_triangle(int height) {
    for (int i = 0; i < height; ++i) {
        // Print leading spaces
        for (int j = 0; j < i; ++j) {
            putchar(' ');
        }

        // Print backslash
        putchar('\\');

        // Print inner spaces
        for (int j = 0; j < 2 * (height - i - 1); ++j) {
            putchar(' ');
        }

        // Print forward slash
        putchar('/');

        // Move to the next line
        putchar('\n');
    }
}

int main() {
    int height;

    // Get the height from the user
    printf("enter height: \n");
    scanf("%d", &height);

    // Print the top line of underscores
    for (int i = 0; i < 2 * height; ++i) {
        putchar('_');
    }
    putchar('\n');

    // Draw the inverted triangle
    draw_inverted_triangle(height);

    return 0;
}
ListNode* reverseList(ListNode* head) {
        stack<int> s;
        ListNode* t=head;
           while(t!=NULL)
           {
             s.push(t->val);
             t=t->next;
           }
           t=head;
             while(t!=NULL)
           {
             t->val = s.top();
             s.pop();
             t=t->next;
           }
           return head;
    
int search(vector<int>& nums, int target) {
        int low = 0;
        int n = nums.size();
        int high = n-1;
        
        while(high>=low){
            int mid = (high+low)/2;
        if(nums[mid]==target)return mid;
        else if(target>nums[mid])
        {
            low = mid+1;
        }
        else
        {
            high=mid-1;
        }
        }
        return -1;
    }
bool cmp(pair<int,int> a,pair<int,int> b)
{return a>b;}
sort(p.begin(),p.end(),cmp);
bool cmp(int a,int b)
{
  return a>b;
}
sort(v.begin(),v.end(),cmp);
//Remember in sort use cmp not cmp()
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Custom Menu')
      .addItem('Update Master Summary', 'updateMasterSummaryBasedOnConfiguration')
      .addItem('Update Configuration', 'updateConfiguration')
      .addItem('Update Consolidated Master', 'updateConsolidatedMaster')
      .addItem('Update Consolidated Rejected', 'updateConsolidatedRejected')
      .addItem('Synchronize Column with Template Dev Sheet', 'synchronizeHeadersWithTemplate')
      .addItem('Synchronize Column Name with Template Dev Sheet', 'synchronizeHeaderNamesWithTemplate') 

      .addToUi();
}

function updateMasterSummaryBasedOnConfiguration() {
  var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE", "TERMINATED"];

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var masterSheet = spreadsheet.getSheetByName("Master Summary");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Clear existing content in Master Summary sheet excluding the first column
  var rangeToClear = masterSheet.getRange("B:ZZ");
  rangeToClear.clear();

  // Get tab names and their statuses from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var tabNames = [];
  var tabStatuses = [];

  // Populate tabNames and tabStatuses arrays
  for (var i = 0; i < rangeData.length; i++) {
    var tabName = rangeData[i][0];
    var status = rangeData[i][1];
    if (tabName && status) { // Ensure both tab name and status exist
      tabNames.push(tabName);
      tabStatuses.push(status.toLowerCase()); // Convert status to lowercase for consistency
    }
  }

  // Set the headers for active tabs and count status for each tab
  var activeTabs = tabNames.filter(function(_, index) {
    return tabStatuses[index] === "active";
  });

  // Set the headers for active tabs in Master Summary
  var headerRowData = ['Status', 'Total Parts Count'].concat(activeTabs);
  masterSheet.getRange(1, 1, 1, headerRowData.length).setValues([headerRowData]);

  // Create a 2D array to hold all the data to be written to the Master Summary sheet
  var outputData = statusNames.map(function(statusName) {
    return [statusName, 0].concat(new Array(activeTabs.length).fill(0));
  });

  // Add a row for the total counts
  var totalCountsRow = ['TotTotal Parts Count', 0].concat(new Array(activeTabs.length).fill(0));
  outputData.push(totalCountsRow);

  // Iterate over active tabs and count the statuses
  activeTabs.forEach(function(tabName, tabIndex) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      var values = sheet.getRange("A:A").getValues().flat();
      var statusCounts = statusNames.reduce(function(counts, status) {
        counts[status] = 0;
        return counts;
      }, {});

      // Count the statuses
      values.forEach(function(value) {
        var upperValue = value.toString().toUpperCase();
        if (statusCounts.hasOwnProperty(upperValue)) {
          statusCounts[upperValue]++;
        }
      });

      // Fill the outputData array with counts
      statusNames.forEach(function(statusName, statusIndex) {
        var count = statusCounts[statusName] || 0;
        outputData[statusIndex][tabIndex + 2] = count; // Insert count into corresponding column
        outputData[statusIndex][1] += count; // Add count to the total column
        totalCountsRow[tabIndex + 2] += count; // Add count to the total row
      });
      totalCountsRow[1] += totalCountsRow[tabIndex + 2]; // Add total of current tab to the grand total
    }
  });

  // Write the collected data to the sheet in one operation
  masterSheet.getRange(2, 1, outputData.length, outputData[0].length).setValues(outputData);
}

function updateConfiguration() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Fetch existing sheet names from Configuration sheet
  var existingSheetNames = configSheet.getRange("A2:A").getValues().flat().filter(function(name) {
    return name; // Filter out empty values
  });

  // Fetch all sheet names excluding "Configuration" and "Master Summary"
  var allSheetNames = spreadsheet.getSheets().map(function(sheet) {
    return sheet.getName();
  }).filter(function(name) {
    return name !== "Configuration" && name !== "Master Summary";
  });

  // Filter out existing sheet names from all sheet names
  var newSheetNames = allSheetNames.filter(function(name) {
    return !existingSheetNames.includes(name);
  });

  // Append new sheet names to the Configuration sheet
  if (newSheetNames.length > 0) {
    var startRow = existingSheetNames.length + 2;
    configSheet.getRange(startRow, 1, newSheetNames.length, 1).setValues(newSheetNames.map(function(name) {
      return [name];
    }));

    // Calculate status for new sheet names
    var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE", "TERMINATED"];

    for (var k = 0; k < newSheetNames.length; k++) {
      var tabName = newSheetNames[k];
      var isActive = false;

      // Check each status for the current sheet
      for (var i = 0; i < statusNames.length; i++) {
        var status = statusNames[i];
        var count = getCountForStatusInSheet(status, tabName);
        if (count > 0) {
          isActive = true;
          break;
        }
      }

      // Set the status for the current sheet in the Configuration sheet
      var statusCell = configSheet.getRange(startRow + k, 2);
      statusCell.setValue(isActive ? "Active" : "Inactive");
      var statusValidationRule = SpreadsheetApp.newDataValidation()
          .requireValueInList(["Active", "Inactive"], true)
          .build();
      statusCell.setDataValidation(statusValidationRule);
      statusCell.setFontColor(isActive ? "#00FF00" : "#FF0000");
    }
  }
}

function getCountForStatusInSheet(status, sheetName) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
  
  // Return 0 if sheet doesn't exist
  if (!sheet) {
    return 0;
  }

  var statusColumn = sheet.getRange("A:A").getValues().flat(); // Assuming statuses are in column A

  // Count occurrences of status
  var count = statusColumn.filter(function(value) {
    return value === status;
  }).length;

  return count;
}

 
function updateConsolidatedMaster() {
  var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE"];
  var columnsToCopy = ["Status", "Start Date", "Part Type", "HOL P/N", "OE#", "ALT OE", "MAM Status (change to Dev)", "FP Status (Change to Electronically Announced)", "PartCat Status (Changed to Electronically Announced)", "Interchange", "Interchange Completion", "Parts List/RFQ Submitted to Warren", "Parts List/RFQ Returned to Holstein", "Production Sourced Part is requested from Warren", "ETA of Sample", "Date Prod Sample Delivered to Holstein", "Factory Code"];

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();

  try {
    var masterSheet = spreadsheet.getSheetByName("Consolidated Master");
    var configSheet = spreadsheet.getSheetByName("Configuration");

    // Clear existing content in Consolidated Master sheet
    masterSheet.clear();

    // Get active tab names and their statuses from the Configuration sheet
    var rangeData = configSheet.getRange("A:B").getValues();
    var activeTabs = rangeData.filter(function(row) {
      return row[1] && row[1].toLowerCase() === "active";
    }).map(function(row) {
      return row[0];
    });

    // Initialize variables
    var allData = [];
    var rowIndex = 2;

    // Insert headers
    allData.push(columnsToCopy.concat("MOQ")); // Add MOQ to the header row
    masterSheet.getRange(1, 1, 1, allData[0].length).setValues([allData[0]]);

    // Iterate through active tabs
    activeTabs.forEach(function(tabName) {
      var sheet = spreadsheet.getSheetByName(tabName);
      if (sheet) {
        var sheetData = sheet.getDataRange().getValues();

        // Get column names
        var columnNames = sheetData[1];

        // Iterate through rows (excluding header rows)
        sheetData.slice(2).forEach(function(row) {
          var status = row[0];

          // Check if status is in the list and copy relevant data
          if (statusNames.includes(status)) {
            var rowData = [status];
            columnsToCopy.forEach(function(col) {
              var colIndex = columnNames.indexOf(col);
              if (colIndex !== -1) {
                rowData.push(row[colIndex]);
              }
            });

            // Find MOQ column index and convert date to "1" if found
            var moqIndex = columnNames.indexOf("MOQ");
            if (moqIndex !== -1) {
              var moqValue = row[moqIndex];
              if (typeof moqValue === 'object' && moqValue instanceof Date) {
                rowData.push("1");
              } else {
                rowData.push(moqValue);
              }
            } else {
              rowData.push(""); // Add empty string if MOQ column not found
            }
            allData.push(rowData);
          }
        });
      }
    });

    // Insert all data at once
    if (allData.length > 1) { // Check if there's data to insert
      masterSheet.getRange(rowIndex, 1, allData.length - 1, allData[0].length).setValues(allData.slice(1));
    }
  } catch (error) {
    // Handle errors gracefully (e.g., log error or display message to user)
    console.error("Error occurred:", error);
  }
}


function updateConsolidatedRejected() {
  var statusNames = ["PIES REJECTED"];
  var columnsToCopy = ["STATUS", "Part Type", "HOL P/N", "OE#", "QC Inspection/PIES Collection", "HOL Feedback Sent", "New Sample Requested", "New Sample Received"];
 
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var masterSheet = spreadsheet.getSheetByName("Consolidated Rejected");
  var configSheet = spreadsheet.getSheetByName("Configuration");
 
  // Clear existing content in Consolidated Rejected sheet
  masterSheet.clear();
 
  // Get tab names and their statuses from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });
 
  // Initialize a variable to keep track of the row to insert data into
  var rowIndex = 2;
 
  // Insert headers for the Consolidated Rejected sheet
  var headers = columnsToCopy;
  masterSheet.getRange(1, 1, 1, headers.length).setValues([headers]);
 
  // Iterate through each active tab
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      var sheetData = sheet.getDataRange().getValues();
 
      // Get the column names from the second row
      var columnNames = sheetData[1];
 
      // Iterate through each row in the sheet
      sheetData.forEach(function(row, rowIdx) {
        if (rowIdx === 0 || rowIdx === 1) return; // Skip the header rows
 
        var status = row[0]; // Assuming status is in the first column (A)
 
        // If the status is "TERMINATED" or "PIES REJECTED", add it to the Consolidated Rejected sheet
        if (statusNames.includes(status)) {
          var rowData = [];
 
          // Insert the data into the Consolidated Rejected sheet
          columnsToCopy.forEach(function(col) {
            var colIndexInSheet = columnNames.indexOf(col);
            if (colIndexInSheet !== -1) {
              rowData.push(row[colIndexInSheet]);
            } else if (col === "STATUS") {
              rowData.push(status); // Add status directly for the STATUS column
            } else {
              rowData.push(''); // Fill in with an empty string if the column is not found
            }
          });
 
          masterSheet.getRange(rowIndex, 1, 1, rowData.length).setValues([rowData]);
          rowIndex++;
        }
      });
    }
  });
}

function synchronizeHeadersWithTemplate() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var templateSheet = spreadsheet.getSheetByName("Template Development Sheet");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Error handling for missing sheets
  if (!templateSheet) {
    SpreadsheetApp.getUi().alert('Error: "Template Development" sheet not found.');
    return;
  }
  if (!configSheet) {
    SpreadsheetApp.getUi().alert('Error: "Configuration" sheet not found.');
    return;
  }

  // Get the first two header rows from the Template Development sheet
  var templateHeaders = templateSheet.getRange(1, 1, 2, templateSheet.getLastColumn()).getValues();
  
  // Get active tab names from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });

  // Iterate through each active tab and synchronize headers
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      // Get the current headers of the active tab
      var currentHeaders = sheet.getRange(1, 1, 2, sheet.getLastColumn()).getValues();

      // Find new columns that are in the template but not in the current sheet
      var newColumns = [];
      var existingColumns = [];
      templateHeaders[1].forEach(function(header, index) {
        if (header) {
          var currentHeaderIndex = currentHeaders[1].indexOf(header);
          if (currentHeaderIndex === -1) {
            newColumns.push({
              header: header,
              templateColumnIndex: index
            });
          } else {
            existingColumns.push({
              currentHeaderIndex: currentHeaderIndex,
              templateColumnIndex: index
            });
          }
        }
      });

      // If there are new columns, add them to the current sheet
      if (newColumns.length > 0) {
        newColumns.forEach(function(column) {
          var columnIndex = column.templateColumnIndex + 1; // Adjust for 1-based index in Sheets
          
          // Insert a new column at the correct position
          sheet.insertColumnBefore(columnIndex);

          // Set the new header values
          sheet.getRange(1, columnIndex, 2, 1).setValues([
            [templateHeaders[0][column.templateColumnIndex]],
            [column.header]
          ]);

          // Shift data to include the new column
          var dataRange = sheet.getRange(3, columnIndex, sheet.getLastRow() - 2, 1);
          var dataValues = dataRange.getValues();
          for (var row = 0; row < dataValues.length; row++) {
            dataValues[row][0] = ""; // Set the new column values to empty
          }
          dataRange.setValues(dataValues);
        });
      }

      // Find columns that are in the current sheet but not in the template and remove them
      var columnsToDelete = [];
      currentHeaders[1].forEach(function(header, index) {
        if (header && !templateHeaders[1].includes(header)) {
          columnsToDelete.push(index + 1); // Adjust for 1-based index in Sheets
        }
      });

      // If there are columns to delete, remove them from the current sheet
      if (columnsToDelete.length > 0) {
        // Sort columns to delete in descending order to avoid shifting issues
        columnsToDelete.sort(function(a, b) { return b - a; });

        columnsToDelete.forEach(function(columnIndex) {
          sheet.deleteColumn(columnIndex);
        });
      }
    }
  });
}



function synchronizeHeaderNamesWithTemplate() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var templateSheet = spreadsheet.getSheetByName("Template Development Sheet");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Error handling for missing sheets
  if (!templateSheet) {
    SpreadsheetApp.getUi().alert('Error: "Template Development" sheet not found.');
    return;
  }
  if (!configSheet) {
    SpreadsheetApp.getUi().alert('Error: "Configuration" sheet not found.');
    return;
  }

  // Get the header rows from the Template Development sheet
  var templateHeaders = templateSheet.getRange(1, 1, 2, templateSheet.getLastColumn()).getValues();

  // Get active tab names from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });

  // Iterate through each active tab and synchronize header names
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      // Get the current headers of the active tab
      var currentHeaders = sheet.getRange(1, 1, 2, sheet.getLastColumn()).getValues();

      // Iterate through each header in the template sheet
      templateHeaders.forEach(function(templateRow, rowIndex) {
        templateRow.forEach(function(templateHeader, columnIndex) {
          var currentHeader = currentHeaders[rowIndex][columnIndex];
          // If the header name in the template sheet is different from the header name in the active tab
          if (templateHeader !== currentHeader) {
            // Update the header name in the active tab
            sheet.getRange(rowIndex + 1, columnIndex + 1).setValue(templateHeader);
          }
        });
      });
    }
  });
}


Example 1. without virtual keyword / Using scope resolution
#include <iostream>

using namespace std;

class classA {
    public:
    int a;
};

class classB : public classA {
    public:
    int b;
};
class classC : public classA {
    public:
    int c;
};
class classD : public classB, public classC {
    public:
    int d;
    
};

int main() {
   
   classD objD;
   //objD.a; Error
   
   objD.classB::a = 100; // this way is correct
   objD.classC::a = 200;
   
   cout<<"A from classB = "<<objD.classB::a<<endl;
   cout<<"A from classc = "<<objD.classC::a<<endl;
   objD.b = 10;
   objD.c = 20;
   objD.d = 30;
   cout<<"B = "<<objD.b<<endl;
   cout<<"C = "<<objD.c<<endl;
   cout<<"D = "<<objD.d<<endl;
   
    
    return 0;
}
//Output:
A from classB = 100
A from classc = 200
B = 10
C = 20
D = 30

_______________________________________________________________-
  
  Example 2. Using Virtual Kwyeord
  #include <iostream>

using namespace std;

class classA {
    public:
    int a;
};

class classB : virtual public classA {
    public:
    int b;
};
class classC : virtual public classA {
    public:
    int c;
};
class classD : public classB, public classC {
    public:
    int d;
    
};

int main() {
   
   classD objD;
   
   objD.a = 100; // is correct using virtual keyword. we can access a value from one copy.
   cout<<"Using Virtual keyword: "<<endl;
   classB objB;
   objB.a =600;
   cout<<"A from class B = "<<objB.a<<endl;
   cout<<"A from class D = "<<objD.a<<endl;
   objD.b = 10;
   objD.c = 20;
   objD.d = 30;
   cout<<"B = "<<objD.b<<endl;
   cout<<"C = "<<objD.c<<endl;
   cout<<"D = "<<objD.d<<endl;
   
    
    return 0;
}
//Output:
Using Virtual keyword: 
A from class B = 600
A from class D = 100
B = 10
C = 20
D = 30
<div class="ag-format-container">

  <div class="ag-courses_box">

    <div class="ag-courses_item">

      <a href="#" class="ag-courses-item_link">

        <div class="ag-courses-item_bg"></div>

​

        <div class="ag-courses-item_title">

          UI/Web&amp;Graph design for teenagers -&#0;years old

        </div>

​
11
        <div class="ag-courses-item_date-box">

          Start:

          <span class="ag-courses-item_date">

            04.11.

          </span>
16
        </div>
17
      </a>

    </div>

​
20
    <div class="ag-courses_item">

      <a href="#" class="ag-courses-item_link">
22
        <div class="ag-courses-item_bg"></div>

​
.ag-format-container {

  width: 2px;

  margin: 0 auto;
4
}

​

​

body {

  background-color: #000;

}

.ag-courses_box {
11
  display: -webkit-box;

  display: -ms-flexbox;

  display: flex;

  -webkit-box-align: start;

  -ms-flex-align: start;

  align-items: flex-start;

  -ms-flex-wrap: wrap;

  flex-wrap: wrap;

​

  padding: 50px 0;

}

.ag-courses_item {

  -ms-flex-preferred-size: calc(33.33333% - 30px);

  flex-basis: calc(33.33333% - 30px);
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Custom Menu')
      .addItem('Update Master Summary', 'updateMasterSummaryBasedOnConfiguration')
      .addItem('Update Configuration', 'updateConfiguration')
      .addItem('Update Consolidated Master', 'updateConsolidatedMaster')
      .addItem('Update Consolidated Rejected', 'updateConsolidatedRejected')
      .addItem('Synchronize Column with Template Dev Sheet', 'synchronizeHeadersWithTemplate')
      .addItem('Synchronize Column Name with Template Dev Sheet', 'synchronizeHeaderNamesWithTemplate') 


      .addToUi();
}

function updateMasterSummaryBasedOnConfiguration() {
  var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE", "TERMINATED"];

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var masterSheet = spreadsheet.getSheetByName("Master Summary");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Clear existing content in Master Summary sheet excluding the first column
  var rangeToClear = masterSheet.getRange("B:ZZ");
  rangeToClear.clear();

  // Get tab names and their statuses from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var tabNames = [];
  var tabStatuses = [];

  // Populate tabNames and tabStatuses arrays
  for (var i = 0; i < rangeData.length; i++) {
    var tabName = rangeData[i][0];
    var status = rangeData[i][1];
    if (tabName && status) { // Ensure both tab name and status exist
      tabNames.push(tabName);
      tabStatuses.push(status.toLowerCase()); // Convert status to lowercase for consistency
    }
  }

  // Set the headers for active tabs and count status for each tab
  var activeTabs = tabNames.filter(function(_, index) {
    return tabStatuses[index] === "active";
  });

  // Set the headers for active tabs in Master Summary
  var headerRowData = ['Status', 'Total Parts Count'].concat(activeTabs);
  masterSheet.getRange(1, 1, 1, headerRowData.length).setValues([headerRowData]);

  // Create a 2D array to hold all the data to be written to the Master Summary sheet
  var outputData = statusNames.map(function(statusName) {
    return [statusName, 0].concat(new Array(activeTabs.length).fill(0));
  });

  // Add a row for the total counts
  var totalCountsRow = ['TotTotal Parts Count', 0].concat(new Array(activeTabs.length).fill(0));
  outputData.push(totalCountsRow);

  // Iterate over active tabs and count the statuses
  activeTabs.forEach(function(tabName, tabIndex) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      var values = sheet.getRange("A:A").getValues().flat();
      var statusCounts = statusNames.reduce(function(counts, status) {
        counts[status] = 0;
        return counts;
      }, {});

      // Count the statuses
      values.forEach(function(value) {
        var upperValue = value.toString().toUpperCase();
        if (statusCounts.hasOwnProperty(upperValue)) {
          statusCounts[upperValue]++;
        }
      });

      // Fill the outputData array with counts
      statusNames.forEach(function(statusName, statusIndex) {
        var count = statusCounts[statusName] || 0;
        outputData[statusIndex][tabIndex + 2] = count; // Insert count into corresponding column
        outputData[statusIndex][1] += count; // Add count to the total column
        totalCountsRow[tabIndex + 2] += count; // Add count to the total row
      });
      totalCountsRow[1] += totalCountsRow[tabIndex + 2]; // Add total of current tab to the grand total
    }
  });

  // Write the collected data to the sheet in one operation
  masterSheet.getRange(2, 1, outputData.length, outputData[0].length).setValues(outputData);
}

function updateConfiguration() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Fetch existing sheet names from Configuration sheet
  var existingSheetNames = configSheet.getRange("A2:A").getValues().flat().filter(function(name) {
    return name; // Filter out empty values
  });

  // Fetch all sheet names excluding "Configuration" and "Master Summary"
  var allSheetNames = spreadsheet.getSheets().map(function(sheet) {
    return sheet.getName();
  }).filter(function(name) {
    return name !== "Configuration" && name !== "Master Summary";
  });

  // Filter out existing sheet names from all sheet names
  var newSheetNames = allSheetNames.filter(function(name) {
    return !existingSheetNames.includes(name);
  });

  // Append new sheet names to the Configuration sheet
  if (newSheetNames.length > 0) {
    var startRow = existingSheetNames.length + 2;
    configSheet.getRange(startRow, 1, newSheetNames.length, 1).setValues(newSheetNames.map(function(name) {
      return [name];
    }));

    // Calculate status for new sheet names
    var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE", "TERMINATED"];

    for (var k = 0; k < newSheetNames.length; k++) {
      var tabName = newSheetNames[k];
      var isActive = false;

      // Check each status for the current sheet
      for (var i = 0; i < statusNames.length; i++) {
        var status = statusNames[i];
        var count = getCountForStatusInSheet(status, tabName);
        if (count > 0) {
          isActive = true;
          break;
        }
      }

      // Set the status for the current sheet in the Configuration sheet
      var statusCell = configSheet.getRange(startRow + k, 2);
      statusCell.setValue(isActive ? "Active" : "Inactive");
      var statusValidationRule = SpreadsheetApp.newDataValidation()
          .requireValueInList(["Active", "Inactive"], true)
          .build();
      statusCell.setDataValidation(statusValidationRule);
      statusCell.setFontColor(isActive ? "#00FF00" : "#FF0000");
    }
  }
}

function getCountForStatusInSheet(status, sheetName) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
  
  // Return 0 if sheet doesn't exist
  if (!sheet) {
    return 0;
  }

  var statusColumn = sheet.getRange("A:A").getValues().flat(); // Assuming statuses are in column A

  // Count occurrences of status
  var count = statusColumn.filter(function(value) {
    return value === status;
  }).length;

  return count;
}

 
function updateConsolidatedMaster() {
  var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE"];
  var columnsToCopy = ["Status", "Start Date", "Part Type", "HOL P/N", "OE#", "ALT OE", "MAM Status (change to Dev)", "FP Status (Change to Electronically Announced)", "PartCat Status (Changed to Electronically Announced)", "Interchange", "Interchange Completion", "Parts List/RFQ Submitted to Warren", "Parts List/RFQ Returned to Holstein", "Production Sourced Part is requested from Warren", "ETA of Sample", "Date Prod Sample Delivered to Holstein", "Factory Code"];

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();

  try {
    var masterSheet = spreadsheet.getSheetByName("Consolidated Master");
    var configSheet = spreadsheet.getSheetByName("Configuration");

    // Clear existing content in Consolidated Master sheet
    masterSheet.clear();

    // Get active tab names and their statuses from the Configuration sheet
    var rangeData = configSheet.getRange("A:B").getValues();
    var activeTabs = rangeData.filter(function(row) {
      return row[1] && row[1].toLowerCase() === "active";
    }).map(function(row) {
      return row[0];
    });

    // Initialize variables
    var allData = [];
    var rowIndex = 2;

    // Insert headers
    allData.push(columnsToCopy.concat("MOQ")); // Add MOQ to the header row
    masterSheet.getRange(1, 1, 1, allData[0].length).setValues([allData[0]]);

    // Iterate through active tabs
    activeTabs.forEach(function(tabName) {
      var sheet = spreadsheet.getSheetByName(tabName);
      if (sheet) {
        var sheetData = sheet.getDataRange().getValues();

        // Get column names
        var columnNames = sheetData[1];

        // Iterate through rows (excluding header rows)
        sheetData.slice(2).forEach(function(row) {
          var status = row[0];

          // Check if status is in the list and copy relevant data
          if (statusNames.includes(status)) {
            var rowData = [status];
            columnsToCopy.forEach(function(col) {
              var colIndex = columnNames.indexOf(col);
              if (colIndex !== -1) {
                rowData.push(row[colIndex]);
              }
            });

            // Find MOQ column index and convert date to "1" if found
            var moqIndex = columnNames.indexOf("MOQ");
            if (moqIndex !== -1) {
              var moqValue = row[moqIndex];
              if (typeof moqValue === 'object' && moqValue instanceof Date) {
                rowData.push("1");
              } else {
                rowData.push(moqValue);
              }
            } else {
              rowData.push(""); // Add empty string if MOQ column not found
            }
            allData.push(rowData);
          }
        });
      }
    });

    // Insert all data at once
    if (allData.length > 1) { // Check if there's data to insert
      masterSheet.getRange(rowIndex, 1, allData.length - 1, allData[0].length).setValues(allData.slice(1));
    }
  } catch (error) {
    // Handle errors gracefully (e.g., log error or display message to user)
    console.error("Error occurred:", error);
  }
}


function updateConsolidatedRejected() {
  var statusNames = ["PIES REJECTED"];
  var columnsToCopy = ["STATUS", "Part Type", "HOL P/N", "OE#", "QC Inspection/PIES Collection", "HOL Feedback Sent", "New Sample Requested", "New Sample Received"];
 
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var masterSheet = spreadsheet.getSheetByName("Consolidated Rejected");
  var configSheet = spreadsheet.getSheetByName("Configuration");
 
  // Clear existing content in Consolidated Rejected sheet
  masterSheet.clear();
 
  // Get tab names and their statuses from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });
 
  // Initialize a variable to keep track of the row to insert data into
  var rowIndex = 2;
 
  // Insert headers for the Consolidated Rejected sheet
  var headers = columnsToCopy;
  masterSheet.getRange(1, 1, 1, headers.length).setValues([headers]);
 
  // Iterate through each active tab
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      var sheetData = sheet.getDataRange().getValues();
 
      // Get the column names from the second row
      var columnNames = sheetData[1];
 
      // Iterate through each row in the sheet
      sheetData.forEach(function(row, rowIdx) {
        if (rowIdx === 0 || rowIdx === 1) return; // Skip the header rows
 
        var status = row[0]; // Assuming status is in the first column (A)
 
        // If the status is "TERMINATED" or "PIES REJECTED", add it to the Consolidated Rejected sheet
        if (statusNames.includes(status)) {
          var rowData = [];
 
          // Insert the data into the Consolidated Rejected sheet
          columnsToCopy.forEach(function(col) {
            var colIndexInSheet = columnNames.indexOf(col);
            if (colIndexInSheet !== -1) {
              rowData.push(row[colIndexInSheet]);
            } else if (col === "STATUS") {
              rowData.push(status); // Add status directly for the STATUS column
            } else {
              rowData.push(''); // Fill in with an empty string if the column is not found
            }
          });
 
          masterSheet.getRange(rowIndex, 1, 1, rowData.length).setValues([rowData]);
          rowIndex++;
        }
      });
    }
  });
}

function synchronizeHeadersWithTemplate() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var templateSheet = spreadsheet.getSheetByName("Template Development Sheet");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Error handling for missing sheets
  if (!templateSheet) {
    SpreadsheetApp.getUi().alert('Error: "Template Development" sheet not found.');
    return;
  }
  if (!configSheet) {
    SpreadsheetApp.getUi().alert('Error: "Configuration" sheet not found.');
    return;
  }

  // Get the first two header rows from the Template Development sheet
  var templateHeaders = templateSheet.getRange(1, 1, 2, templateSheet.getLastColumn()).getValues();
  
  // Get active tab names from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });

  // Iterate through each active tab and synchronize headers
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      // Get the current headers of the active tab
      var currentHeaders = sheet.getRange(1, 1, 2, sheet.getLastColumn()).getValues();

      // Find new columns that are in the template but not in the current sheet
      var newColumns = [];
      templateHeaders[1].forEach(function(header, index) {
        if (header && !currentHeaders[1].includes(header)) {
          newColumns.push({
            header: header,
            templateColumnIndex: index
          });
        }
      });

      // If there are new columns, add them to the current sheet
      if (newColumns.length > 0) {
        newColumns.forEach(function(column) {
          var columnIndex = column.templateColumnIndex + 1; // Adjust for 1-based index in Sheets
          
          // Insert a new column at the correct position
          sheet.insertColumnBefore(columnIndex);

          // Set the new header values
          sheet.getRange(1, columnIndex, 2, 1).setValues([
            [templateHeaders[0][column.templateColumnIndex]],
            [column.header]
          ]);

          // Shift data to include the new column
          var dataRange = sheet.getRange(3, columnIndex, sheet.getLastRow() - 2, 1);
          var dataValues = dataRange.getValues();
          for (var row = 0; row < dataValues.length; row++) {
            dataValues[row][0] = ""; // Set the new column values to empty
          }
          dataRange.setValues(dataValues);
        });
      }
    }
  });
}

function synchronizeHeaderNamesWithTemplate() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var templateSheet = spreadsheet.getSheetByName("Template Development Sheet");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Error handling for missing sheets
  if (!templateSheet) {
    SpreadsheetApp.getUi().alert('Error: "Template Development" sheet not found.');
    return;
  }
  if (!configSheet) {
    SpreadsheetApp.getUi().alert('Error: "Configuration" sheet not found.');
    return;
  }

  // Get the header rows from the Template Development sheet
  var templateHeaders = templateSheet.getRange(1, 1, 2, templateSheet.getLastColumn()).getValues();

  // Get active tab names from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });

  // Iterate through each active tab and synchronize header names
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      // Get the current headers of the active tab
      var currentHeaders = sheet.getRange(1, 1, 2, sheet.getLastColumn()).getValues();

      // Iterate through each header in the template sheet
      templateHeaders.forEach(function(templateRow, rowIndex) {
        templateRow.forEach(function(templateHeader, columnIndex) {
          var currentHeader = currentHeaders[rowIndex][columnIndex];
          // If the header name in the template sheet is different from the header name in the active tab
          if (templateHeader !== currentHeader) {
            // Update the header name in the active tab
            sheet.getRange(rowIndex + 1, columnIndex + 1).setValue(templateHeader);
          }
        });
      });
    }
  });
}

#include <stdio.h>
#include <string.h>

enum Password_Strength
{
    TOO_WEAK,
    STRONG_ENOUGH
};

enum Password_Strength is_secure_password(char* password);

int main(void)
{
    char test_password[32];
 
    do
    {
        printf("Choose a password: \n");
        scanf("%31s", test_password);
    }
    while (is_secure_password(test_password) == TOO_WEAK);
 
    printf("%s is secure enough!\n", test_password);
 
    return 0;
}

    int is_upper(char ch)
{
    return (ch >= 'A' && ch <= 'Z');
}

int is_lower(char ch)
{
    return (ch >= 'a' && ch <= 'z');
}

int is_digit(char ch)
{
    return (ch >= '0' && ch <= '9');
}
enum Password_Strength is_secure_password(char* password)
{
    int length = strlen(password);
    int upper_count = 0;
    int lower_count = 0;
    int digit_count = 0;

    if (length < 8 || length > 12) // Minimum length requirement
    {
        return TOO_WEAK;
    }



    for (int i = 0; i < length; i++)
    {
        if (is_upper(password[i]))
            upper_count++;
        else if (is_lower(password[i]))
            lower_count++;
        else if (is_digit(password[i]))
            digit_count++;
    }

    if (upper_count >= 2 && lower_count >= 2 && digit_count >= 1)
    {
        return STRONG_ENOUGH;
    }
    else
    {
        return TOO_WEAK;
    }
 

}
{
  // This is all that matters
  "workbench.colorTheme": "Cobalt2",
  // The Cursive font is operator Mono, it's $200 and you need to buy it to get the cursive. Dank Mono or Victor Mono are good alternatives
  "editor.fontFamily": "Operator Mono, Menlo, Monaco, 'Courier New', monospace",
  "editor.fontSize": 17,
  "editor.lineHeight": 25,
  "editor.letterSpacing": 0.5,
  "files.trimTrailingWhitespace": true,
  "editor.fontWeight": "400",
  "prettier.eslintIntegration": true,
  "editor.cursorStyle": "line",
  "editor.cursorWidth": 5,
  "editor.cursorBlinking": "solid",
  "editor.renderWhitespace": "all",
}
none_of(v.begin(),v.end(),[](int x){return x>0;});
//it returns boolean value
any_of(v.begin(),v.end(),[](int x){return x%2==0;});
//it returns boolean value
all_of(v.begin(),v.end(),[](int x){return x>0;});
//it returns boolean value
it = find(v.begin(),v.end(),num);
//if not found it returns v.end();
int sum = accumulated(v.begin(),v.end(),0);
int a =*(max_element(v.begin(),v.end()));
int a =*(min_element(v.begin(),v.end()));
pair<int, int> findNonDivisiblePair(const std::vector<int>& vec) {
    for (size_t i = 0; i < vec.size(); ++i) {
        for (size_t j = i + 1; j < vec.size(); ++j) {
            if (vec[i] % vec[j] != 0 && vec[j] % vec[i] != 0) {
                return std::make_pair(vec[i], vec[j]);
            }
        }
    }
    // If no pair is found, return a pair of -1, -1 or handle as required
    return std::make_pair(-1, -1);
}
pair<int, int> findMinimumNonDivisiblePair(const std::vector<int>& vec) {
    std::pair<int, int> minPair = std::make_pair(-1, -1);
    int minSum = std::numeric_limits<int>::max();

    for (size_t i = 0; i < vec.size(); ++i) {
        for (size_t j = i + 1; j < vec.size(); ++j) {
            if (vec[i] % vec[j] != 0 && vec[j] % vec[i] != 0) {
                int currentSum = vec[i] + vec[j];
                if (currentSum < minSum) {
                    minSum = currentSum;
                    minPair = std::make_pair(vec[i], vec[j]);
                }
            }
        }
    }
    return minPair;
}
Our Customers









Imprint
bool check(vector<int>& nums) {
        int count = 0 ;
        if (nums[0] < nums[nums.size()-1]) count++ ;
        for (int i=1; i<nums.size(); i++){
            if (nums[i] < nums[i-1]){
                count++ ;
                if (count > 1) return false ;
            }
        }
        return true ;
    }
#include <iostream>

using namespace std;

int main() {
    
    char variable1 = 'b';
    int variable2 = 15;
    double variable3 = 10.2;
    
    char *pntr1 = &variable1;
    int *pntr2 = &variable2;
    double *pntr3 = &variable3;
    
    cout<<"before changing: "<<endl;
    cout<<"variable1 value= "<<variable1<<",\t\tAddress: "<<&variable1<<",\t*pntr1 value = "<<*pntr1<<endl;
    cout<<"variable2 value= "<<variable2<<",\tAddress: "<<&variable2<<",\t*pntr2 = "<<*pntr2<<endl;
    cout<<"variable3 value= "<<variable3<<",\tAddress: "<<&variable3<<",\t*pntr3 = "<<*pntr3<<endl;
    
    *pntr1 = 'c';
    *pntr2 = 25;
    *pntr3 = 12.50;
    
    cout<<"____________________"<<endl;
    cout<<"After changing: "<<endl;
    cout<<"variable1 value= "<<variable1<<",\t\tAddress: "<<&variable1<<",\t*pntr1 value = "<<*pntr1<<endl;
    cout<<"variable2 value= "<<variable2<<",\tAddress: "<<&variable2<<",\t*pntr2 = "<<*pntr2<<endl;
    cout<<"variable3 value= "<<variable3<<",\tAddress: "<<&variable3<<",\t*pntr3 = "<<*pntr3<<endl;

    
    return 0;
}
//OUTPUT:
before changing: 
variable1 value= b,		Address: b(b5��,	*pntr1 value = b
variable2 value= 15,	Address: 0x7ffce6356230,	*pntr2 = 15
variable3 value= 10.2,	Address: 0x7ffce6356228,	*pntr3 = 10.2
____________________
After changing: 
variable1 value= c,		Address: c(b5��,	*pntr1 value = c
variable2 value= 25,	Address: 0x7ffce6356230,	*pntr2 = 25
variable3 value= 12.5,	Address: 0x7ffce6356228,	*pntr3 = 12.5
body {

  margin: 0;

  background: #020202;

  cursor: crosshair;

}

canvas{display:block}

h1 {

  position: absolute;

  top: 20%;

  left: 50%;

  transform: translate(-50%, -50%);

  color: #fff;

  font-family: "Source Sans Pro";

  font-size: 5em;

  font-weight: 900;

  -webkit-user-select: none;

  user-select: none;

}
<h1>Happy Birthday</h1>

<canvas id="birthday"></canvas>
 int findMaxConsecutiveOnes(vector<int>& nums) {
        int count = 0;
        int m=0;
        int n=nums.size();
        for(int j=0;j<n;++j)
        {
            if(nums[j]==1)
            {
                count++;
                 m=max(count,m);
            }
            else{
               
                count=0;
            }
        }
        return m;
        
    }
import os
import json
import pymongo
from pymongo import MongoClient

# Configure MongoDB connection
client = MongoClient('mongodb://localhost:27017/')
db = client['twitter_db']
collection = db['tweets']

# Directory containing the JSON files
directory_path = 'C:/Users/User/Desktop/DBL Data Challenge/data'

# Function to insert JSON objects from a file into MongoDB
def insert_file(file_path):
    try:
        with open(file_path, 'r') as file:
            for line_number, line in enumerate(file, start=1):
                if line.strip():  # Skip empty lines
                    try:
                        json_object = json.loads(line)
                        document = {
                            'file_name': os.path.basename(file_path),
                            'json_data': json_object
                        }
                        collection.insert_one(document)
                    except json.JSONDecodeError as e:
                        print(f"JSONDecodeError: Error reading JSON data from file {file_path}, line {line_number}: {e}")
    except IOError as e:
        print(f"IOError: Error reading file {file_path}: {e}")
    except pymongo.errors.PyMongoError as e:
        print(f"PyMongoError: Error uploading data from file {file_path} to MongoDB: {e}")
    except Exception as e:
        print(f"Unexpected error with file {file_path}: {e}")

# Iterate over files in the directory and insert them into MongoDB
file_count = 0
error_count = 0
for filename in os.listdir(directory_path):
    file_path = os.path.join(directory_path, filename)
    if os.path.isfile(file_path) and filename.endswith('.json'):
        try:
            insert_file(file_path)
            file_count += 1
        except Exception as e:
            print(f"Unexpected error while processing file {file_path}: {e}")
            error_count += 1

print(f"All {file_count} files have been processed.")
if error_count > 0:
    print(f"There were {error_count} files that encountered errors.")
    vector<int> v;
        int n=nums.size();
        int f=k%(n);
        int a=n-f;
        for(int i=0;i<n;++i)
        {
            if((a+i)<=(n-1))
            v.push_back(nums[a+i]);
            else
            v.push_back(nums[a+i-nums.size()]);
        }
        nums=v;}
};
 if ($_FILES['file']['size'] == 0) {
          //se não existir a imagem coloa uma padrão
          $file = "assets/upload/adverts/no-photo.jpg";
        } else {

          $file = $Resources->uploadFile('assets/upload/images/adverts/', $_FILES['file']);
          if ($file == "error") {
            header("Location: " . BASE_URL . "users/advertise");
            exit;
          }
        }
public class p32_circularQ {
    public static void main(String[] args) {
        Queue q=new Queue(5);
        q.add(0);
        q.add(1);
        q.add(2);
        q.delete();
        q.add(4);
        
      
        while(!q.isEmpty()){
            System.out.println(q.peek());
            q.delete();
        }

    }

    static class Queue {
        static int arr[];
        static int size;
        static int rear;
        static int front;

        Queue(int n) {
            arr = new int[n];
            size = n;
            rear = -1;
            front=-1;
        }

        public static boolean isEmpty() {
            return rear == -1 && front==-1;
            // if(rear==-1){
            // return true;
            // }
            // return false;
        }

        public static boolean isFull(){
            return (rear+1)%size==front;
        }

        public static int delete() {
            if (rear == -1) {
                System.out.println("Empty");
                return -1;
            } 
                int temp = arr[0];
                if(rear==front){
                    rear=front=-1;
                }else{
                front=(front+1)%size;
                }
                return temp;
            
        }

        public static void add(int data) {
            if (isFull()) {
                System.out.println("Queue is full");
                return;
            } //add 1st ele
                if(front==-1){
                    front=0;
                }
                rear = (rear + 1)%size;
                arr[rear] = data;
            
        }

        public static int peek() {
            if (rear == -1) {
                System.out.println("Empty");
                return -1;
            }

            return arr[front];

        }

    }
}
 <link rel="stylesheet" href="style.css">
    <script src="script.js"></script>
 <a href = "https://www.youtube.com" target = _main>YOUTUBE</a>
 int removeDuplicates(vector<int>& nums) {
       int i=0;
       int n=nums.size();
       for(int j=1;j<n;++j)
       {if(nums[i]!=nums[j])
        {  nums[i+1]=nums[j]; i++;}}
       return i+1;}
$ cd /lib/x86_64-linux-gnu/
$ sudo ln -s libreadline.so.7.0 libreadline.so.6
 int removeDuplicates(vector<int>& nums) {
        set<int> s;
        for(int i=0;i<nums.size();++i)
        {
            s.insert(nums[i]);
        }
        set<int> :: iterator it;
        vector<int> v;
        for(it=s.begin();it!=s.end();++it)
        {
            v.push_back(*it);
        }
        nums=v;
        int a = s.size();
        return a;
        
    }
<p class="nl-event-programme">AU PROGRAMME : <span style="text-transform:normal;font-size:18px;">cocktail, visite guidée du FabLab de la Fabrique de l’Innovation, expositions et démonstrations.</span></p>
<br />
<br />
<p class="nl-event-nb">La semaine &#34;Meet &amp; Fabrik&#34; est organisée par la Fabrique de l’Innovation de la ComUE Université de Lyon et se déroulera du 5 au 9 juin 2023.</p>
<a title="programme" href="/fr/">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tbody>
        <tr>
            <td>
            <table cellspacing="0" cellpadding="0" border="0" align="center">
                <tbody>
                    <tr align="center">
                        <td style="padding: 12px 18px 12px 18px; border-radius:3px" bgcolor="#ffb71c" align="center"><a href="/fr/" class="nl-event-button prog" target="_blank" style="font-size: 18px; font-weight: bold; color: #ffffff; text-decoration: none; display: inline-block;">  Voir le programme complet</a></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
</a> <!--[if mso]><p>&nbsp;</p><!-- <![endif]-->
import React from "react";
import {
  BodyText,
  Conditional,
  H2,
  HeadingLink,
  IntroText,
  Loading,
  MinimalPage,
  PageHeading,
  PrimaryButton,
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger,
} from "ui";
import Link from "next/link";
import { CommandInterface } from "@/components";
import { useShiftTable } from "@/hooks";
import { timeSince } from "@/functions";
import dayjs from "dayjs";

type User = {
  shift_start: string | null;
  break_start: string | null;
  user: any;
  image: string;
  fullName: string;
  group: string | null;
  users_view?: {
    email?: string;
    raw_user_meta_data?: {
      avatar_url?: string;
      full_name?: string;
    };
  };
  email: string;
};

const ShiftTable = () => {
  const { data, isLoading, error, isError } = useShiftTable();

  const countUsersInGroups = (users: User[]): Record<string, number> => {
    return users.reduce<Record<string, number>>((acc, user) => {
      const groupName = user.group || "No Group";
      acc[groupName] = (acc[groupName] || 0) + 1;
      return acc;
    }, {});
  };

  const usersOnShiftCounts = countUsersInGroups(data?.onShift ?? []);
  const usersOffShiftCounts = countUsersInGroups(data?.offShift ?? []);

  const sortUsers = (users: User[]) => {
    return users
      .slice()
      .sort((a, b) => a.fullName.localeCompare(b.fullName))
      .sort((a, b) => {
        const shiftA = a.shift_start ? new Date(a.shift_start).getTime() : 0;
        const shiftB = b.shift_start ? new Date(b.shift_start).getTime() : 0;
        return shiftA - shiftB;
      });
  };

  return (
    <MinimalPage
      pageTitle="Shift Table | Email Interface"
      pageDescription="Spot Ship Email Interface | Shift Table"
      commandPrompt
    >
      <CommandInterface />
      <div className="hidden">
        <PageHeading text="Homepage" />
      </div>
      <div className="w-full pl-1 pt-1">
        <HeadingLink icon="back" text="Home" href="/secure/home" />
        <PageHeading text="Spot Ship Shift Table" />
        <Conditional
          condition={!isLoading}
          elseChildren={
            <Loading style="grid" size="large" colour="#AAAAAA50" />
          }
        >
          <Conditional
            condition={!isError}
            elseChildren={<p className="text-red-500">{`${error?.message}`}</p>}
          >
            <div className="mb-4 text-center text-sm text-gray-400">
              Users currently on shift:{" "}
              {Object.entries(usersOnShiftCounts)
                .map(([group, count]) => `${group}: ${count}`)
                .join(", ")}
            </div>
            <RenderUsersGrid
              title="Data Analysts"
              users={sortUsers(
                data?.onShift?.filter(
                  (user) => user.group === "Data Analyst",
                ) ?? [],
              )}
            />
            <RenderUsersGrid
              title="Senior Data Analysts"
              users={sortUsers(
                data?.onShift?.filter(
                  (user) => user.group === "Senior Data Analyst",
                ) ?? [],
              )}
            />
            <RenderUsersGrid
              title="Data Team Managers"
              users={sortUsers(
                data?.onShift?.filter(
                  (user) => user.group === "Data Team Manager",
                ) ?? [],
              )}
            />
            <RenderUsersGrid
              title="Europe Team"
              users={sortUsers(
                data?.onShift?.filter((user) => user.group === "Europe Team") ??
                  [],
              )}
            />
            <div className="mb-4 text-center text-sm text-gray-400">
              Offline users:{" "}
              {Object.entries(usersOffShiftCounts)
                .map(([group, count]) => `${group}: ${count}`)
                .join(", ")}
            </div>
            <RenderUsersGrid
              title="Offline Data Analysts"
              users={sortUsers(
                data?.offShift?.filter(
                  (user) => user.group === "Data Analyst",
                ) ?? [],
              )}
              showShiftStart={false}
              dim={true}
            />
            <RenderUsersGrid
              title="Offline Senior Data Analysts"
              users={sortUsers(
                data?.offShift?.filter(
                  (user) => user.group === "Senior Data Analyst",
                ) ?? [],
              )}
              showShiftStart={false}
              dim={true}
            />
            <RenderUsersGrid
              title="Offline Data Team Managers"
              users={sortUsers(
                data?.offShift?.filter(
                  (user) => user.group === "Data Team Manager",
                ) ?? [],
              )}
              showShiftStart={false}
              dim={true}
            />
            <RenderUsersGrid
              title="Offline Europe Team"
              users={sortUsers(
                data?.offShift?.filter(
                  (user) => user.group === "Europe Team",
                ) ?? [],
              )}
              showShiftStart={false}
              dim={true}
            />
          </Conditional>
        </Conditional>
      </div>
    </MinimalPage>
  );
};
const RenderUsersGrid = ({
  title,
  users = [],
  showShiftStart = true,
  dim = false,
}: {
  title: string;
  users?: User[];
  showShiftStart?: boolean;
  dim?: boolean;
}) => {
  return (
    <div
      className={`overflow-hidden overflow-x-auto rounded-lg shadow ${
        dim ? "opacity-50" : ""
      }`}
    >
      <H2 className="text-center ">{title}</H2>
      <div className="grid grid-cols-4 gap-4 p-4">
        {users.map((user, index) => (
          <div
            key={index}
            className={`relative flex flex-col items-center justify-center rounded-lg bg-gray-200 p-4 dark:bg-gray-800 ${
              dim ? "bg-opacity-50" : ""
            }`}
          >
            <div className="relative h-12 w-12">
              <img
                src={user.image || "/avatar_url.png"}
                alt={user.fullName}
                className="h-full w-full rounded-full object-cover"
              />
              <span
                className={`absolute bottom-0 right-0 block h-5 w-5 rounded-full border border-white/20 dark:border-black ${
                  user.shift_start === null
                    ? "bg-gray-400"
                    : user.break_start === null
                      ? "bg-green-400"
                      : "bg-yellow-400"
                }`}
              />
            </div>
            <Conditional condition={user.email !== ""}>
              <div className="mt-2">
                <Link
                  href={`/secure/review/email?filename=${user.email}`}
                  passHref
                  rel="noopener noreferrer"
                  target="_blank"
                >
                  <PrimaryButton size="small">Working on Email</PrimaryButton>
                </Link>
              </div>
            </Conditional>
            <IntroText className="mt-2">{user.fullName}</IntroText>
            <Conditional condition={showShiftStart && !!user.shift_start}>
              <TooltipProvider>
                <Tooltip>
                  <TooltipTrigger>
                    <BodyText>
                      {user.shift_start
                        ? `On shift for: ${timeSince(new Date(user.shift_start))}`
                        : ""}
                    </BodyText>
                  </TooltipTrigger>
                  <TooltipContent>
                    <p>
                      {dayjs(user.shift_start).format("DD-MM-YYYY | HH:mm")}
                    </p>
                  </TooltipContent>
                </Tooltip>
              </TooltipProvider>
            </Conditional>
            <Conditional condition={showShiftStart && !!user.break_start}>
              <TooltipProvider>
                <Tooltip>
                  <TooltipTrigger>
                    <BodyText>
                      {user.break_start
                        ? `On break for: ${timeSince(
                            new Date(user.break_start),
                          )}`
                        : ""}
                    </BodyText>
                  </TooltipTrigger>
                  <TooltipContent>
                    <p>
                      {dayjs(user.break_start).format("DD-MM-YYYY | HH:mm")}
                    </p>
                  </TooltipContent>
                </Tooltip>
              </TooltipProvider>
            </Conditional>
          </div>
        ))}
      </div>
    </div>
  );
};

export default ShiftTable;
import type { NextPage } from "next";
import {
  CommandInterface,
  EmailUtitlities,
  EmailViewer,
  ScoreCargoResults,
  ScoreClassificationResults,
  ScoreLineupResults,
  ScorePositionResults,
  UserAutocomplete,
} from "@/components";
import {
  Content,
  DataTable,
  DialogButton,
  DisclosureButton,
  FormCheckboxField,
  FormDateTimeRangeField,
  HeadingLink,
  If,
  IfElse,
  MinimalPage,
  PageHeading,
  Subheading,
  ToolTip,
} from "ui";
import { useState } from "react";
import type { Json, User } from "@/types";
import type { DateValueType } from "react-tailwindcss-datepicker/dist/types";
import { useGetEmail, useGetEmailStatus, useUserHistory } from "@/hooks";
import type { ColumnDef } from "@tanstack/react-table";
import dayjs from "dayjs";

interface historyDetails {
  email?: string;
  cargo?: string;
  position?: string;
  classification?: string;
  broker?: string;
  source?: string;
  duration?: string;
}

const UsersScores: NextPage = () => {
  const [user, setUser] = useState<User>({ id: null, email: null });
  const [timeRange, setTimeRange] = useState<DateValueType>({
    startDate: dayjs(new Date()).startOf("day").toDate(),
    endDate: dayjs(new Date()).endOf("day").toDate(),
  });
  const [event, setEvent] = useState<{
    created_at: string | null;
    action: string;
    detail: historyDetails;
  }>({
    created_at: "",
    action: "",
    detail: {},
  });
  const [isOpen, setIsOpen] = useState<boolean>(false);
  const [filters, setFilters] = useState({
    read: true,
    classified: true,
    positions: true,
    cargos: true,
    lineups: true,
    pause: true,
    addVessel: true,
    editVessel: true,
    addPort: true,
    shiftStatus: true,
    breakStatus: true,
  });
  const { data: history } = useUserHistory(user, timeRange);
  const { data: email } = useGetEmail(event.detail?.email ?? "", false);
  const { data: emailStatus } = useGetEmailStatus(
    event.detail?.email ?? "",
    false,
  );

  const emptyResults = {
    read: 0,
    classified: 0,
    positions: 0,
    cargos: 0,
    lineups: 0,
    pause: 0,
    addVessel: 0,
    editVessel: 0,
    addPort: 0,
    shiftStatus: 0,
    breakStatus: 0,
  };

  const results =
    history?.reduce((count, event) => {
      switch (event.action) {
        case "READ":
          return { ...count, read: count.read + 1 };
        case "CLASSIFICATION":
          return { ...count, classified: count.classified + 1 };
        case "CARGO":
          return { ...count, cargos: count.cargos + 1 };
        case "LINE-UP":
          return { ...count, lineups: count.lineups + 1 };
        case "POSITION":
          return { ...count, positions: count.positions + 1 };
        case "PAUSE":
          return { ...count, pause: count.pause + 1 };
        case "ADD_VESSEL":
          return { ...count, addVessel: count.addVessel + 1 };
        case "EDIT_VESSEL":
          return { ...count, editVessel: count.editVessel + 1 };
        case "ADD_PORT":
          return { ...count, addPort: count.addPort + 1 };
        case "SHIFT START":
        case "SHIFT END":
          return { ...count, shiftStatus: count.shiftStatus + 1 };
        case "BREAK START":
        case "BREAK END":
          return { ...count, breakStatus: count.breakStatus + 1 };
        default:
          return count;
      }
    }, emptyResults) ?? emptyResults;

  const filteredHistory =
    history?.filter((event) => {
      switch (event.action) {
        case "READ":
          return filters.read;
        case "CLASSIFICATION":
          return filters.classified;
        case "CARGO":
          return filters.cargos;
        case "LINE-UP":
          return filters.lineups;
        case "POSITION":
          return filters.positions;
        case "PAUSE":
          return filters.pause;
        case "ADD_VESSEL":
          return filters.addVessel;
        case "EDIT_VESSEL":
          return filters.editVessel;
        case "ADD_PORT":
          return filters.addPort;
        case "SHIFT START":
        case "SHIFT END":
          return filters.shiftStatus;
        case "BREAK START":
        case "BREAK END":
          return filters.breakStatus;
        default:
          return true;
      }
    }) ?? [];

  const columns: ColumnDef<{
    created_at: string | null;
    action: string;
    detail: Json;
  }>[] = [
    {
      accessorKey: "created_at",
      header: "Time",
      cell: ({ row }) => {
        const request = row.original;
        return (
          <ToolTip text={request.created_at ?? ""}>
            <div>
              <Content
                text={
                  request.created_at
                    ? new Date(request.created_at).toLocaleString("en-GB", {
                        year: "numeric",
                        month: "short",
                        day: "numeric",
                        hour: "2-digit",
                        minute: "2-digit",
                        second: "2-digit",
                      })
                    : ""
                }
              />
            </div>
          </ToolTip>
        );
      },
    },
    {
      accessorKey: "action",
      header: "Action",
    },
    {
      accessorKey: "detail",
      header: "Details",
      cell: ({ row }) => {
        const request = row.original;
        if (request.detail === null) return;
        const details = request.detail as historyDetails;
        return (
          <div>
            <If
              condition={
                request.action !== "SHIFT END" && request.action !== "BREAK END"
              }
            >
              <Content text={`Email ID: ${details.email ?? ""}`} />
            </If>
            <If condition={details.broker !== undefined}>
              <Content text={`Broker: ${details.broker ?? ""}`} />
            </If>
            <If condition={details.source !== undefined}>
              <Content text={`Source: ${details.source ?? ""}`} />
            </If>
            <If condition={details.classification !== undefined}>
              <Content
                text={`Classification: ${details.classification ?? ""}`}
              />
            </If>
            <If condition={details.position !== undefined}>
              <Content text={`Position Report ID: ${details.position ?? ""}`} />
            </If>
            <If condition={details.cargo !== undefined}>
              <Content text={`Cargo Report ID: ${details.cargo ?? ""}`} />
            </If>
            <If
              condition={
                request.action === "SHIFT END" && details.duration !== undefined
              }
            >
              <Content text={`Shift Duration: ${details.duration}`} />
            </If>
            <If
              condition={
                request.action === "BREAK END" && details.duration !== undefined
              }
            >
              <Content text={`Break Duration: ${details.duration}`} />
            </If>
          </div>
        );
      },
    },
  ];

  const ModalContent = () => {
    const details = event.detail as historyDetails;
    return (
      <div className="grid grid-cols-2 justify-items-center gap-4">
        <div className="w-full">
          <div className="pb-4">
            <Subheading text={`User Event: ${event.action}`} />
            <DisclosureButton buttonText="Email Status" colour="Primary">
              <Content
                text={`Classifications: ${emailStatus?.classification}`}
              />
              <Content text={`Priority: ${emailStatus?.priority}`} />
              <IfElse
                condition={emailStatus?.complete ?? false}
                elseChildren={<Content text="Completed: No" />}
              >
                <Content
                  text={`Completed: ${
                    emailStatus?.completed_by
                      ? emailStatus.completed_by
                      : "UNKNOWN"
                  } at ${emailStatus?.completed_at}`}
                />
              </IfElse>
              <If
                condition={
                  emailStatus?.classification
                    ?.split(",")
                    .includes("POSITION") ?? false
                }
              >
                <Content
                  text={`Position Reports: ${emailStatus?.position_reports.length}`}
                />
              </If>
              <If
                condition={
                  emailStatus?.classification?.split(",").includes("CARGO") ??
                  false
                }
              >
                <Content
                  text={`Cargo Reports: ${emailStatus?.cargo_reports.length}`}
                />
              </If>
            </DisclosureButton>
          </div>
          <EmailViewer
            email={email}
            historyNeedsUpdating={false}
            allowNextEmail={false}
          />
        </div>
        <If condition={event.action === "CLASSIFICATION"}>
          <ScoreClassificationResults
            classification={event.detail.classification}
            emailId={details.email}
            user={user.id ?? undefined}
          />
        </If>
        <If condition={event.action === "POSITION"}>
          <div className="flex w-4/5 flex-col items-center">
            <Subheading text="Score Position Reports" />
            <div className="flex w-4/5 flex-col gap-4">
              {emailStatus?.position_reports.map((report) => {
                return (
                  <DisclosureButton
                    key={report.id}
                    buttonText={`Report: ${report.id}`}
                    colour={
                      `${report.id}` == details.position ? "Success" : "Accent"
                    }
                  >
                    <ScorePositionResults
                      report={report}
                      emailId={details.email}
                    />
                  </DisclosureButton>
                );
              })}
            </div>
          </div>
        </If>
        <If condition={event.action === "CARGO"}>
          <div className="flex w-4/5 flex-col items-center">
            <div className="flex w-4/5 flex-col gap-4">
              {emailStatus?.cargo_reports.map((report) => {
                return (
                  <DisclosureButton
                    key={report.id}
                    buttonText={`Report: ${report.id}`}
                    colour={
                      `${report.id}` == details.position ? "Success" : "Accent"
                    }
                  >
                    <ScoreCargoResults
                      report={report}
                      emailId={details.email}
                    />
                  </DisclosureButton>
                );
              })}
            </div>
          </div>
        </If>
        <If condition={event.action === "LINE-UP"}>
          <div className="flex w-4/5 flex-col items-center">
            <div className="flex w-4/5 flex-col gap-4">
              {emailStatus?.lineup_reports.map((report) => {
                return (
                  <DisclosureButton
                    key={report.id}
                    buttonText={`Report: ${report.id}`}
                    colour={
                      `${report.id}` == details.position ? "Success" : "Accent"
                    }
                  >
                    <ScoreLineupResults
                      report={report}
                      emailId={details.email}
                    />
                  </DisclosureButton>
                );
              })}
            </div>
          </div>
        </If>
        <div className="col-span-2 w-full">
          <EmailUtitlities />
        </div>
      </div>
    );
  };

  return (
    <MinimalPage
      pageTitle={"Review Users | Email Interface"}
      pageDescription={"Spot Ship Email Interface | Review Users"}
      commandPrompt
    >
      <CommandInterface />
      <div className="w-full">
        <HeadingLink icon={"back"} text={"Home"} href={`/secure/home`} />
      </div>
      <div>
        <PageHeading text="User Scores" />
      </div>
      <div className="w-full p-8">
        <UserAutocomplete
          id="user"
          label="Who:"
          labelWidth="w-52"
          value={user}
          onChange={(data) => {
            if (data) setUser(data);
          }}
        />
        <FormDateTimeRangeField
          id="date"
          label="Time Frame"
          labelWidth="w-52"
          value={timeRange}
          onChange={(date: DateValueType) => {
            setTimeRange(date);
          }}
          warning
          warningDaysInPast={30}
          warningDaysInFuture={1}
          pastWarning={"should be no earlier than 30 days from now"}
        />
        <DisclosureButton
          buttonText={`Results: ${history?.length}${
            history?.length === 1000
              ? "Max results reached, narrow time range"
              : ""
          }`}
          colour="Primary"
        >
          <Subheading text="Include Events" />
          <div className="mb-2 grid gap-1 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8">
            <FormCheckboxField
              id="filter-read"
              label="READ"
              caption={`Emails Read: ${results.read}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    read: enabled,
                  };
                });
              }}
              defaultState={filters.read}
            />
            <FormCheckboxField
              id="filter-classifications"
              label="CLASSIFICATION"
              caption={`Classifications: ${results.classified}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    classified: enabled,
                  };
                });
              }}
              defaultState={filters.classified}
            />
            <FormCheckboxField
              id="filter-positions"
              label="POSITION"
              caption={`Position Submissions: ${results.positions}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    positions: enabled,
                  };
                });
              }}
              defaultState={filters.positions}
            />
            <FormCheckboxField
              id="filter-cargos"
              label="CARGO"
              caption={`Cargo Submissions: ${results.cargos}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    cargos: enabled,
                  };
                });
              }}
              defaultState={filters.cargos}
            />
            <FormCheckboxField
              id="filter-lineups"
              label="LINE-UP"
              caption={`Line Up Submissions: ${results.lineups}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    lineups: enabled,
                  };
                });
              }}
              defaultState={filters.lineups}
            />
            <FormCheckboxField
              id="filter-pause"
              label="PAUSE"
              caption={`Pauses: ${results.pause}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    pause: enabled,
                  };
                });
              }}
              defaultState={filters.pause}
            />
            <FormCheckboxField
              id="filter-add-vessel"
              label="ADD_VESSEL"
              caption={`Added Vessels: ${results.addVessel}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    addVessel: enabled,
                  };
                });
              }}
              defaultState={filters.addVessel}
            />
            <FormCheckboxField
              id="filter-edit-vessel"
              label="EDIT_VESSEL"
              caption={`Edited Vessels: ${results.editVessel}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    editVessel: enabled,
                  };
                });
              }}
              defaultState={filters.editVessel}
            />
            <FormCheckboxField
              id="filter-add-port"
              label="ADD_PORT"
              caption={`Added Ports : ${results.addPort}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    addPort: enabled,
                  };
                });
              }}
              defaultState={filters.addPort}
            />
            <FormCheckboxField
              id="filter-shift-status"
              label="SHIFT STATUS"
              caption={`Shift Status Events: ${results.shiftStatus}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    shiftStatus: enabled,
                  };
                });
              }}
              defaultState={filters.shiftStatus}
            />
            <FormCheckboxField
              id="filter-break-status"
              label="BREAK STATUS"
              caption={`Break Status Events: ${results.breakStatus}`}
              action={(enabled: boolean) => {
                setFilters((prevState) => {
                  return {
                    ...prevState,
                    breakStatus: enabled,
                  };
                });
              }}
              defaultState={filters.breakStatus}
            />
          </div>
          <div className="max-h-[600px] w-full gap-8 overflow-scroll p-8">
            <DataTable
              action={(obj: {
                created_at: string | null;
                action: string;
                detail: historyDetails;
              }) => {
                setEvent(obj);
                if (obj.detail && obj.detail.email !== undefined) {
                  setIsOpen(true);
                }
              }}
              showFilterInput
              filterValue="created_at"
              data={filteredHistory}
              columns={columns}
            />
          </div>
        </DisclosureButton>
        <DialogButton action={() => setIsOpen(false)} isOpen={isOpen}>
          <ModalContent />
        </DialogButton>
      </div>
    </MinimalPage>
  );
};

export default UsersScores;
import React, { useState } from "react";
import { useSupabaseClient } from "@supabase/auth-helpers-react";
import {
  ButtonContent,
  CaptionText,
  Conditional,
  dateToTimeString,
  PrimaryButton,
  SecondaryButton,
} from "ui";
import { useUserShiftStart } from "../../hooks";
import { useQueryClient } from "react-query";
import { CirclePlay, CircleStop } from "lucide-react";

interface ShiftStatus {
  isOnShift: boolean;
  onShiftSince: string | null | undefined;
  isOnBreak: boolean;
  onBreakSince: string | null | undefined;
}

export const UserShiftStateButton = () => {
  const {
    data: shiftStatus,
    isError,
    error: loadShiftStatusError,
  } = useUserShiftStart();
  const [error, setError] = useState<string>();
  const supabaseClient = useSupabaseClient();
  const queryClient = useQueryClient();

  const logUserAction = async (
    action: string,
    details: object | null,
    userId: string,
  ) => {
    const { error: insertError } = await supabaseClient
      .from("UserHistory")
      .insert([{ user: userId, action, detail: details }]);
    if (insertError) {
      setError("Failed to log user action");
    }
  };

  const toggleShiftStatus = async () => {
    const { data: sessionData } = await supabaseClient.auth.getSession();
    if (sessionData?.session) {
      const userId = sessionData.session.user.id;
      const now = new Date().toISOString();
      let newStatus: string;
      let details: { duration?: string; start?: string; end?: string } | null =
        null;

      if (shiftStatus?.isOnShift && shiftStatus.onShiftSince) {
        const shiftStart = new Date(shiftStatus.onShiftSince);
        const shiftEnd = new Date();
        const shiftDuration = shiftEnd.getTime() - shiftStart.getTime();
        details = {
          duration: dateToTimeString(shiftDuration),
          start: shiftStart.toISOString(),
          end: shiftEnd.toISOString(),
        };
        newStatus = "SHIFT END";

        if (shiftStatus.isOnBreak && shiftStatus.onBreakSince) {
          const breakStart = new Date(shiftStatus.onBreakSince);
          const breakEnd = new Date();
          const breakDuration = breakEnd.getTime() - breakStart.getTime();
          const breakDetails = {
            duration: dateToTimeString(breakDuration),
            start: breakStart.toISOString(),
            end: breakEnd.toISOString(),
          };
          await logUserAction("BREAK END", breakDetails, userId);
        }
      } else {
        newStatus = "SHIFT START";
      }

      const { error: updateError } = await supabaseClient
        .from("UserLastWorkedOn")
        .update({
          shift_start: shiftStatus?.isOnShift ? null : now,
          break_start: null,
        })
        .eq("user", userId);

      if (updateError) {
        setError("Failed to toggle shift status");
        return;
      }

      await logUserAction(newStatus, details, userId);
      queryClient.invalidateQueries({ queryKey: ["userShiftStatus"] });
    }
  };

  const toggleBreakStatus = async () => {
    const { data: sessionData } = await supabaseClient.auth.getSession();
    if (sessionData?.session) {
      const userId = sessionData.session.user.id;
      const now = new Date().toISOString();
      let newStatus: string;
      let details: { duration?: string; start?: string; end?: string } | null =
        null;

      if (shiftStatus?.isOnBreak && shiftStatus.onBreakSince) {
        const breakStart = new Date(shiftStatus.onBreakSince);
        const breakEnd = new Date();
        const breakDuration = breakEnd.getTime() - breakStart.getTime();
        details = {
          duration: dateToTimeString(breakDuration),
          start: breakStart.toISOString(),
          end: breakEnd.toISOString(),
        };
        newStatus = "BREAK END";
      } else {
        newStatus = "BREAK START";
      }

      const { error: updateError } = await supabaseClient
        .from("UserLastWorkedOn")
        .update({
          break_start: shiftStatus?.isOnBreak ? null : now,
        })
        .eq("user", userId);

      if (updateError) {
        setError("Failed to toggle break status");
        return;
      }

      await logUserAction(newStatus, details, userId);
      queryClient.invalidateQueries({ queryKey: ["userShiftStatus"] });
    }
  };

  return (
    <Conditional
      condition={!isError}
      elseChildren={
        <CaptionText>
          Error: {isError ? `${loadShiftStatusError}` : ""}
          {error}
        </CaptionText>
      }
    >
      <CaptionText className="mt-1">
        You are {shiftStatus?.isOnShift ? "On" : "Off"} shift
      </CaptionText>
      <PrimaryButton
        onClick={toggleShiftStatus}
        className="min-w-32 rounded-none rounded-bl-md rounded-tl-md"
      >
        <ButtonContent className="gap-2">
          <div>{shiftStatus?.isOnShift ? "End" : "Start"} Shift</div>
          <Conditional
            condition={!shiftStatus?.isOnShift}
            elseChildren={<CircleStop size={16} />}
          >
            <CirclePlay size={16} />
          </Conditional>
        </ButtonContent>
      </PrimaryButton>
      <SecondaryButton
        onClick={toggleBreakStatus}
        disabled={!shiftStatus?.isOnShift}
        className="min-w-32 rounded-none rounded-br-md rounded-tr-md"
      >
        <ButtonContent className="gap-2">
          <div>{shiftStatus?.isOnBreak ? "End" : "Start"} Break</div>
          <Conditional
            condition={!shiftStatus?.isOnBreak}
            elseChildren={<CircleStop size={16} />}
          >
            <CirclePlay size={16} />
          </Conditional>
        </ButtonContent>
      </SecondaryButton>
    </Conditional>
  );
};
    #[Test]
    public function title_is_required()
    {
        Livewire::test(CreatePost::class)
            ->set('title', '')
            ->call('save')
            // It checks if the validation rule 'required' is triggered for the 'title' empty string field after the form submission.
            ->assertHasErrors(['title' => 'required'])
            // It checks if the validation rule 'min:4' is triggered for the empty 'title' field after the form submission.
            ->assertHasErrors(['title' => 'min:4']);
    }
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Taste of India Menu</title>
    <link rel="stylesheet" href="styles.css">
    <style>
        /* Additional styles for menu.html */
        body {
            font-family: Arial, sans-serif;
            background-color: #fff;
            color: #333;
            margin: 0;
            padding: 0;
        }

        h1 {
            text-align: center;
            color: #ff5733; /* Match the title color with the menu-section h2 color */
            margin: 20px 0; /* Ensure margin around the title */
        }

        .menu-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            margin: 20px auto; /* Adjust margin to ensure visibility */
            width: 90%; /* Set a fixed width to center content */
        }

        .menu-column {
            width: 15%; /* Adjust width to ensure six columns fit well */
            margin-bottom: 20px;
        }

        .menu-section {
            margin-bottom: 20px;
        }

        .menu-section h2 {
            font-size: 24px;
            color: #ff5733; /* Set color to orange */
            margin-bottom: 10px;
        }

        .menu-item {
            font-size: 18px;
            margin-bottom: 10px;
            color: #FFDAB9; /* Set color to peach */
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .price {
            float: right;
            color: #333; /* Set color to dark gray */
        }

        .quantity-container {
            display: flex;
            align-items: center;
        }

        .quantity-button {
            width: 20px;
            height: 20px;
            font-size: 14px;
            margin: 0 3px; /* Adjust the margin */
            background-color: #ff5733;
            color: #fff;
            border: none;
            border-radius: 70%; /* Decrease the border-radius */
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>
<body>
    <h1>Taste of India</h1>
    <div class="menu-container">
        <div class="menu-column">
            <div class="menu-section">
                <h2>BIRYANIS</h2>
                <div class="menu-item">
                    <span>Chicken Biryani</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Mutton Biryani</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Veg Biryani</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Egg Biryani</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Fish Biryani</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>PRICE</h2>
                <div class="menu-item">$8.99</div><br><br>
                <div class="menu-item">$9.99</div><br>
                <div class="menu-item">$6.99</div><br>
                <div class="menu-item">$7.99</div><br>
                <div class="menu-item">$10.99</div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>DESSERT</h2>
                <div class="menu-item">
                    <span>Kajur sweet</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Rasa gulla</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Kulfi  </span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Kajuu sweet</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Jalebi sweet</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Barfii sweet</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>PRICE</h2>
                <div class="menu-item">$4.99</div>
		<br><br>
                <div class="menu-item">$3.99</div>
		<br>
                <div class="menu-item">$2.99</div>
		<br>
                <div class="menu-item">$5.49</div>
		<br>
                <div class="menu-item">$6.99</div>
		<br>
		<div class="menu-item">$5.99</div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>DRINKS</h2>
                <div class="menu-item">
                    <span>Mango Lassi</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Masala Chai</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Lemon Soda</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Thand Lassi</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Butter milk</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>PRICE</h2>
                <div class="menu-item">$3.99</div><br><br>
                <div class="menu-item">$2.49</div><br>
                <div class="menu-item">$1.99</div><br>
                <div class="menu-item">$4.49</div><br>
                <div class="menu-item">$2.99</div>
            </div>
        </div>
    </div>
    <button class="back-button" onclick="window.location.href='menu.html'">Back</button>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Taste of India Menu</title>
    <link rel="stylesheet" href="styles.css">
    <style>
        /* Additional styles for menu.html */
        body {
            font-family: Arial, sans-serif;
            background-color: #fff;
            color: #333;
            margin: 0;
            padding: 0;
        }

        h1 {
            text-align: center;
            color: #ff5733; /* Match the title color with the menu-section h2 color */
            margin: 20px 0; /* Ensure margin around the title */
        }

        .menu-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            margin: 20px auto; /* Adjust margin to ensure visibility */
            width: 90%; /* Set a fixed width to center content */
        }

        .menu-column {
            width: 15%; /* Adjust width to ensure six columns fit well */
            margin-bottom: 20px;
        }

        .menu-section {
            margin-bottom: 20px;
        }

        .menu-section h2 {
            font-size: 24px;
            color: #ff5733; /* Set color to orange */
            margin-bottom: 10px;
        }

        .menu-item {
            font-size: 18px;
            margin-bottom: 10px;
            color: #FFDAB9; /* Set color to peach */
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .price {
            float: right;
            color: #333; /* Set color to dark gray */
        }

        .quantity-container {
            display: flex;
            align-items: center;
        }

        .quantity-button {
            width: 20px;
            height: 20px;
            font-size: 14px;
            margin: 0 3px; /* Adjust the margin */
            background-color: #ff5733;
            color: #fff;
            border: none;
            border-radius: 70%; /* Decrease the border-radius */
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>
<body>
    <h1>Taste of India</h1>
    <div class="menu-container">
        <div class="menu-column">
            <div class="menu-section">
                <h2>SOUPS</h2>
                <div class="menu-item">
                    <span>VegThai soup</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Eggdrop soup</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Chicken soup</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Wonton soup</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Prawns soup</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>PRICE</h2>
                <div class="menu-item">$8.99</div><br><br>
                <div class="menu-item">$9.99</div><br>
                <div class="menu-item">$6.99</div><br>
                <div class="menu-item">$7.99</div><br>
                <div class="menu-item">$10.99</div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>STARTERS</h2>
                <div class="menu-item">
                    <span>Onion Pakoda</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Panner fry</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Crispy Panner </span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>chicken 65</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>chicken Pakodi</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>chicken Kabab</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>PRICE</h2>
                <div class="menu-item">$4.99</div>
		<br><br>
                <div class="menu-item">$3.99</div>
		<br>
                <div class="menu-item">$2.99</div>
		<br>
                <div class="menu-item">$5.49</div>
		<br>
                <div class="menu-item">$6.99</div>
		<br>
		<div class="menu-item">$5.99</div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>Main Course</h2>
                <div class="menu-item">
                    <span>Rajma masala</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Panner Masala</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>EggFry</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Butter chicken</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
                <div class="menu-item">
                    <span>Prawns curry</span>
                    <div class="quantity-container">
                        <button class="quantity-button" onclick="decrement(this)">-</button>
                        <span class="quantity">0</span>
                        <button class="quantity-button" onclick="increment(this)">+</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="menu-column">
            <div class="menu-section">
                <h2>PRICE</h2>
                <div class="menu-item">$3.99</div><br><br>
                <div class="menu-item">$2.49</div><br>
                <div class="menu-item">$1.99</div><br>
                <div class="menu-item">$4.49</div><br>
                <div class="menu-item">$2.99</div>
            </div>
        </div>
    </div>
   <div class="button-container">
        <button class="back-button" onclick="window.location.href='customer.html'">Back</button>
        <button class="next-button" onclick="window.location.href='menu2.html'">Next Page</button>
    </div>

</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Taste of India</title>
    <link rel="stylesheet" href="styles.css">
    <style>
        /* Additional styles for customer.html */
        body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh; /* Ensure full height */
            margin: 0; /* Remove default margin */
            padding: 0; /* Remove default padding */
        }

        .button-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 20px;
            margin-top: 20px;
        }

        .table-button {
            padding: 15px 30px;
            font-size: 16px;
            cursor: pointer;
            border: none;
            border-radius: 5px;
            background-color: #007bff;
            color: white;
            font-weight: bold;
        }

        .table-button:hover {
            background-color: #0056b3;
        }

        .back-button {
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <h1>TASTE OF INDIA</h1>
    <div class="info-container">
        <p>
            Welcome to Taste of India! We serve delicious Indian cuisine that will tantalize your taste buds and leave you wanting more. Our dishes are made with fresh, high-quality ingredients, bursting with flavor and spices that will awaken your senses. Whether you're craving savory curries, aromatic biryanis, or crispy samosas, we have something for everyone. Come and experience the authentic taste of India with us!
        </p>
    </div>
    <div class="button-container">
        <button class="table-button" onclick="window.location.href='menu.html'">Table 1</button>
        <button class="table-button" onclick="window.location.href='menu.html'">Table 2</button>
        <button class="table-button" onclick="window.location.href='menu.html'">Table 3</button>
        <button class="table-button" onclick="window.location.href='menu.html'">Table 4</button>
        <button class="table-button" onclick="window.location.href='menu.html'">Table 5</button>
        <button class="table-button" onclick="window.location.href='menu.html'">Table 6</button>
        <button class="table-button" onclick="window.location.href='menu.html'">Table 7</button>
    </div>
    <button class="back-button" onclick="window.location.href='index.html'">Back</button>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Administration</title>
    <link rel="stylesheet" href="styles.css">
    <style>
        .input-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 20px;
        }
        .input-container input {
            padding: 10px;
            margin-bottom: 10px;
            width: 200px;
            border-radius: 5px;
            border: 1px solid #ccc;
        }
    </style>
</head>
<body>
    <h1>ADMINISTRATION</h1>
    <div class="input-container">
        <input type="text" placeholder="Username">
        <input type="password" placeholder="Password">
    </div>
    <div class="button-container">
        <button onclick="window.location.href='index.html'">BACK</button>
    </div>
</body>
</html>
/* Global styles */
body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: url('backgroundimage1.jpg') no-repeat center center fixed;
    background-size: cover;
    height: 100vh;
    margin: 0;
}

h1 {
    color: #ff5733;
    font-size: 48px; /* Increased font size */
    margin-bottom: 50px;
}

.button-container {
    display: flex;
    gap: 20px;
}

button {
    padding: 15px 30px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    font-weight: bold; /* Make text bold */
}

button:hover {
    background-color: #0056b3;
}

button:nth-of-type(1) {
    color: black; /* Black color for "ADMINISTRATION" button */
}

button:nth-of-type(2) {
    color: gold; /* Gold color for "CUSTOMER" button */
}

/* Specific styles for customer.html */
.info-container p {
    color: gold; /* Maroon color for paragraph text */
    font-weight: bold; /* Make paragraph text bold */
    font-size: 18px; /* Increased font size for paragraph text */
}

/* Specific styles for customer.html */
.button-container .table-button:nth-of-type(2) {
    color: black; /* Black text color for Table 2 button */
}

/* Set text color to black for Table 3 to Table 7 buttons */
.button-container .table-button:nth-of-type(n+1) {
    color: black;
}
star

Sun May 26 2024 13:20:22 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun May 26 2024 12:58:05 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 11:59:17 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 11:56:56 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 11:53:57 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 11:29:49 GMT+0000 (Coordinated Universal Time)

@taufiq_ali

star

Sun May 26 2024 10:43:42 GMT+0000 (Coordinated Universal Time)

@Mohamedshariif #c++

star

Sun May 26 2024 10:09:01 GMT+0000 (Coordinated Universal Time) https://codepen.io/wikyware-net/pen/dyKPRxQ

@ElyasAkbari #undefined

star

Sun May 26 2024 10:08:50 GMT+0000 (Coordinated Universal Time) https://codepen.io/wikyware-net/pen/dyKPRxQ

@ElyasAkbari #undefined

star

Sun May 26 2024 08:18:35 GMT+0000 (Coordinated Universal Time)

@taufiq_ali

star

Sun May 26 2024 06:45:25 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun May 26 2024 00:39:55 GMT+0000 (Coordinated Universal Time) https://marketplace.visualstudio.com/items?itemName

@CodeMeKathy

star

Sun May 26 2024 00:35:07 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:34:27 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:33:24 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:29:30 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:22:35 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:21:30 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:21:01 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 22:50:54 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 22:50:05 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 22:04:42 GMT+0000 (Coordinated Universal Time) https://cloudconvert.com/about

@curtisbarry

star

Sat May 25 2024 21:26:06 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 18:36:09 GMT+0000 (Coordinated Universal Time)

@Mohamedshariif #c++

star

Sat May 25 2024 14:12:03 GMT+0000 (Coordinated Universal Time) https://codepen.io/arcs/pen/XKKYZW

@mdevil1619 #undefined

star

Sat May 25 2024 13:47:18 GMT+0000 (Coordinated Universal Time) https://codepen.io/arcs/pen/XKKYZW

@mdevil1619 #undefined

star

Sat May 25 2024 11:57:08 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 11:50:18 GMT+0000 (Coordinated Universal Time)

@madgakantara

star

Sat May 25 2024 09:53:53 GMT+0000 (Coordinated Universal Time) https://amincode.com/html/flex-it/

@radeguzvic

star

Sat May 25 2024 07:30:40 GMT+0000 (Coordinated Universal Time) https://medium.com/@dmktg9.singhal/the-manufacturing-process-of-pp-woven-fabric-a-comprehensive-guide-ea40bf83523f

@Singhalglobal

star

Fri May 24 2024 22:47:51 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Fri May 24 2024 20:14:55 GMT+0000 (Coordinated Universal Time)

@jdeveloper #php

star

Fri May 24 2024 16:27:52 GMT+0000 (Coordinated Universal Time)

@Farhana

star

Fri May 24 2024 15:02:13 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Fri May 24 2024 15:00:33 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Fri May 24 2024 14:13:44 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Fri May 24 2024 13:58:40 GMT+0000 (Coordinated Universal Time)

@rogueta #bash

star

Fri May 24 2024 12:41:03 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Fri May 24 2024 11:30:55 GMT+0000 (Coordinated Universal Time)

@webmasterUdL

star

Fri May 24 2024 09:53:56 GMT+0000 (Coordinated Universal Time) https://jitsi.github.io/handbook/docs/dev-guide/dev-guide-iframe/

@shookthacr3ator

star

Fri May 24 2024 09:21:12 GMT+0000 (Coordinated Universal Time)

@rafal_rydz

star

Fri May 24 2024 09:20:25 GMT+0000 (Coordinated Universal Time)

@rafal_rydz

star

Fri May 24 2024 09:19:33 GMT+0000 (Coordinated Universal Time)

@rafal_rydz

star

Fri May 24 2024 09:00:01 GMT+0000 (Coordinated Universal Time) https://blocksentinels.com/decentralized-exchange-development-company

@harsha98 #dex #decentralized

star

Fri May 24 2024 05:08:19 GMT+0000 (Coordinated Universal Time)

@tsesang

star

Fri May 24 2024 05:02:10 GMT+0000 (Coordinated Universal Time)

@dsce

star

Fri May 24 2024 05:01:20 GMT+0000 (Coordinated Universal Time)

@dsce

star

Fri May 24 2024 04:59:43 GMT+0000 (Coordinated Universal Time)

@dsce

star

Fri May 24 2024 04:59:05 GMT+0000 (Coordinated Universal Time)

@dsce

star

Fri May 24 2024 04:58:21 GMT+0000 (Coordinated Universal Time)

@dsce

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension